use of org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.OryxIdMappings in project kie-wb-common by kiegroup.
the class AbstractObjectBuilder method setProperties.
@SuppressWarnings("unchecked")
protected void setProperties(final BuilderContext context, final BPMNDefinition definition) {
assert definition != null;
Bpmn2OryxPropertyManager propertyManager = context.getOryxManager().getPropertyManager();
OryxIdMappings idMappings = context.getOryxManager().getMappingsManager();
Set<?> defProperties = context.getDefinitionManager().adapters().forDefinition().getProperties(definition);
for (Map.Entry<String, String> entry : properties.entrySet()) {
final String oryxId = entry.getKey();
if (!idMappings.isSkipProperty(definition.getClass(), oryxId)) {
final String pValue = entry.getValue();
final String pId = idMappings.getPropertyId(definition, oryxId);
boolean found = false;
if (null != pId) {
final Object property = GraphUtils.getProperty(context.getDefinitionManager(), defProperties, pId);
if (null != property) {
try {
PropertyType propertyType = context.getDefinitionManager().adapters().forProperty().getType(property);
Object value = propertyManager.parse(property, propertyType, pValue);
context.getDefinitionManager().adapters().forProperty().setValue(property, value);
found = true;
} catch (Exception e) {
LOG.error("Cannot parse value [" + pValue + "] for property [" + pId + "]", e);
}
}
}
if (!found && null != pId) {
// LOG.warn( "Property [" + pId + "] not found for definition [" + definition.getClass().getName() + "]" );
}
}
}
}
use of org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.OryxIdMappings in project kie-wb-common by kiegroup.
the class CaseManagementOryxManagerTest method setup.
@Before
public void setup() {
OryxIdMappings oryxIdMappings = new Bpmn2OryxIdMappings(definitionManager, WorkItemDefinitionEmptyRegistry::new);
DefinitionUtils definitionUtils = new DefinitionUtils(definitionManager, factoryManager);
List<Bpmn2OryxPropertySerializer<?>> oryxPropertySerializers = new ArrayList<>();
oryxPropertySerializers.add(new AssigneeTypeSerializer());
oryxPropertySerializers.add(new AssignmentsTypeSerializer());
oryxPropertySerializers.add(new BooleanTypeSerializer());
oryxPropertySerializers.add(new ColorTypeSerializer());
oryxPropertySerializers.add(new DoubleTypeSerializer());
oryxPropertySerializers.add(new EnumTypeSerializer(definitionUtils));
oryxPropertySerializers.add(new IntegerTypeSerializer());
oryxPropertySerializers.add(new StringTypeSerializer());
oryxPropertySerializers.add(new VariablesTypeSerializer());
Bpmn2OryxPropertyManager oryxPropertyManager = new Bpmn2OryxPropertyManager(oryxPropertySerializers);
this.oryxManager = new CaseManagementOryxManager(oryxIdMappings, oryxPropertyManager);
}
Aggregations