* @return The Integer representing the execution id
*/
public Integer insertAudit(BIObject obj, SubObject subObj, IEngUserProfile profile, String role, String modality) {
logger.debug("IN");
_auditDAO.setUserProfile(profile);
SbiAudit audit = new SbiAudit();
logger.debug("userID for audit"+ ((UserProfile)profile).getUserId().toString());
audit.setUserName(((UserProfile)profile).getUserId().toString());
audit.setUserGroup(role);
audit.setDocumentId(obj.getId());
audit.setDocumentLabel(obj.getLabel());
audit.setDocumentName(obj.getName());
audit.setDocumentType(obj.getBiObjectTypeCode());
audit.setDocumentState(obj.getStateCode());
String documentParameters = "";
List parameters = obj.getBiObjectParameters();
ParameterValuesEncoder parValuesEncoder = new ParameterValuesEncoder();
if (parameters != null && parameters.size() > 0) {
for (int i = 0; i < parameters.size(); i++) {
BIObjectParameter parameter = (BIObjectParameter) parameters.get(i);
documentParameters += parameter.getParameterUrlName() + "=";
if (parameter.getParameterValues() != null) {
String value = parValuesEncoder.encode(parameter);
documentParameters += value;
} else
documentParameters += "NULL";
if (i < parameters.size() - 1)
documentParameters += "&";
}
}
audit.setDocumentParameters(documentParameters);
if (subObj != null) {
audit.setSubObjId(subObj.getId());
audit.setSubObjName(subObj.getName());
audit.setSubObjOwner(subObj.getOwner());
audit.setSubObjIsPublic(subObj.getIsPublic().booleanValue() ? new Short((short) 1) : new Short((short) 0));
}
Engine engine = obj.getEngine();
audit.setEngineId(engine.getId());
audit.setEngineLabel(engine.getLabel());
audit.setEngineName(engine.getName());
Domain engineType = null;
try {
engineType = DAOFactory.getDomainDAO().loadDomainById(engine.getEngineTypeId());
} catch (EMFUserError e) {
logger.error("Error retrieving document's engine information", e);
}
audit.setEngineType(engineType != null ? engineType.getValueCd() : null);
if (engineType != null) {
if ("EXT".equalsIgnoreCase(engineType.getValueCd())) {
audit.setEngineUrl(engine.getUrl());
audit.setEngineDriver(engine.getDriverName());
} else {
audit.setEngineClass(engine.getClassName());
}
}
audit.setRequestTime(new Timestamp(System.currentTimeMillis()));
audit.setExecutionModality(modality);
audit.setExecutionState("EXECUTION_REQUESTED");
try {
insertAudit(audit);
} catch (EMFUserError e) {
logger.error("Error doing audit insertion", e);
return null;
}
logger.debug("OUT");
return audit.getId();
}