Integer dsIdInt = new Integer(dsIdStr);
ds = DAOFactory.getDataSourceDAO().loadDataSourceByID(dsIdInt);
}
String datasetIdStr = (String) request.getAttribute("dataset");
IDataSet dataset = null;
if (datasetIdStr != null && !datasetIdStr.equals("")) {
Integer datasetIdInt = new Integer(datasetIdStr);
dataset = DAOFactory.getDataSetDAO().loadActiveIDataSetByID(datasetIdInt);
}
// TRY TO LOAD ALL THE FUNCTIONALITIES ASSOCIATED (into request) TO THE BIOBEJCT
List functionalities = new ArrayList();
List functionalitiesStr = request.getAttributeAsList(ObjectsTreeConstants.FUNCT_ID);
if (functionalitiesStr.size() == 0) {
EMFValidationError error = new EMFValidationError(EMFErrorSeverity.ERROR, ObjectsTreeConstants.FUNCT_ID, "1008");
this.respCont.getErrorHandler().addError(error);
} else {
for (Iterator it = functionalitiesStr.iterator(); it.hasNext(); ) {
String functIdStr = (String) it.next();
Integer functId = new Integer (functIdStr);
functionalities.add(functId);
}
}
// lOAD ALL THE FUNCTIONALITIES ASSOCIATED TO THE BIOBJECT (but not into request)
// First case: the current user is not an administrator (so he cannot see all the functionalities)
// and the modality is Modify. In this case some functionalities, that the user cannot see, can be
// already associated to the object (by different users). This associations mustn't be erased.
if (!profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN) && mod.equalsIgnoreCase(ObjectsTreeConstants.DETAIL_MOD)) {
IBIObjectDAO objDAO = DAOFactory.getBIObjectDAO();
BIObject prevObj = objDAO.loadBIObjectById(id);
List prevFuncsId = prevObj.getFunctionalities();
for (Iterator it = prevFuncsId.iterator(); it.hasNext(); ) {
Integer funcId = (Integer) it.next();
if (!ObjectsAccessVerifier.canDev(stateCode, funcId, profile)) {
functionalities.add(funcId);
}
}
}
// Second case: the current user is a local administrator (he can admin only a part of the tree)
// and the modality is Modify. In this case some funtionalities in oder part of the tree, which the
// user cannot see, can be already associated to the object. This associations mustn't be erased.
if (profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)
&& initialPath != null && !initialPath.trim().equals("")
&& mod.equalsIgnoreCase(ObjectsTreeConstants.DETAIL_MOD)) {
IBIObjectDAO objDAO = DAOFactory.getBIObjectDAO();
BIObject prevObj = objDAO.loadBIObjectById(id);
List functionalitiesId = prevObj.getFunctionalities();
Iterator it = functionalitiesId.iterator();
while (it.hasNext()) {
Integer folderId = (Integer) it.next();
LowFunctionality folder = DAOFactory.getLowFunctionalityDAO().loadLowFunctionalityByID(folderId, false);
String folderPath = folder.getPath();
if (!folderPath.equalsIgnoreCase(initialPath) && !folderPath.startsWith(initialPath + "/")) {
functionalities.add(folderId);
}
}
}
// CHECK IF THE LABEL IS ALREADY ASSIGNED TO AN EXISTING OBJECT
BIObject aBIObject = DAOFactory.getBIObjectDAO().loadBIObjectByLabel(label);
if (aBIObject != null && !aBIObject.getId().equals(id)) {
EMFValidationError error = new EMFValidationError(EMFErrorSeverity.ERROR, "label", "1056");
this.respCont.getErrorHandler().addError(error);
}
// SET DATA INTO OBJECT
obj.setFunctionalities(functionalities);
obj.setBiObjectTypeCode(typeCode);
obj.setBiObjectTypeID(typeIdInt);
obj.setDescription(description);
obj.setEncrypt(encrypt);
obj.setVisible(visible);
obj.setProfiledVisibility(profiledVisibilityStr);
obj.setEngine(engine);
obj.setDataSourceId(ds == null ? null : new Integer(ds.getDsId()));
obj.setDataSetId(dataset == null ? null : new Integer(dataset.getId()));
obj.setId(id);
obj.setName(name);
obj.setLabel(label);
obj.setRelName(relname);
obj.setStateCode(stateCode);