Advertisement
LemuelCushing

processService.save(bap)

Apr 23rd, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.31 KB | None | 0 0
  1. package com.scantask.better.dataValidation
  2.  
  3. import com.scantask.tms.engine.ILanguageIds
  4. import com.scantask.tms.engine.PropertyDefinition
  5. import com.scantask.tms.engine.measurement.Measurement
  6. import com.scantask.tms.engine.process.PestMeasurement
  7. import com.scantask.tms.engine.process.StringActionProperty
  8.  
  9. final def log = { output.println it }
  10.  
  11. PestMeasurement pm = measurementService.getPestMeasurement(72159566306934787)
  12. Measurement m = measurementService.loadMeasurementDetails(session,pm)
  13. PropertyDefinition pd = propertyService.findPropertyByNameInProjectOrCommon(session.currentUserProjectRole,"batch_id")
  14. log "$pm.pest.name - $pd.name: ${m.getPropertyValue(pd, ILanguageIds.LANG_DEFAULT, false)}"
  15. StringActionProperty sap = getOrCreateStringProperty(pm,pd)
  16. log "$sap.definition.name: $sap.value"
  17. sap.setValue("TEST-10.10.10")
  18. processService.save(sap)
  19.  
  20. StringActionProperty getOrCreateStringProperty(PestMeasurement pm, PropertyDefinition property) {
  21.   String propertyName = property.getName()
  22.   List<StringActionProperty> props = processService.findStringActionProperties(pm.getId(), propertyName)
  23.   StringActionProperty result
  24.   if (props.size() > 0) {
  25.     result = props.get(0)
  26.   } else {
  27.     result = new StringActionProperty(processService.idGen().newId(), pm, property, null)
  28.   }
  29.   return result
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement