Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel
nameblue

Useful methods frequently used in the system concerning date, SQL and metadata handling.

What does this section cover?

Table of Contents

...

Expand
titleTruncate Date

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
titleExample
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;
}

...

Expand
titleGet 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
titleHibernate Query Example
...
Process process = MetadataUtil.getModuleAdditionalProcess(rentalsModule, "CUSTOM_SET_RENTAL_AS_EFFECTIVE");	
ArrayList<Method> methods = process.getMethods();
...
Expand
titleGet Variable

The following method returns a global variable value as defined in variables metadata file.

getVariable(String variableName, String context, String mpID)

Code Block
titleHibernate Query Example
...
String testVariableValue= MetadataUtil.getVariable("myvariable", getCRMSession().getRealPath(), getOrganisationID());
...