Versions Compared

Key

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

...

Anchor
isEquipmentEsfriClassificationRequired-anchor
isEquipmentEsfriClassificationRequired-anchor
isEquipmentEsfriClassificationRequired
Questa è un'applicability rule che viene valutata prima di eseguire altre validazioni.
Se ritorna true allora vengono eseguite le validazioni a cui è agganciata altrimenti no.
Questa regola ritorna true se la configurazione ap.eqp.esfriClassification.required è settata a true.
Code Block
languagejs
linenumberstrue
collapsetrue
			(
				"true"==StringUtils.trimToEmpty(ConfigurationUtil.getConfigValue("ap.eqp.esfriClassification.required"))
			)
		

Anchor
isEquipmentInventoryGoodEnabled-anchor
isEquipmentInventoryGoodEnabled-anchor
isEquipmentInventoryGoodEnabled
Questa è un'applicability rule che viene valutata prima di eseguire altre validazioni.
Se ritorna true allora vengono eseguite le validazioni a cui è agganciata altrimenti no.
Questa regola ritorna true se la configurazione ap.eqp.ugovpj.inventory.enabled è settata a true.
Questa configurazione abilita l'import dei Beni di Inventario da UGOV.
Code Block
languagejs
linenumberstrue
collapsetrue

			(
				"true"==StringUtils.trimToEmpty(ConfigurationUtil.getConfigValue("ap.eqp.ugovpj.inventory.enabled"))
			)
		

Anchor
urlPublicCalendarEquipmentValidator-anchor
urlPublicCalendarEquipmentValidator-anchor
urlPublicCalendarEquipmentValidator
Questa validazione verifica che sia presente il metadato urlPublicCalendar se il metadato publicCalendar è valorizzato a true.
Il messaggio di errore è contenuto nell'etichetta error.equipment.urlPublicCalendar.required
Per maggiori dettagli cfr. il modello modello dati dell'entità in questione.
Code Block
languagejs
linenumberstrue
collapsetrue
			if (Boolean.TRUE.equals(object.getBooleanMap().get("publicCalendar"))){
				if (StringUtils.isBlank(object.getStringMap().get("urlPublicCalendar"))){
					errors.rejectValue("stringMap[urlPublicCalendar]","error.equipment.urlPublicCalendar.required");
				}
			}
		

...

Anchor
tariffEquipmentValidator-anchor
tariffEquipmentValidator-anchor
tariffEquipmentValidator
Questa validazione verifica che sia presente il metadato tariff se è presente il dizionario di valore applications.tariff (RM - Attrezzature - Applicazioni) nella sezione Applicazioni.
Il messaggio di errore è contenuto nell'etichetta error.equipment.tariff.required
Per maggiori dettagli cfr. il modello modello dati dell'entità in questione.
Code Block
languagejs
linenumberstrue
collapsetrue
			var applicationsSet = FragmentUtil.getCurrentFragmentSetByParentAndDiscriminator(object, "it.cilea.wf.model.WfItemElement","applications", wfService);			
			var applicationsSetIterator=applicationsSet.iterator();
			while(applicationsSetIterator.hasNext()){
				var applicationsElement=applicationsSetIterator.next();
				var dictionary=applicationsElement.getWfDictionaryMap().get("application");
				if (dictionary!=null && "applications.tariff"==dictionary.getStringMap().get("code")){					
					if (StringUtils.isBlank(object.getStringMap().get("tariff"))){
						errors.rejectValue("stringMap[tariff]","error.equipment.tariff.required");
					}
				}
			}		
		

Anchor
externalOrganizationOwnerEquipmentValidatorpurchaseValueInventoryGoodValidator-anchorexternalOrganizationOwnerEquipmentValidator
purchaseValueInventoryGoodValidator-anchor
externalOrganizationOwnerEquipmentValidator purchaseValueInventoryGoodValidator
Questa validazione verifica che sia presente il metadato externalOrganizationOwner , se il metadato internalOwnership è valorizzato a falsecalcolo automatico è attivato, il valore di acquisto totale sia la somma dei singoli valori di acquisto dei beni di inventario che sono stati importati da UGOV.
Il messaggio di errore è contenuto nell'etichetta error.equipment.externalOrganizationOwnerautocalculatedInventoryGoodsTotalValue.requiredinconsistent
Per maggiori dettagli cfr. il modello modello dati dell'entità in questione.
Code Block
languagejs
linenumberstrue
collapsetrue
		
	if (Boolean.FALSE.equals(		// controllo solo nel caso in cui il calcolo automatico è attivato
			if(object.getBooleanMap().get("internalOwnershipautocalculatedInventoryGoodsTotalValue")) == true){			
		
			if (object.getOrganizationUnitMap().get("externalOrganizationOwner")==null){	var inventoryGoodSet = FragmentUtil.getCurrentFragmentSetByParentAndDiscriminator(object, "it.cilea.wf.model.WfItemElement","inventoryGood", wfService);			
				var inventoryGoodSetIterator = inventoryGoodSet.iterator();
					errors.rejectValue("organizationUnitMap[externalOrganizationOwner]","error.equipment.externalOrganizationOwner.required");
				var calculatedPurchaseValue = BigDecimal.ZERO;
				
				while(inventoryGoodSetIterator.hasNext()){
				}
			}
				var inventoryGoodElement = inventoryGoodSetIterator.next();
					
					var inventoryGoodRmItem = inventoryGoodElement.getRmItemMap().get("inventoryGoodId");
					
					var conventionalValue = inventoryGoodRmItem.getNumberMap().get("conventionalValue");
					
					// se conventionalValue non è presente, cioè null, aggiungo zero
					
					calculatedPurchaseValue = calculatedPurchaseValue.add(conventionalValue != null ? conventionalValue : BigDecimal.ZERO);
				}
				
				if(!calculatedPurchaseValue.equals(object.getNumberMap().get("purchaseValue"))){
					errors.rejectAndLocate("error.equipment.autocalculatedInventoryGoodsTotalValue.inconsistent", "purchaseValue");
				}
				
			}
		

Anchor
externalOrganizationOwnerEquipmentValidator-anchor
externalOrganizationOwnerEquipmentValidator-anchor
externalOrganizationOwnerEquipmentValidator
Questa validazione verifica che sia presente il metadato externalOrganizationOwner se il metadato internalOwnership è valorizzato a false.
Il messaggio di errore è contenuto nell'etichetta error.equipment.externalOrganizationOwner.required
Per maggiori dettagli cfr. il modello modello dati dell'entità in questione.
Code Block
languagejs
linenumberstrue
collapsetrue

			if (Boolean.FALSE.equals(object.getBooleanMap().get("internalOwnership"))){
				if (object.getOrganizationUnitMap().get("externalOrganizationOwner")==null){
					errors.rejectValue("organizationUnitMap[externalOrganizationOwner]","error.equipment.externalOrganizationOwner.required");
				}
			}
		

Anchor
Anchor
wfStartLogicEquipment-anchorwfStartLogicEquipment-anchor
wfStartLogicEquipment-anchor
wfStartLogicEquipment
Questa logica viene eseguita in fase di creazione di una nuova attrezzatura.
Effettua il setup dei seguenti attributi con i valori tra parentesi

...

Anchor
grantorFinancingQuotaRequiredValidatorProject-anchor
grantorFinancingQuotaRequiredValidatorProject-anchor
grantorFinancingQuotaRequiredValidatorProject
Questa validazione controlla viene attivata dalla configuration ap.prj.grantor.financingQuota.enabled.
Verfica che vengano inserite le quote di finanziamento associate a ogni ente e che la loro somma sia corretta.
Dal punto di vista del modello dati si tratta degli elementi di tipo grantor.
Per maggiori dettagli cfr. excel modello dati dell'entità Progetto
Code Block
languagejs
linenumberstrue
collapsetrue
	
			if(ConfigurationUtil.getConfigValue("ap.prj.grantor.financingQuota.enabled") != null){
				if(ConfigurationUtil.getConfigValue("ap.prj.grantor.financingQuota.enabled").equalsIgnoreCase("true")){
					var grantorSet = FragmentUtil.getCurrentFragmentSetByParentAndDiscriminator(object, "getWfItemElementSet", "it.cilea.wf.model.WfItemElement", "grantor", wfService);
					var grantorSetIterator = grantorSet.iterator();
					var sum = BigDecimal.ZERO;
					while (grantorSetIterator.hasNext()){
						var element = grantorSetIterator.next();		
						sum = sum.add(element.getNumberMap().get("financingQuota") != null ? element.getNumberMap().get("financingQuota") : BigDecimal.ZERO);
					}
					if(!sum.equals(object.getNumberMap().get("internalContribution"))){
						errors.reject("error.project.grantor.quota.inconsistent");		
					}
			
				}
			}
		

Anchor
topicValidatorProject-anchor
topicValidatorProject-anchor
topicValidatorProject
Questa validazione controlla che esista almeno una area tematica nel tab "Dati generali".
Dal punto di vista del modello dati si tratta degli elementi di tipo topic
Per maggiori dettagli cfr. excel modello dati dell'entità Progetto
Code Block
languagejs
linenumberstrue
collapsetrue
					
			var topicSet = Packages.it.cilea.core.fragment.util.FragmentUtil.getCurrentFragmentSetByParentAndDiscriminator(object, "getWfItemElementSet", "it.cilea.wf.model.WfItemElement", "topic", wfService);
			if (topicSet.size()<1)
				errors.reject("error.project.topic.atLeast1");		
		

...

Anchor
wfStartLogicDepartmentAndOwnerDependentIdentifier-anchor
wfStartLogicDepartmentAndOwnerDependentIdentifier-anchor
wfStartLogicDepartmentAndOwnerDependentIdentifier
Questa logica effettua la costruzione dell'identificativo dell'oggetto seguendo le seguenti regole:
<CODICE_CSA_DEL_DIPARTIMENTO><VALORE_PERSONALIZZABILE>-<CODICE_TIPO_PROGETTO>-<ULTIME_DUE_CIFRE_ANNO>-<PRIME_5_LETTERE_COGNOME>_<PROGRESSIVO>

  • VALORE_PERSONALIZZABILE:
    • CODICE_CSA_DEL_DIPARTIMENTO: codice del dipartimento
    da recuperare
    • recuperato nel metadato orgUnit.stringMap[idCsa]
    • CODICE_IDAB_DEL_DIPARTIMENTO: codice del dipartimento recuperato nel metadato orgUnit.stringMap[idAb]
    • ID_DEL_DIPARTIMENTO: identificativo univoco del dipartimento recuperato nel metadato orgUnit.id
    • CODICE_ACRONYM_DEL_DIPARTIMENTO: codice del dipartimento recuperato nel metadato orgUnit.stringMap[acronym]
  • CODICE_TIPO_PROGETTO: come da campo CODE da tassonomia scaricata dalla sezione "Alberatura tipologie RM/AP"
  • ULTIME_DUE_CIFRE_ANNO: anno in due cifre estratto dalla data di inizio
  • PRIME_5_LETTERE_COGNOME: prime cinque lettere del cognome del responsabile
  • PROGRESSIVO: numero progressivo
  • del responsabile
  • PROGRESSIVO: numero progressivo

...

  • csa verrà utilizzato il metadato orgUnit.stringMap[idCsa]
  • ugov verrà utilizzato il metadato orgUnit.stringMap[idAb]
  • iris verrà utilizzato il metadato orgUnit.id del dipartimento
  • acronym verrà utilizzato il metadato orgUnit.stringMap[acronym]

...

Code Block
languagejs
linenumberstrue
collapsetrue
			var departmentIdConf = Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.prj.identifier.logic.department-id");
			departmentIdConf=(!departmentIdConf)?"csa":departmentIdConf;
			var departmentId = null;
			var ownerWfElementSet = FragmentUtil.getCurrentFragmentSetByParentAndDiscriminator(wfItem, "it.cilea.wf.model.WfItemElement", "owner", wfService);
			var person = Packages.it.cilea.wf.util.WfUtil.getOwnerForIdentifier(ownerWfElementSet, wfService);
			var idCsa = null;
			if (person != null) {
				var checkDate = WfUtil.getCheckDate(wfItem, wfService);
				var checkDatepositionContext = WfUtil.getCheckDategetPositionContext(wfItem, wfService);
				var ownerPositionSet = WfUtil.getPositionSet(person, checkDate, positionContext, "department", gaService);
				var department = GaUtil.getPriorityOrganizationUnit(ownerPositionSet, positionContext, "department");
				if (department == null) {
					throw "To = WfUtil.getPositionContext(wfItem, wfService)use wfStartLogicDepartmentAndOwnerDependentIdentifier you MUST specify department for that person ";
				}
			} else {
				throw "To use wfStartLogicDepartmentAndOwnerDependentIdentifier you MUST specify department";
			}		
			switch(String(departmentIdConf)){
				case "csa":
					departmentId = department.getStringMap().get("idCsa");
					if (departmentId == null) {
						throw "To use wfStartLogicDepartmentAndOwnerDependentIdentifier you MUST specify code department [idCsa]";
					}
				break;
			    var ownerPositionSet = WfUtil.getPositionSet(person, checkDate, positionContext, "department", gaService);
			    var department = GaUtil.getPriorityOrganizationUnit(ownerPositionSet, positionContext, "department	
				case "ugov": 
					departmentId = department.getStringMap().get("idAb");
			    		if (departmentdepartmentId == null) {
				  		throw "To use wfStartLogicDepartmentAndOwnerDependentIdentifier you MUST specify department for that person "code department [idAb]";
					}
				break;
				
				case "iris": 
					departmentId = String(department.getId());
				break;
				} else {case "acronym": 
					idCsadepartmentId = department.getStringMap().get("idCsaacronym");
				}
			} else	if (departmentId == null) {
						throw "To use wfStartLogicDepartmentAndOwnerDependentIdentifier you MUST specify code department [acronym]";
					}
				break;
				default:
					departmentId = department.getStringMap().get("idCsa");
					if (idCsadepartmentId == null) {
			    			throw "To use wfStartLogicDepartmentAndOwnerDependentIdentifier you MUST specify code department [idCsa]";
					}
			}
			var lastName = person.getLastName().replaceAll("\s", "");
			lastName = lastName.replaceAll("'", "");
			lastName = (lastName.length() >= 4) ? lastName.substring(0, 5) : lastName.substring(0, lastName.length());
			lastName = lastName.toUpperCase();
			
			var dateDiscriminators = Packages.it.cilea.core.configuration.util.ConfigurationUtil.getConfigValue("ap.identifier.logic.date.discriminators");
			var discriminator = "proposalStartDate";
			if (dateDiscriminators != null) {
			    var discriminatorArray = dateDiscriminators.split(",");
			    for (i in discriminatorArray) {
			        if (wfItem.getDateMap().get(discriminatorArray[i]) != null) {
			            discriminator = discriminatorArray[i];
			            break;
			        }
			    }
			}
			
			var startDate = wfItem.getDateMap().get(discriminator);
			var year = startDate.get(Packages.java.util.Calendar.YEAR);
			var yearString = new Packages.java.lang.Integer(year).toString();
			yearString = yearString.substring(2);
			var sourceItemTypeCode = wfService.getWfItemType(wfItem.getWfItemTypeId()).getCode();
			
			
			var stringBuilder = new Packages.java.lang.StringBuilder(idCsadepartmentId);
			stringBuilder.append(sourceItemTypeCode);
			stringBuilder.append(yearString);
			stringBuilder.append(lastName);
			
			var identifier = stringBuilder.toString();
			
			if (wfItem.getIdentifier() == null || !(wfItem.getIdentifier().substring(0, wfItem.getIdentifier().lastIndexOf("_"))).equals(identifier)) {
				var paramMap = new Packages.java.util.HashMap();
				paramMap.put("identifier", identifier);
				paramMap.put("excludeIdentifier", identifier+"M");
				var count = searchBuilderTemplate.getSingleObject("getMaxItemCountForGivenIdentifier", paramMap);
				var countString = "";
				if (count < 9)
					countString += "0";			
				countString += (count.intValue()+1);
				identifier += "_" + countString;
			    wfItem.setIdentifier(identifier);
			}
		

...

Anchor
wfActionLogicSaveNewIdentifier-anchor
wfActionLogicSaveNewIdentifier-anchor
wfActionLogicSaveNewIdentifier
Questa logica serve per il ricalcolo dell'identificativo della scheda in caso di cambio ti tipologiadi tipologia.
Il ricalcolo viene effettuato SOLO se la variabile di configurazione ap.<wfItemType>.identifier.recalculation.enabled è settata a true o non è valorizzata.
E' necessario inserirla come save logic per tutti gli stati nei flussi progetti e contratti che precedono la sincronizzazione con Ugov PJ.
Code Block
languagejs
linenumberstrue
collapsetruetrue

			var sourceItemType = wfService.getWfItemType(wfItem.getWfItemTypeId()).getRootWfItemType();
			var identifierRecalculationConfig = Packages.it.cilea.wf.util.WfUtil.getParametricConfiguration("ap.<wfItemType>.identifier.recalculation.enabled", sourceItemType);
			var identifierRecalculationEnabled=("true"==identifierRecalculationConfig||!identifierRecalculationConfig)?true:false;
			if(identifierRecalculationEnabled){
				var myNEWWfItemType = object.getWfItemTypeId();
				var myOLDWfItemType = object.getIntegerMap().get("wfItemTypeIdPreviousValue");
				if (myOLDWfItemType == null)
					throw "To use changeItemTypeValidator you MUST specify wfItemTypeIdPreviousValue hidden value";
					
				if(myNEWWfItemType != myOLDWfItemType){
					//var wfStateId = object.getWfStateId();
					var startLogic = Packages.it.cilea.wf.WfConstant.START_LOGIC_MAP.get("wfStartLogicIdentifier");
					startLogic.start(object, request);
					//object.setWfStateId(wfStateId);
					object.getIntegerMap().put("wfItemTypeIdPreviousValue", object.getWfItemTypeId());
				}
			}	
		

Anchor
wfActionLogicSaveNewYear-anchor
wfActionLogicSaveNewYear-anchor
wfActionLogicSaveNewYear
Questa logica serve per l'aggiornamento dell'anno della scheda in caso di cambio di data.
L'aggiornamento viene effettuato se viene recuperata una data e se l'anno della data è diverso dal valore presente nel campo anno (year).
E' necessario inserirla come save logic per tutti gli stati, in tutti i flussi tranne quelli di Public Engagement, perché in quei flussi l'anno viene gestito con una semantica differente.
La data viene recuperata dalla configurazione ap.<wfItemType>.owner.position.date, se la configurazione viene valorizzarta con CURRENT o CURRENT_OR_LAST, verrà effettuato un recupero della data presente nel metadato startDate, se non presente verrà recuperata la data presente nel metadato proposalStartDate , se non presente verrà recuperata la data presente nel metadato applicationDate.
Code Block
languagejs
linenumberstrue
collapsetrue

			var myDate=WfUtil.getCheckDateNotCurrent(wfItem, wfService);
			if(myDate != null){
				var calendar = Calendar.getInstance();
				calendar.setTime(myDate);
				if(wfItem.getYear() != new Packages.java.lang.Integer(calendar.get(Calendar.YEAR))){
					wfItem.setYear(new Packages.java.lang.Integer(calendar.get(Calendar.YEAR)));
				}
			}
		

Anchor
wfActionLogicTransitionLogger-anchor
wfActionLogicTransitionLogger-anchor
wfActionLogicTransitionLogger
Questa logica serve per la gestione del logging delle transizioni di stato nel metadato transitionLog.
Se il metadato NON è presente nel modello dati, non sarà visibile nell'interfaccia web.
Questa logica viene inserita come enter action logic per tutti gli stati nei flussi per i quali si vuole abilitare il logging delle transizioni di stato.
Se necessario, è possibile richiedere all'utente che sta effettuando la transizione di stato di inserire un messaggio che giustifichi la transizione di stato: questo messaggio verrà conservato nel log.
La gestione del messaggio opzionale è gestito con il metadato transitionComment che deve essere configurato come metadato @Required. per la validazione di enter.
Code Block
languagejs
linenumberstrue
collapsetrue
		
			var justExternallyCreated=request.getParameter("justExternallyCreated");
			if (Packages.java.lang.Boolean.TRUE.equals(wfItem.isMaster()) && (!justExternallyCreated || (justExternallyCreated=="true" && Packages.java.lang.Boolean.TRUE.equals(wfItem.isMostValidated())))){
				var formatter=new Packages.java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
				var currentDate="["+formatter.format(new Packages.java.util.Date())+"]";
				var user=Packages.it.cilea.ga.authorization.context.GaAuthorizationUserHolder.getUser();			
				
				var message="";
				if(Packages.org.apache.commons.lang.StringUtils.isNotBlank(wfItem.getClobMap().get("transitionsLog"))){
					message+="_______________________________________________________________"+ "

";
				} else {				
					wfItem.getClobMap().put("transitionsLog", "");
				}
				if (user!=null){
					message+=currentDate+" <strong>"+user.getLastName()+" "+user.getFirstName()+"</strong> ("+user.getUsername()+")"+"
";
				} else {
					message+=currentDate+" <strong>system</strong>
";
				}
				
				message+="Transizione verso "<strong>"+wfItem.getWfState().getDisplayValue()+"</strong>" ("+wfItem.getWfState().getDescription()+")";
				if (Packages.org.apache.commons.lang.StringUtils.isNotBlank(wfItem.getStringMap().get("transitionComment"))){			
					message+="
<strong>Motivazione transizione di stato</strong>
";
					message+="<i>"+wfItem.getStringMap().get("transitionComment")+"</i>";				
				}
				message+="
";			
				wfItem.getClobMap().put("transitionsLog", wfItem.getClobMap().get("transitionsLog")+message);
				wfItem.getStringMap().put("transitionComment", null);
			}			
		

...