return addDefinitionImpl(belongingPdid, pdvid, version, name, description, isAdhoc, definition, folder, overwrite, null);
}
public String[] addDefinitionImpl(String belongingPdid, String pdvid, int version, String name, String description, boolean isAdhoc, Object definition, String folder, boolean overwrite, Map options) throws Exception{
ProcessDefinitionRepositoryHomeLocal pdhr = GlobalContext.createProcessDefinitionRepositoryHomeLocal(tc);
boolean verifyModifiedDateWhenOverwriting = true;
boolean isOtherResourceType = options!=null && options.containsKey("objectType");
String objectType = "upd";
if(isOtherResourceType)
objectType = (String)options.get("objectType");
//if there is no parent folder, this will throw an exception to break this try~catch block
if(UEngineUtil.isNotEmpty(folder) && !folder.equals("-1")){
try{
pdhr.findByPrimaryKey(new Long(folder));
}catch(javax.ejb.ObjectNotFoundException e){
throw new UEngineException("No such folder");
}
}else{
folder="-1";
}
//if there is no definition for this version, create new one
boolean definitionExist = false;
if(belongingPdid !=null){
try{
pdhr.findByPrimaryKey(new Long(belongingPdid));
definitionExist = true;
}catch(Exception e){
}
}
if(!definitionExist){
belongingPdid = ""+UniqueKeyGenerator.issueProcessDefinitionKey(tc);
ProcessDefinitionRepositoryLocal pdr = pdhr.create(new Long(belongingPdid));
pdr.setName(name);
pdr.setParentFolder(new Long(folder));
if(UEngineUtil.isNotEmpty(description))
pdr.setDescription(description);
if(options!=null && options.containsKey("objectType")){
objectType = (String)options.get("objectType");
pdr.setObjType(objectType);
}
if(options!=null && options.containsKey("alias")){
String alias = (String)options.get("alias");
pdr.setAlias(alias);
ProcessDefinitionRepositoryLocal pdrl=null;
try{
pdrl = pdhr.findByAlias(alias);
}catch(Exception e){
}
if(pdrl != null)
throw new UEngineException("This alias("+alias+") already exists, Write another keyword!");
}