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("roleId");
					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(organizationUnitelement, this.getFinancing(), contractorSet.size(), errors);
						dtoPj.getDTOEfPjs().add(enteFinanziatore);
					}
				}
			};
			this.setPartners = function() {};
			this.getResearchNature = function() {
				return null;
			};
			this.getContribution = function() {
				return null;
			};
			this.getCofinancing = function() {
				return null;
			};
			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.getCurrentEndDate = function() {
				return null;	    
			};
			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() {
				var externalDmsIdentifierAutogenerated = Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.con.externalDmsIdentifier.autogenerated");
				if("true".equals(externalDmsIdentifierAutogenerated)){
					return wfItem.getIdentifier();
				}else {
					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);
		

...

Anchor
publicInvolvedAtLeastOneValidatorPublicEngagement-anchor
publicInvolvedAtLeastOneValidatorPublicEngagement-anchor
publicInvolvedAtLeastOneValidatorPublicEngagement
Questa validazione controlla che esista almeno un elemento publicInvolved, se la tipologia dell'iniziativa è "PEN.FORMAZIONE-COMUNICAZIONE" ("Giornate organizzate di formazione alla comunicazione - rivolta a PTA o docenti")
Dal punto di vista del modello dati si tratta degli elementi publicInvolved
Per maggiori dettagli cfr. modello dati dell'entità publicEngagement
Code Block
languagejs
linenumberstrue
collapsetrue
			
			var itemTypeIdentifier = object.getWfItemType().getIdentifier();
			
			if (Packages.org.apache.commons.lang.StringUtils.equals("PEN.FORMAZIONE-COMUNICAZIONE", itemTypeIdentifier)) {
				
				    var publicInvolvedSet = Packages.it.cilea.core.fragment.util.FragmentUtil.getCurrentFragmentSetByParentAndDiscriminator(object, "getWfItemElementSet", "it.cilea.wf.model.WfItemElement", "publicInvolved", wfService);
				if(publicInvolvedSet.isEmpty()){
					    if (publicInvolvedSet.isEmpty()) {
		        errors.reject("error.publicEngagement.publicInvolved.atLeast1");
		    } else {
		        var publicInvolvedSetIterator = publicInvolvedSet.iterator();
		        while (publicInvolvedSetIterator.hasNext()) {
		            var publicInvolved = publicInvolvedSetIterator.next();
		            var dictionary = publicInvolved.getWfDictionaryMap().get("dictionary");
		            var code = dictionary.getStringMap().get("code");
		            if (new String("publicInvolvedPublicEngagement.other-professors").valueOf() != new String(code).valueOf() && new String("publicInvolvedPublicEngagement.other-administratives").valueOf() != new String(code).valueOf() && new String("publicInvolvedPublicEngagement.other-unstructored-research-staff").valueOf() != new String(code).valueOf() && new String("publicInvolvedPublicEngagement.other-students-phd").valueOf() != new String(code).valueOf()) {
		                errors.reject("error.publicEngagement.publicInvolved.atLeast1consistent");
		            }
		        }
			    }	
			}
		

Anchor
addScientificAreaInvolvedFromNewOwnerValidatorPublicEngagement-anchor
addScientificAreaInvolvedFromNewOwnerValidatorPublicEngagement-anchor
addScientificAreaInvolvedFromNewOwnerValidatorPublicEngagement
Questa "validazione" va a popolare la sezione "Aree scientifiche coinvolte" nel tab "Classificazioni" ogni volta che viene aggiunto un nuovo owner.
Dal punto di vista del modello dati si tratta degli elementi scientificAreasInvolved
Per maggiori dettagli cfr. modello dati dell'entità publicEngagement
Code Block
languagejs
linenumberstrue
collapsetrue
		
			if(!errors.hasErrors()){
			
				//inutile, ma mi serve per ricordarmi il contesto
				var wfItemElement = object;							
				var wfItem = wfService.getWfItem(wfItemElement.getWfItemId()); 
				var fragmentInfo = Packages.it.cilea.core.fragment.util.FragmentUtil.getFragmentableInfo(wfItemElement);
				var newOwnerToAdd = wfItemElement.getPersonMap().get(fragmentInfo.getDiscriminator()+"Id");
				var person = gaService.getPerson(newOwnerToAdd.getPersonId());
				
				var positionLastSet = person.getPositionLastSet();
				var maxPriority = Packages.it.cilea.ga.util.GaUtil.getMaxPriority(positionLastSet, "research", "academicArea");
				positionLastSetIterator = positionLastSet.iterator();
				
				while (positionLastSetIterator.hasNext()){
					var position = positionLastSetIterator.next();					
					if (maxPriority == null || maxPriority.equals(position.getPriority())) {
					
						if ("research".equals(position.getDiscriminator()) 
							&& "academicArea".equals(position.getOrganizationUnit().getOrganizationUnitType().getDescription())) {
							
							//log.error("FOUND ONE!");
							//ora che ho trovato l'academicArea, vado a vedere se non è già presente
							
							var scientificAreasInvolvedElementSet = wfItem.getWfItemElementSet("scientificAreasInvolved");
							var scientificAreasInvolvedElementSetIterator = scientificAreasInvolvedElementSet.iterator();
							var alreadyAdded = false;
							
							while(scientificAreasInvolvedElementSetIterator.hasNext()){
							
								var scientificAreasInvolvedElement = scientificAreasInvolvedElementSetIterator.next();
								var orgUnit = scientificAreasInvolvedElement.getOrganizationUnitMap().get("ouId");
								if(orgUnit.getOrganizationUnitId() == position.getOrganizationUnitId()){
									alreadyAdded = true;
								}
							}
							
							//se alla fine non l'ho trovata, allora la inserisco
							if(!alreadyAdded){
								
								var saiElement = new Packages.it.cilea.wf.model.WfItemElement();
								saiElement.setDiscriminator("scientificAreasInvolved");
								saiElement.setWfItemId(wfItem.getId());
								saiElement.getOrganizationUnitMap().put("ouId", position.getOrganizationUnit());
								wfService.saveOrUpdate(saiElement);
								wfItem.getWfItemElementSet().add(saiElement);
								
								//UTILIZZARE QUESTO Packages.it.cilea.core.fragment.util.FragmentUtil.addNewFragment(ouIe, wfService);	
								
								break;
							}	
						}
					}
				}
			
			}
			
		

...