Versions Compared

Key

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

...

Code Block
languagejs
linenumberstrue
collapsetrue
			var Logic = function(wfItem, dtoPj, superLogic, errors, messageUtil, request, gaService, wfService, wfTaskService, searchBuilderTemplate, log) {
			this.wfItem=wfItem;
			this.dtoPj=dtoPj;
			this.superLogic=superLogic;
			this.errors=errors;
			this.messageUtil=messageUtil;
			this.request=request;
			this.gaService=gaService;
			this.wfService=wfService;
			this.wfTaskService=wfTaskService;
			this.searchBuilderTemplate=searchBuilderTemplate;
			this.log=log;
			this.setInternalOrgUnitList = function() {
				var internalOrganizationUnitSet = Packages.it.cilea.core.fragment.util.FragmentUtil.getCurrentFragmentSetByParentAndDiscriminator(wfItem, "it.cilea.wf.model.WfItemElement","internalOrganizationUnit", wfService);
				var internalOrganizationUnitSetIterator=internalOrganizationUnitSet.iterator();
				while (internalOrganizationUnitSetIterator.hasNext()){
					var element=internalOrganizationUnitSetIterator.next();
					var orgUnit = element.getOrganizationUnitMap().get("ouId");
					var orgUnitRole = element.getWfDictionaryMap().get("ouRole");
					dtoPj.getDTOUoPjs().add(superLogic.getOrganizationUnit(orgUnit, orgUnitRole, errors));
				}
			};			
			this.setFinanciers = function() {
				var sendCustomer2Ugov=Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.contract.customer.send2ugov.enable");
				if (sendCustomer2Ugov && sendCustomer2Ugov.trim().equalsIgnoreCase("true")){
					var contractorSet = Packages.it.cilea.core.fragment.util.FragmentUtil.getCurrentFragmentSetByParentAndDiscriminator(wfItem, "it.cilea.wf.model.WfItemElement", "customer",wfService);
					var contractorSetIterator=contractorSet.iterator();
					while (contractorSetIterator.hasNext()){
						var element=contractorSetIterator.next();
						var organizationUnit = element.getOrganizationUnitMap().get("customerId");
						var enteFinanziatore = superLogic.getEnteFinanziatore(organizationUnit, this.getFinancing(), contractorSet.size(), errors);
						dtoPj.getDTOEfPjs().add(enteFinanziatore);
					}
				}
			};
			this.setPartners = function() {};
			this.getFinancing = function() {				
				return wfItem.getNumberMap().get("totalAmount");
			};
			this.getStartDate = function() {
				return wfItem.getDateMap().get("startDate");			    	
			};
			this.getEndDate = function() {
				return wfItem.getDateMap().get("endDate");			    
			};
			this.getExpenditureStartDate = function() {
				return wfItem.getDateMap().get("startDate");			    	
			};
			this.getExpenditureEndDate = function() {
				return wfItem.getDateMap().get("endDate");			    
			};
			this.getIdentifier = function() {	
				return wfItem.getIdentifier();
			};
			this.getIdPj = function() {     
 	 			if(wfItem.getIntegerMap().get("ugovId") != null){
 	 	        	return wfItem.getIntegerMap().get("ugovId");
 	            } else {
 	                return null;
 	            }
 	 	    };
			this.getDescription = function() {
				if(wfItem.getDescription()!=null){
					var length=wfItem.getDescription().length();
					return wfItem.getDescription().substring(0,(length>255)?255:length);
				} else {
					return null;
				}
			};
			this.getCup = function() {
				var sendCup2Ugov = Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.con.cup.send2ugov.enable");
				if (sendCup2Ugov && sendCup2Ugov.trim().equalsIgnoreCase("true")){
					return wfItem.getStringMap().get("cup");
				} else {
					return null;
				}		
			};
			this.getAcronym = function() {
				if(wfItem.getStringMap().get("acronym") != null){
					var length = wfItem.getStringMap().get("acronym").length();
					return wfItem.getStringMap().get("acronym").substring(0,(length>50)?50:length);
				} else {
					return null;
				}
			};
			this.getExternalDmsIdentifier = function() {
				return wfItem.getStringMap().get("externalDmsIdentifier");
			};						
			this.isSynchronizable = function() {
				var financing=this.getFinancing();
				var legacy=wfItem.getBooleanMap().get("legacy");
				if (Packages.java.lang.Boolean.TRUE.equals(legacy) || financing==null || Packages.java.math.BigDecimal.ZERO.equals(financing))
					return Packages.java.lang.Boolean.FALSE;
				else			    
					return Packages.java.lang.Boolean.TRUE;
			};
			this.getProjectType = function() {
				return superLogic.getProjectType(wfItem);
			};
			this.getFinanceSchema = function() {
				return this.getProjectType();
			};
			this.getPjInternalCode = function() {
				return null;
			};
			this.isContributorStartDateRequired = function() {						
				var contributorStartDateRequired=Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.contract.contributor.starDate.required");
				if (contributorStartDateRequired){
					if (contributorStartDateRequired.trim().equalsIgnoreCase("true")){
						return Packages.java.lang.Boolean.TRUE;
					} else if (contributorStartDateRequired.trim().equalsIgnoreCase("false")){
						return Packages.java.lang.Boolean.FALSE;
					} else {
						throw "ap.contract.contributor.starDate.required MUST BE true or false";
					}
				} else {
					return Packages.java.lang.Boolean.TRUE;
				}							    
			};				
			this.isOwnerStartDateRequired = function() {
				var ownerStartDateRequired=Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.contract.owner.starDate.required");
				if (ownerStartDateRequired){
					if (ownerStartDateRequired.trim().equalsIgnoreCase("true")){
						return Packages.java.lang.Boolean.TRUE;
					} else if (ownerStartDateRequired.trim().equalsIgnoreCase("false")){
						return Packages.java.lang.Boolean.FALSE;
					} else {
						throw "ap.contract.owner.starDate.required MUST BE true or false";
					}
				} else {
					return Packages.java.lang.Boolean.TRUE;
				}
			};
		};
		new Logic(wfItem, dtoPj, superLogic, errors, messageUtil, request, gaService, wfService, wfTaskService, searchBuilderTemplate, log);
		

...

Code Block
languagejs
linenumberstrue
collapsetrue
			var Logic = function(wfItem, dtoPj, superLogic, errors, messageUtil, request, gaService, wfService, wfTaskService, searchBuilderTemplate, log) {
			this.wfItem=wfItem;
			this.dtoPj=dtoPj;
			this.superLogic=superLogic;
			this.errors=errors;
			this.messageUtil=messageUtil;
			this.request=request;
			this.gaService=gaService;
			this.wfService=wfService;
			this.wfTaskService=wfTaskService;
			this.searchBuilderTemplate=searchBuilderTemplate;
			this.log=log;
			this.setInternalOrgUnitList = function() {
				var internalOrganizationUnitSet = Packages.it.cilea.core.fragment.util.FragmentUtil.getCurrentFragmentSetByParentAndDiscriminator(wfItem, "it.cilea.wf.model.WfItemElement","internalOrganizationUnit", wfService);
				var internalOrganizationUnitSetIterator=internalOrganizationUnitSet.iterator();
				while (internalOrganizationUnitSetIterator.hasNext()){
					var element=internalOrganizationUnitSetIterator.next();
					var orgUnit = element.getOrganizationUnitMap().get("ouId");
					var orgUnitRole = element.getWfDictionaryMap().get("ouRole");
					dtoPj.getDTOUoPjs().add(superLogic.getOrganizationUnit(orgUnit, orgUnitRole, errors));
				}
			};			
			this.setFinanciers = function() {
				var sendGrantor2Ugov=Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.project.grantor.send2ugov.enable");
				if (sendGrantor2Ugov && sendGrantor2Ugov.trim().equalsIgnoreCase("true")){
					var contractorSet = Packages.it.cilea.core.fragment.util.FragmentUtil.getCurrentFragmentSetByParentAndDiscriminator(wfItem, "it.cilea.wf.model.WfItemElement", "grantor",wfService);
					var contractorSetIterator=contractorSet.iterator();
					while (contractorSetIterator.hasNext()){
						var element=contractorSetIterator.next();
						var organizationUnit = element.getOrganizationUnitMap().get("grantorId");
						var enteFinanziatore = superLogic.getEnteFinanziatore(organizationUnit, this.getFinancing(), contractorSet.size(), errors);
						dtoPj.getDTOEfPjs().add(enteFinanziatore);
					}
				}
			};
			this.setPartners = function() {
				var sendPartner2Ugov=Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.project.partner.send2ugov.enable");
				if (sendPartner2Ugov && sendPartner2Ugov.trim().equalsIgnoreCase("true")){
					var partnerSet = Packages.it.cilea.core.fragment.util.FragmentUtil.getCurrentFragmentSetByParentAndDiscriminator(wfItem, "it.cilea.wf.model.WfItemElement", "partner",wfService);
					var partnerSetIterator=partnerSet.iterator();
					while (partnerSetIterator.hasNext()){
						var element=partnerSetIterator.next();
						var organizationUnit = element.getOrganizationUnitMap().get("partnerId");
						var partnerRole = element.getWfDictionaryMap().get("partnerRole");
						var partecipante = superLogic.getPartecipante(organizationUnit,  partnerRole, errors);
						dtoPj.getDTOPartPjs().add(partecipante)
					}
				}			
			};
			this.getFinancing = function() {
				var coordinatorRoleId=Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.project.partner.role.main");
				var myOrganization=Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.project.partner.myOrganization");
				var forcedPjInternalCost=Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.project.financing.internalCost.send2ugov.forced");
				if (forcedPjInternalCost==null)
					forcedPjInternalCost=false;
				else if (forcedPjInternalCost.equalsIgnoreCase("true")){				
					forcedPjInternalCost=true;
				} else {
					forcedPjInternalCost=false;
				}
				
				if (!forcedPjInternalCost){
					if (coordinatorRoleId==null || myOrganization==null){
						throw "Configuration variables ap.project.partner.role.main and ap.project.partner.myOrganization MUST BE DEFINED";
					} else {
						coordinatorRoleId=new Packages.java.lang.Integer(coordinatorRoleId);
						myOrganization=new Packages.java.lang.Integer(myOrganization);
					}		
					var partnerSet = Packages.it.cilea.core.fragment.util.FragmentUtil.getCurrentFragmentSetByParentAndDiscriminator(wfItem, "it.cilea.wf.model.WfItemElement", "partner",wfService);
					var partnerSetIterator=partnerSet.iterator();
					while (partnerSetIterator.hasNext()){
						var element=partnerSetIterator.next();			 
						var orgUnitRole = element.getWfDictionaryMap().get("partnerRole");
						if (orgUnitRole==null){
							errors.reject("error.project.partner.missingRole");
							throw "Detected partner without role";
						}
						
						var orgUnit = element.getOrganizationUnitMap().get("partnerId");
						if(myOrganization.equals(orgUnit.getId()) && coordinatorRoleId.equals(orgUnitRole.getId())){				
							var globalCost=wfItem.getNumberMap().get("globalCost");
							if (globalCost==null)
								globalCost=Packages.java.math.BigDecimal.ZERO;
							
							var globalContribution=wfItem.getNumberMap().get("globalContribution");
							if (globalContribution==null)
								globalContribution=Packages.java.math.BigDecimal.ZERO;
							
							var internalCofinancing=wfItem.getNumberMap().get("internalCofinancing");
							if (internalCofinancing==null)
								internalCofinancing=Packages.java.math.BigDecimal.ZERO;
							
							return globalCost.subtract(globalCost.subtract(globalContribution).subtract(internalCofinancing));
						}			
					}
				}				
				return wfItem.getNumberMap().get("internalCost");
			};
			this.getStartDate = function() {
				var expenditureDateEnabled=Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.project.date.expenditure.send2ugov.enabled");
				var expenditureAndActivityDateEnabled = Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.project.date.activityAndExpenditure.send2ugov.enabled");
				if (expenditureDateEnabled && expenditureDateEnabled.trim().equalsIgnoreCase("true") && expenditureAndActivityDateEnabled && expenditureAndActivityDateEnabled.trim().equalsIgnoreCase("true")){
					throw "ap.project.date.expenditure.send2ugov.enabled and ap.project.date.activityAndExpenditure.send2ugov.enabled CANNOT BE BOTH TRUE";
				} else {
					if (expenditureDateEnabled && expenditureDateEnabled.trim().equalsIgnoreCase("true")){
						if (wfItem.getDateMap().get("expenditureStartDate")!=null)
							return wfItem.getDateMap().get("expenditureStartDate");
						else
							return wfItem.getDateMap().get("startDate");
					} else {
						return wfItem.getDateMap().get("startDate");
					}	
				}					    	
			};
			this.getEndDate = function() {
				var expenditureDateEnabled=Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.project.date.expenditure.send2ugov.enabled");
				var expenditureAndActivityDateEnabled = Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.project.date.activityAndExpenditure.send2ugov.enabled");
				if (expenditureDateEnabled && expenditureDateEnabled.trim().equalsIgnoreCase("true")){
					if (wfItem.getDateMap().get("expenditureEndDate")!=null)
						return wfItem.getDateMap().get("expenditureEndDate");
					else
						return wfItem.getDateMap().get("endDate");
				} else {
					return wfItem.getDateMap().get("endDate");
				}		
			};
						
			this.getIdentifiergetExpenditureStartDate = function() {	
				return wfItem.getIdentifier(    var expenditureDateEnabled=Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.project.date.expenditure.send2ugov.enabled");
				var expenditureAndActivityDateEnabled = Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.project.date.activityAndExpenditure.send2ugov.enabled");
				if (expenditureDateEnabled && expenditureDateEnabled.trim().equalsIgnoreCase("true") && expenditureAndActivityDateEnabled && expenditureAndActivityDateEnabled.trim().equalsIgnoreCase("true")){
					throw "ap.project.date.expenditure.send2ugov.enabled and ap.project.date.activityAndExpenditure.send2ugov.enabled CANNOT BE BOTH TRUE";
				} else {
					if (expenditureAndActivityDateEnabled && expenditureAndActivityDateEnabled.trim().equalsIgnoreCase("true")){
				    	return wfItem.getDateMap().get("expenditureStartDate");
				    } else {
						if (expenditureDateEnabled && expenditureDateEnabled.trim().equalsIgnoreCase("true")){
							if (wfItem.getDateMap().get("expenditureStartDate")!=null)
								return wfItem.getDateMap().get("expenditureStartDate");
							else
								return wfItem.getDateMap().get("startDate");
						} else {
							return wfItem.getDateMap().get("startDate");
						}	
					}		
				}
			    				    	
			};
			this.getExpenditureEndDate = function() {
				var expenditureAndActivityDateEnabled = Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.project.date.activityAndExpenditure.send2ugov.enabled");
			    if (expenditureAndActivityDateEnabled && expenditureAndActivityDateEnabled.trim().equalsIgnoreCase("true")){
			    	return wfItem.getDateMap().get("expenditureEndDate");
			    } else {
			    
					var expenditureDateEnabled=Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.project.date.expenditure.send2ugov.enabled");
					if (expenditureDateEnabled && expenditureDateEnabled.trim().equalsIgnoreCase("true")){
						if (wfItem.getDateMap().get("expenditureEndDate")!=null)
							return wfItem.getDateMap().get("expenditureEndDate");
						else
							return wfItem.getDateMap().get("endDate");
					} else {
						return wfItem.getDateMap().get("endDate");
					}		
				}
			};
						
			this.getIdentifier = function() {	
				return wfItem.getIdentifier();
			};
			this.getIdPj = function() {     
 	 			if(wfItem.getIntegerMap().get("ugovId") != null){
 	 	        	return wfItem.getIntegerMap().get("ugovId");
 	            } else {
 	                return null;
 	            }
 	 	    };
			this.getDescription = function() {
				if(wfItem.getDescription()!=null){
					var length=wfItem.getDescription().length();
					return wfItem.getDescription().substring(0,(length>255)?255:length);
				} else {
					return null;
				}
			};
			this.getCup = function() {
				var sendCup2Ugov = Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.project.cup.send2ugov.enable");
				if (sendCup2Ugov && sendCup2Ugov.trim().equalsIgnoreCase("true")){
					return wfItem.getStringMap().get("cup");
				} else {
					return null;
				}				
			};
			this.getAcronym = function() {
				if(wfItem.getStringMap().get("acronym") != null){
					var length = wfItem.getStringMap().get("acronym").length();
					return wfItem.getStringMap().get("acronym").substring(0,(length>50)?50:length);
				} else {
					return null;
				}
			};
			this.getExternalDmsIdentifier = function() {
				return wfItem.getStringMap().get("externalDmsIdentifier");
			};
			this.isSynchronizable = function() {
				var legacy=wfItem.getBooleanMap().get("legacy");
				var financing=this.getFinancing();				
				if (Packages.java.lang.Boolean.TRUE.equals(legacy) || financing==null || Packages.java.math.BigDecimal.ZERO.equals(financing))
					return Packages.java.lang.Boolean.FALSE;
				else			    
					return Packages.java.lang.Boolean.TRUE;
			};
			this.getProjectType = function() {
				return superLogic.getProjectType(wfItem);
			};
			this.getFinanceSchema = function() {
				return this.getProjectType();
			};
			this.getPjInternalCode = function() {
				return null;
			};
			this.isContributorStartDateRequired = function() {						
				var contributorStartDateRequired=Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.project.contributor.starDate.required");
				if (contributorStartDateRequired){
					if (contributorStartDateRequired.trim().equalsIgnoreCase("true")){
						return Packages.java.lang.Boolean.TRUE;
					} else if (contributorStartDateRequired.trim().equalsIgnoreCase("false")){
						return Packages.java.lang.Boolean.FALSE;
					} else {
						throw "ap.project.contributor.starDate.required MUST BE true or false";
					}
				} else {
					return Packages.java.lang.Boolean.TRUE;
				}							    
			};				
			this.isOwnerStartDateRequired = function() {
				var ownerStartDateRequired = Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.project.owner.starDate.required");
				if (ownerStartDateRequired){
					if (ownerStartDateRequired.trim().equalsIgnoreCase("true")){
						return Packages.java.lang.Boolean.TRUE;
					} else if (ownerStartDateRequired.trim().equalsIgnoreCase("false")){
						return Packages.java.lang.Boolean.FALSE;
					} else {
						throw "ap.project.owner.starDate.required MUST BE true or false";
					}
				} else {
					return Packages.java.lang.Boolean.TRUE;
				}
			};
		};
		new Logic(wfItem, dtoPj, superLogic, errors, messageUtil, request, gaService, wfService, wfTaskService, searchBuilderTemplate, log);
		

...

Anchor
organizationUnitValidatorProject-anchor
organizationUnitValidatorProject-anchor
organizationUnitValidatorProject
Questa validazione controlla che esista almeno una unità organizzativa interna nel tab "Soggetti interni".
Dal punto di vista del modello dati si tratta degli elementi di tipo internalOrganizationUnit
Per maggiori dettagli cfr. excel modello dati dell'entità Progetto
Code Block
languagejs
linenumberstrue
collapsetrue
			
			if (!Packages.java.lang.Boolean.TRUE.equals(wfItem.getBooleanMap().get("legacy"))){				
				var orgUnitSet = Packages.it.cilea.core.fragment.util.FragmentUtil.getCurrentFragmentSetByParentAndDiscriminator(object, "getWfItemElementSet", "it.cilea.wf.model.WfItemElement", "internalOrganizationUnit", wfService);
				if (orgUnitSet.size()<1)
					errors.reject("error.project.multipleInternalOrganization.atLeast1");		
			}
		

Anchor
internalOrganizationUnitCostRequiredValidatorProject-anchor
internalOrganizationUnitCostRequiredValidatorProject-anchor
internalOrganizationUnitCostRequiredValidatorProject
Questa validazione controlla che esista almeno una Struttura Interna associata ai finanziamenti totali nel tab "Soggetti interni".
Dal punto di vista del modello dati si tratta degli elementi di tipo internalOrganizationUnitCost
Per maggiori dettagli cfr. excel modello dati dell'entità Progetto
Code Block
languagejs
linenumberstrue
collapsetrue
		
			var internalOrganizationUnitCostSet = Packages.it.cilea.core.fragment.util.FragmentUtil.getCurrentFragmentSetByParentAndDiscriminator(object, "getWfItemElementSet", "it.cilea.wf.model.WfItemElement", "internalOrganizationUnitCost", wfService);
			if (!Packages.java.lang.Boolean.TRUE.equals(wfItem.getBooleanMap().get("legacy")) && internalOrganizationUnitCostSet.size() < 1 )
				errors.reject("error.project.internalOrganizationUnitCost.atLeast1");
		

Anchor
ethicCommiteeApplicabilityValidatorProject-anchor
ethicCommiteeApplicabilityValidatorProject-anchor
ethicCommiteeApplicabilityValidatorProject
Questa validazione controlla che venga dichiarato se
sono previste attività di ricerca che prevedono sperimentazioni passibili di giudizio da parte del Comitato Etico.
Code Block
languagejs
linenumberstrue
collapsetrue
			if (!Packages.java.lang.Boolean.TRUE.equals(wfItem.getBooleanMap().get("legacy"))){		
				var ethicCommiteeApplicability = object.getBooleanMap().get("ethicCommiteeApplicability");
				if(ethicCommiteeApplicability == null){
					errors.reject("error.project.ethicCommiteeApplicability.required");
				}
			}
		

...