Panel |
---|
|
Useful methods frequently used in the system concerning date, SQL and metadata handling. What does this section cover? |
...
Expand |
---|
|
truncate(Date date) method returns the date rounded to the day with a time of 00:00:00:00. setEndOfDay(Date date) method returns the date rounded to the day with a time of 23:59:59:999. Code Block |
---|
| public DateRange getDateRange(Date fromDate, Date toDate){
if (fromDate!=null && toDate!=null )
{
fromDate = DateUtil.truncate(fromDate);
toDate = DateUtil.setEndOfDay(toDate);
range = new DateRange(fromDate, toDate);
}
return range;
} |
|
...
Metadata Handling Methods
Metadata handling methods can be found in com.crm.framework.metadata.MetadataUtil class.
Expand |
---|
title | Get entity by class, id, type entity id and table |
---|
|
The following methods return an Entity object which holds information about the entity as defined in entities metadata file. getEntityByClass(String className, String context, String mpID) getEntity(String entityID, String context, String mpID) Code Block |
---|
title | Hibernate Query Example |
---|
| ...
Entity rentalEntity = MetadataUtil.getEntityByClass(CUSTOMCRMDORental.getClass().getName(), getCRMSession().getRealPath(), getOrganisationID());
String entityId = rentalEntity.getId();
String moduleId = rentalEntity.getModuleid();
String typeEntityId = rentalEntity.getTypeentityid();
Entity typeEntity = MetadataUtil.getEntity(typeEntityId, getCRMSession().getRealPath(), getOrganisationID());
... |
getEntityByTable(String tableName, String context, String mpID) getEntityByTypeEntity(String typeEntityID, String context, String mpID) Code Block |
---|
title | Hibernate Query Example |
---|
| ...
Entity rentalTypeEntity = MetadataUtil.getEntityByTable("TRN_RENTALTYPES", getCRMSession().getRealPath(), getOrganisationID());
Entity rentalEntity = MetadataUtil.getEntityByTypeEntity(rentalTypeEntity.getId() , getCRMSession().getRealPath(), getOrganisationID());
... |
|
Expand |
---|
|
The following method returns a Module object which holds information about the module as defined in modules metadata file. getModuleByID(String moduleID, String context, String mpid) Code Block |
---|
title | Hibernate Query Example |
---|
| ...
String moduleId = rentalEntity.getModuleid();
Module module = MetadataUtil.getModuleByID(moduleId, getCRMSession().getRealPath(), getOrganisationID());
... |
|
Expand |
---|
title | Get module additional process |
---|
|
The following method returns a Process object which holds information about the process as defined in modules metadata file. getModuleAdditionalProcess(Module module, String processID) Code Block |
---|
title | Hibernate Query Example |
---|
| ...
Process process = MetadataUtil.getModuleAdditionalProcess(rentalsModule, "CUSTOM_SET_RENTAL_AS_EFFECTIVE");
ArrayList<Method> methods = process.getMethods();
... |
|