Search in sources :

Example 6 with PropertyType

use of org.kie.workbench.common.stunner.core.definition.property.PropertyType 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)

Example 7 with PropertyType

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

the class ClientBindablePropertyAdapterTest method testDefaultTypes.

@Test
public void testDefaultTypes() {
    types.put(Foo.class, new StringType());
    types.put(Bar.class, new BooleanType());
    final PropertyType fooType = clientBindablePropertyAdapter.getType(new Foo());
    final PropertyType barType = clientBindablePropertyAdapter.getType(new Bar());
    assertEquals(StringType.class, fooType.getClass());
    assertEquals(BooleanType.class, barType.getClass());
}
Also used : StringType(org.kie.workbench.common.stunner.core.definition.property.type.StringType) BooleanType(org.kie.workbench.common.stunner.core.definition.property.type.BooleanType) PropertyType(org.kie.workbench.common.stunner.core.definition.property.PropertyType) Test(org.junit.Test)

Example 8 with PropertyType

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

the class BackendPropertyAdapterTest method testGetPropertyType.

@Test
public void testGetPropertyType() {
    final PropertyType type = tested.getType(instance);
    assertEquals(StringType.class, type.getClass());
}
Also used : PropertyType(org.kie.workbench.common.stunner.core.definition.property.PropertyType) Test(org.junit.Test)

Example 9 with PropertyType

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

the class StunnerClientLogger method logProperty.

public static void logProperty(final DefinitionManager definitionManager, final Object prop, final Set<Object> propertiesVisited) {
    final PropertyAdapter<Object, ?> adapter = definitionManager.adapters().registry().getPropertyAdapter(prop.getClass());
    final String id = adapter.getId(prop);
    final String caption = adapter.getCaption(prop);
    final String description = adapter.getDescription(prop);
    final PropertyType type = adapter.getType(prop);
    final Object value = adapter.getValue(prop);
    GWT.log("    -------------------------------------------------");
    GWT.log("    ID = " + id);
    GWT.log("    CAPTION = " + caption);
    GWT.log("    DESC = " + description);
    GWT.log("    TYPE = " + type);
    GWT.log("    VALUE = " + value);
    GWT.log("    -------------------------------------------------");
    propertiesVisited.add(prop);
}
Also used : PropertyType(org.kie.workbench.common.stunner.core.definition.property.PropertyType)

Aggregations

PropertyType (org.kie.workbench.common.stunner.core.definition.property.PropertyType)9 Test (org.junit.Test)3 Field (java.lang.reflect.Field)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 OryxIdMappings (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.OryxIdMappings)1 Bpmn2OryxPropertyManager (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.Bpmn2OryxPropertyManager)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 FooProperty2TestBean (org.kie.workbench.common.stunner.core.backend.definition.adapter.FooProperty2TestBean)1 PropertyAdapter (org.kie.workbench.common.stunner.core.definition.adapter.PropertyAdapter)1 HasInheritance (org.kie.workbench.common.stunner.core.definition.adapter.binding.HasInheritance)1 Type (org.kie.workbench.common.stunner.core.definition.annotation.property.Type)1 MorphProperty (org.kie.workbench.common.stunner.core.definition.morph.MorphProperty)1 BooleanType (org.kie.workbench.common.stunner.core.definition.property.type.BooleanType)1 StringType (org.kie.workbench.common.stunner.core.definition.property.type.StringType)1 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)1 DefinitionUtils (org.kie.workbench.common.stunner.core.util.DefinitionUtils)1