if (hibObjPar == null) {
logger.error("the BIObjectParameter with id="+aBIObjectParameter.getId()+" does not exist.");
throw new EMFUserError(EMFErrorSeverity.ERROR, 1033);
}
SbiObjects aSbiObject = (SbiObjects) aSession.load(SbiObjects.class, aBIObjectParameter.getBiObjectID());
SbiParameters aSbiParameter = (SbiParameters)aSession.load(SbiParameters.class, aBIObjectParameter.getParameter().getId());
hibObjPar.setSbiObject(aSbiObject);
hibObjPar.setSbiParameter(aSbiParameter);
hibObjPar.setLabel(aBIObjectParameter.getLabel());
hibObjPar.setReqFl(new Short(aBIObjectParameter.getRequired().shortValue()));
hibObjPar.setModFl(new Short(aBIObjectParameter.getModifiable().shortValue()));
hibObjPar.setViewFl(new Short(aBIObjectParameter.getVisible().shortValue()));
hibObjPar.setMultFl(new Short(aBIObjectParameter.getMultivalue().shortValue()));
hibObjPar.setParurlNm(aBIObjectParameter.getParameterUrlName());
Integer oldPriority = hibObjPar.getPriority();
Integer newPriority = aBIObjectParameter.getPriority();
if (!oldPriority.equals(newPriority)) {
Query query = null;
if (oldPriority.intValue() > newPriority.intValue()) {
String hqlUpdateShiftRight = "update SbiObjPar s set s.priority = (s.priority + 1) where s.priority >= "
+ newPriority + " and s.priority < " + oldPriority + "and s.sbiObject.biobjId = " + aSbiObject.getBiobjId();
query = aSession.createQuery(hqlUpdateShiftRight);
} else {
String hqlUpdateShiftLeft = "update SbiObjPar s set s.priority = (s.priority - 1) where s.priority > "
+ oldPriority + " and s.priority <= " + newPriority + "and s.sbiObject.biobjId = " + aSbiObject.getBiobjId();
query = aSession.createQuery(hqlUpdateShiftLeft);
}
query.executeUpdate();
}
hibObjPar.setPriority(newPriority);