Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.scantask.better.dataValidation
- import com.scantask.tms.engine.ILanguageIds
- import com.scantask.tms.engine.PropertyDefinition
- import com.scantask.tms.engine.measurement.Measurement
- import com.scantask.tms.engine.process.PestMeasurement
- import com.scantask.tms.engine.process.StringActionProperty
- final def log = { output.println it }
- PestMeasurement pm = measurementService.getPestMeasurement(72159566306934787)
- Measurement m = measurementService.loadMeasurementDetails(session,pm)
- PropertyDefinition pd = propertyService.findPropertyByNameInProjectOrCommon(session.currentUserProjectRole,"batch_id")
- log "$pm.pest.name - $pd.name: ${m.getPropertyValue(pd, ILanguageIds.LANG_DEFAULT, false)}"
- StringActionProperty sap = getOrCreateStringProperty(pm,pd)
- log "$sap.definition.name: $sap.value"
- sap.setValue("TEST-10.10.10")
- processService.save(sap)
- StringActionProperty getOrCreateStringProperty(PestMeasurement pm, PropertyDefinition property) {
- String propertyName = property.getName()
- List<StringActionProperty> props = processService.findStringActionProperties(pm.getId(), propertyName)
- StringActionProperty result
- if (props.size() > 0) {
- result = props.get(0)
- } else {
- result = new StringActionProperty(processService.idGen().newId(), pm, property, null)
- }
- return result
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement