Search in sources :

Example 1 with Category

use of com.alibaba.json.test.entity.case2.Category in project fastjson by alibaba.

the class CircularReferenceTest method test_0.

public void test_0() throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ObjectOutputStream objectOut = new ObjectOutputStream(out);
    Category p = new Category();
    p.setId(1);
    p.setName("root");
    {
        Category child = new Category();
        child.setId(2);
        child.setName("child");
        p.getChildren().add(child);
        child.setParent(p);
    }
    objectOut.writeObject(p);
}
Also used : Category(com.alibaba.json.test.entity.case2.Category) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream)

Example 2 with Category

use of com.alibaba.json.test.entity.case2.Category in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method revisitGroups.

public void revisitGroups(Definitions def) {
    List<RootElement> rootElements = def.getRootElements();
    Category defaultCat = Bpmn2Factory.eINSTANCE.createCategory();
    defaultCat.setName("default");
    for (RootElement root : rootElements) {
        if (root instanceof Process) {
            Process process = (Process) root;
            List<Artifact> processArtifacts = process.getArtifacts();
            if (processArtifacts != null) {
                for (Artifact ar : processArtifacts) {
                    if (ar instanceof Group) {
                        Group group = (Group) ar;
                        Iterator<FeatureMap.Entry> iter = group.getAnyAttribute().iterator();
                        while (iter.hasNext()) {
                            FeatureMap.Entry entry = iter.next();
                            if (entry.getEStructuralFeature().getName().equals("categoryval")) {
                                CategoryValue catval = Bpmn2Factory.eINSTANCE.createCategoryValue();
                                catval.setValue((String) entry.getValue());
                                defaultCat.getCategoryValue().add(catval);
                                group.setCategoryValueRef(catval);
                            }
                        }
                    }
                }
            }
        }
    }
    // only add category if it includes at least one categoryvalue
    if (defaultCat.getCategoryValue() != null && defaultCat.getCategoryValue().size() > 0) {
        rootElements.add(defaultCat);
    }
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Group(org.eclipse.bpmn2.Group) Entry(java.util.Map.Entry) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) RootElement(org.eclipse.bpmn2.RootElement) Category(org.eclipse.bpmn2.Category) CategoryValue(org.eclipse.bpmn2.CategoryValue) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process) Artifact(org.eclipse.bpmn2.Artifact)

Aggregations

Category (com.alibaba.json.test.entity.case2.Category)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Entry (java.util.Map.Entry)1 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)1 Artifact (org.eclipse.bpmn2.Artifact)1 Category (org.eclipse.bpmn2.Category)1 CategoryValue (org.eclipse.bpmn2.CategoryValue)1 Group (org.eclipse.bpmn2.Group)1 Process (org.eclipse.bpmn2.Process)1 RootElement (org.eclipse.bpmn2.RootElement)1 SubProcess (org.eclipse.bpmn2.SubProcess)1 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)1 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)1