Search in sources :

Example 1 with OryxIdMappings

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() + "]" );
            }
        }
    }
}
Also used : Bpmn2OryxPropertyManager(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.Bpmn2OryxPropertyManager) OryxIdMappings(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.OryxIdMappings) PropertyType(org.kie.workbench.common.stunner.core.definition.property.PropertyType) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with OryxIdMappings

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);
}
Also used : Bpmn2OryxPropertyManager(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.Bpmn2OryxPropertyManager) DoubleTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.DoubleTypeSerializer) ColorTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ColorTypeSerializer) StringTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.StringTypeSerializer) ArrayList(java.util.ArrayList) Bpmn2OryxIdMappings(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.Bpmn2OryxIdMappings) Bpmn2OryxPropertySerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.Bpmn2OryxPropertySerializer) Bpmn2OryxIdMappings(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.Bpmn2OryxIdMappings) OryxIdMappings(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.OryxIdMappings) AssignmentsTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.AssignmentsTypeSerializer) IntegerTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.IntegerTypeSerializer) VariablesTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.VariablesTypeSerializer) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) EnumTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.EnumTypeSerializer) BooleanTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.BooleanTypeSerializer) AssigneeTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.AssigneeTypeSerializer) Before(org.junit.Before)

Aggregations

OryxIdMappings (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.OryxIdMappings)2 Bpmn2OryxPropertyManager (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.Bpmn2OryxPropertyManager)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Before (org.junit.Before)1 Bpmn2OryxIdMappings (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.Bpmn2OryxIdMappings)1 AssigneeTypeSerializer (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.AssigneeTypeSerializer)1 AssignmentsTypeSerializer (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.AssignmentsTypeSerializer)1 BooleanTypeSerializer (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.BooleanTypeSerializer)1 Bpmn2OryxPropertySerializer (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.Bpmn2OryxPropertySerializer)1 ColorTypeSerializer (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ColorTypeSerializer)1 DoubleTypeSerializer (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.DoubleTypeSerializer)1 EnumTypeSerializer (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.EnumTypeSerializer)1 IntegerTypeSerializer (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.IntegerTypeSerializer)1 StringTypeSerializer (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.StringTypeSerializer)1 VariablesTypeSerializer (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.VariablesTypeSerializer)1 PropertyType (org.kie.workbench.common.stunner.core.definition.property.PropertyType)1 DefinitionUtils (org.kie.workbench.common.stunner.core.util.DefinitionUtils)1