Search in sources :

Example 1 with PropertyAdapter

use of org.kie.workbench.common.stunner.core.definition.adapter.PropertyAdapter in project kie-wb-common by kiegroup.

the class ClientDefinitionManager method init.

@PostConstruct
@SuppressWarnings("unchecked")
public void init() {
    // DefinitionSet client adapters.
    Collection<SyncBeanDef<DefinitionSetAdapter>> beanDefSetAdapters = beanManager.lookupBeans(DefinitionSetAdapter.class);
    for (SyncBeanDef<DefinitionSetAdapter> defSet : beanDefSetAdapters) {
        DefinitionSetAdapter definitionSet = defSet.getInstance();
        addAdapter(definitionSet);
    }
    // DefinitionSetRule client adapters.
    Collection<SyncBeanDef<DefinitionSetRuleAdapter>> beanDefSetRuleAdapters = beanManager.lookupBeans(DefinitionSetRuleAdapter.class);
    for (SyncBeanDef<DefinitionSetRuleAdapter> defSet : beanDefSetRuleAdapters) {
        DefinitionSetRuleAdapter definitionSet = defSet.getInstance();
        addAdapter(definitionSet);
    }
    // Definition client adapters.
    Collection<SyncBeanDef<DefinitionAdapter>> beanDefAdapters = beanManager.lookupBeans(DefinitionAdapter.class);
    for (SyncBeanDef<DefinitionAdapter> defSet : beanDefAdapters) {
        DefinitionAdapter definitionSet = defSet.getInstance();
        addAdapter(definitionSet);
    }
    // PropertySet client adapters.
    Collection<SyncBeanDef<PropertySetAdapter>> beanPropSetAdapters = beanManager.lookupBeans(PropertySetAdapter.class);
    for (SyncBeanDef<PropertySetAdapter> defSet : beanPropSetAdapters) {
        PropertySetAdapter definitionSet = defSet.getInstance();
        addAdapter(definitionSet);
    }
    // Property client adapters.
    Collection<SyncBeanDef<PropertyAdapter>> beanPropAdapters = beanManager.lookupBeans(PropertyAdapter.class);
    for (SyncBeanDef<PropertyAdapter> defSet : beanPropAdapters) {
        PropertyAdapter definitionSet = defSet.getInstance();
        addAdapter(definitionSet);
    }
    // Morph adapters.
    Collection<SyncBeanDef<MorphAdapter>> beanMorphAdapters = beanManager.lookupBeans(MorphAdapter.class);
    for (SyncBeanDef<MorphAdapter> morphAdapter : beanMorphAdapters) {
        MorphAdapter instance = morphAdapter.getInstance();
        addAdapter(instance);
    }
    // Once adapters present, add the Definition Sets found on current context.
    Collection<SyncBeanDef<DefinitionSetProxy>> beanDefSets = beanManager.lookupBeans(DefinitionSetProxy.class);
    for (SyncBeanDef<DefinitionSetProxy> defSet : beanDefSets) {
        DefinitionSetProxy definitionSetProxy = defSet.getInstance();
        Object definitionSet = definitionSetProxy.getDefinitionSet();
        addDefinitionSet(definitionSet);
    }
}
Also used : DefinitionSetProxy(org.kie.workbench.common.stunner.core.definition.DefinitionSetProxy) PropertySetAdapter(org.kie.workbench.common.stunner.core.definition.adapter.PropertySetAdapter) SyncBeanDef(org.jboss.errai.ioc.client.container.SyncBeanDef) DefinitionAdapter(org.kie.workbench.common.stunner.core.definition.adapter.DefinitionAdapter) DefinitionSetAdapter(org.kie.workbench.common.stunner.core.definition.adapter.DefinitionSetAdapter) DefinitionSetRuleAdapter(org.kie.workbench.common.stunner.core.definition.adapter.DefinitionSetRuleAdapter) PropertyAdapter(org.kie.workbench.common.stunner.core.definition.adapter.PropertyAdapter) MorphAdapter(org.kie.workbench.common.stunner.core.definition.adapter.MorphAdapter) PostConstruct(javax.annotation.PostConstruct)

Example 2 with PropertyAdapter

use of org.kie.workbench.common.stunner.core.definition.adapter.PropertyAdapter in project kie-wb-common by kiegroup.

the class ElementParser method initialize.

@Override
@SuppressWarnings("unchecked")
public void initialize(final Context context) {
    this.context = context;
    Object definition = element.getContent().getDefinition();
    // Resource id field.
    super.addParser(new StringFieldParser("resourceId", element.getUUID()));
    // Properties array.
    Object def = element.getContent().getDefinition();
    Set<?> properties = context.getDefinitionManager().adapters().forDefinition().getProperties(def);
    ObjectParser propertiesParser = new ObjectParser("properties");
    super.addParser(propertiesParser);
    if (null != properties && !properties.isEmpty()) {
        for (Object property : properties) {
            PropertyAdapter propertyAdapter = context.getDefinitionManager().adapters().registry().getPropertyAdapter(property.getClass());
            PropertyType propertyType = propertyAdapter.getType(property);
            String oryxPropId = context.getOryxManager().getMappingsManager().getOryxPropertyId(def.getClass(), property.getClass());
            Object value = propertyAdapter.getValue(property);
            String valueStr = value != null ? context.getOryxManager().getPropertyManager().serialize(property, propertyType, value) : "";
            propertiesParser.addParser(new StringFieldParser(oryxPropId, valueStr));
        }
    }
    // Custom extended prpoerties, if any.
    parseExtendedProperties(propertiesParser);
    // Stencil id field.
    String defId = context.getOryxManager().getMappingsManager().getOryxDefinitionId(definition);
    super.addParser(new ObjectParser("stencil").addParser(new StringFieldParser("id", defId)));
    // Bounds.
    Bounds.Bound ul = element.getContent().getBounds().getUpperLeft();
    Bounds.Bound lr = element.getContent().getBounds().getLowerRight();
    parseBounds(ul, lr);
}
Also used : ObjectParser(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.parser.common.ObjectParser) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) PropertyAdapter(org.kie.workbench.common.stunner.core.definition.adapter.PropertyAdapter) PropertyType(org.kie.workbench.common.stunner.core.definition.property.PropertyType) StringFieldParser(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.parser.common.StringFieldParser)

Aggregations

PropertyAdapter (org.kie.workbench.common.stunner.core.definition.adapter.PropertyAdapter)2 PostConstruct (javax.annotation.PostConstruct)1 SyncBeanDef (org.jboss.errai.ioc.client.container.SyncBeanDef)1 ObjectParser (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.parser.common.ObjectParser)1 StringFieldParser (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.parser.common.StringFieldParser)1 DefinitionSetProxy (org.kie.workbench.common.stunner.core.definition.DefinitionSetProxy)1 DefinitionAdapter (org.kie.workbench.common.stunner.core.definition.adapter.DefinitionAdapter)1 DefinitionSetAdapter (org.kie.workbench.common.stunner.core.definition.adapter.DefinitionSetAdapter)1 DefinitionSetRuleAdapter (org.kie.workbench.common.stunner.core.definition.adapter.DefinitionSetRuleAdapter)1 MorphAdapter (org.kie.workbench.common.stunner.core.definition.adapter.MorphAdapter)1 PropertySetAdapter (org.kie.workbench.common.stunner.core.definition.adapter.PropertySetAdapter)1 PropertyType (org.kie.workbench.common.stunner.core.definition.property.PropertyType)1 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)1