viernes, 25 de enero de 2013
Drools 5.0 - Read rules
Another form to read the Droools rules is through a FileInputStream
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
.newKnowledgeBuilder();
FileInputStream fis = new FileInputStream(url);
kbuilder.add(ResourceFactory.newInputStreamResource(fis), ResourceType.DTABLE);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error : errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
Instead of
kbuilder.add(ResourceFactory.newClassPathResource(url), ResourceType.DRL);
lunes, 7 de enero de 2013
PrimeFaces - Mobile
To implement PrimeFaces for mobile you have to do some changes to the implementation.
- POM
- Add this repository & dependencies
- FACES-CONFIG.xml
- <repository>
- <id>prime-repo</id>
- <name>Prime Repo</name>
- <url>http://repository.primefaces.org</url>
- <layout>default</layout>
- </repository>
-
<dependency>
- <groupId>org.primefaces</groupId>
- <artifactId>primefaces</artifactId>
- <version>3.3</version>
- </dependency>
<dependency>
- <groupId>org.primefaces</groupId>
- <artifactId>primefaces-mobile</artifactId>
- <version>0.9.3</version>
- </dependency>
- Add in the tag<application> <application>
- <default-render-kit-id>PRIMEFACES_MOBILE</default-render-kit-id>
- </application>
- XHTML
- Add in the libraries xmlns:pm="http://primefaces.org/mobile"
- Insert the tag <f:view> instead of <h:body> <f:view xmlns:pm="http://primefaces.org/mobile" contentType="text/html" renderKitId="PRIMEFACES_MOBILE">
- Insert the tag <pm:page> <pm:page title="Title page">
- Insert the tag <pm:view> <pm:view id="main">
- If you want to display a header in the page, insert <pm:header> <pm:header title="Mobile" swatch="b"/>
- There are 5 themes (swatch values): "a", "b", "c", "d", "e"
- In the <p:inputText> there is an attribute label, so you don´t have to user the <h:outputLabel> element
- The nature of the tag <f:facet> in different
- The tag <p:dataList> works better than <p:dataTable>
Oracle BPM - Oracle WebLogic Server
- Install DB (wls1035_win32.exe)
- Welcome Screen -> Next
- Choose Middleware Home Directory Screen
- Select Create a new Middleware Home. -> Next
- Register for Security Updates Screen -> Next
- Choose Install Type Screen
- Select Typical. -> Next
- Choose Product Installation Directories Screen -> Next
- Choose Shortcut Location (Windows only) -> Next
- Installation Summary Screen -> Next
- Installation Complete Screen
- De-select Run Quickstart. -> Done
viernes, 4 de enero de 2013
Oracle BPM - RCU
- Install DB (OracleXE112_Win32)
- Install the RCU (ofm_rcu_win_11.1.1.5.0_disk1_1of1.zip)
- Unzip in path C:\ to avoid the message error Windows cannot find 'C:\Documents'.
- Create the environment variable RCU_JDBC_TRIM_BLOCKS with value TRUE
- Setup steps
- Welcome Screen -> Next
- Create Repository Screen -> Next
- Database Connection Details Screen -> Next (Accept the warning)
- Host Name: localhost Ex. ora-node1-vip.example.com
- Port: 1521 by default
- Database Name: xe
- User: SYS
- Pwd: Has to be the password from the DB
- Role: for user SYS the role has to be SYSDBA role
- Select Components Screen
- Schema Passwords Screen
- Select Use same password for all schemas.
- Type password
- Map Tablespaces Screen -> Next
- Summary Screen -> Create -> Next
- Completion Summary Screen -> Close
You has finished your RCU installation =)
Oracle BPM - Errors
Error:
Current Value: 100, it should be greater than or equal to 200.
Solution:
- Login on your database with system user.
SQL> connect system
Enter password:
Connected.
- Type:
- show parameters processes (which will show the current value of processes).
- ALTER SYSTEM SET PROCESSES=200 SCOPE=SPFILE;
- show parameters open_cursors (which will show the current value of open_cursors).
- ALTER SYSTEM SET OPEN_CURSORS=200 SCOPE=SPFILE;
- Restart DB.
viernes, 28 de diciembre de 2012
Hibernate - Queries
Load an entity
There are two forms to get an entity with the methods load() or get().
public Category getCategory(Long catId) throws DataAccessException {
There are two forms to get an entity with the methods load() or get().
public Category getCategory(Long catId) throws DataAccessException {
return (Category) this.getSessionFactory().getCurrentSession()
.load(Category.class, catId); }
public Category getCategory(Long catId) throws DataAccessException { return (Category) this.getSessionFactory().getCurrentSession().get(Category.class, catId); }The difference are:
- load()
- Throws an exception if there isn't any row.
- Has performane benefits.
- get()
- Return null if there isn't any row.
HibernateTemplate - Using Parameters with findByNamedParamIn case of use only one parameter, you need the query, parameter name and the value.public List<ArtEntity> getArtworkInCategory(Long catId) throws DataAccessException { return this.getHibernateTemplate().findByNamedParam( "select art from Category cat " + "join cat.artEntities art " + "where cat.id = :catId ", "catId", catId ); }
In case of many parameters, you need the query, array with the parameters and the array with corresponding valuespublic Person authenticatePerson(String username, String password) throws DataAccessException, AuthenticationException { List<Person> validUsers = this.getHibernateTemplate().findByNamedParam( "select people from Person people where" + "people.username = :username " + "and people.password = :password", new String[] {"username", "password"}, new String[] {username, password } ); if (validUsers == null || validUsers.size() <= 0) { throw new AuthenticationException("No users found"); } else { return validUsers.get(0); } }
Hibernate Core APIs - Using Parameters
public Person authenticatePerson(String username, String password) throws DataAccessException, AuthenticationException { Person validUser = (Person) this.getSessionFactory().getCurrentSession().createQuery( "select people from Person people where" + "people.username = :username " + "and people.password = :password") .setString("username", username) .setString("password", password) .uniqueResult() ); if (validUser == null) { throw new AuthenticationException("No users found");
} else { return validUser; } }
Suscribirse a:
Entradas (Atom)