Search in sources :

Example 1 with DrawingObjectRelationshipGroups

use of com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.StoredDisplay.DrawingObjectRelationshipGroups in project cubrid-manager by CUBRID.

the class ExportSchemaTask method setDrawData.

private void setDrawData(Model model) {
    int ENTITY_PER_ROW = 5;
    model.setSubjectAreaGroups(new SubjectAreaGroups());
    SubjectArea subjectArea = new SubjectArea();
    model.getSubjectAreaGroups().getSubjectAreaList().add(subjectArea);
    String name = "<Main Subject Area>";
    subjectArea.setId(getUUID());
    subjectArea.setName(name);
    subjectArea.setSubjectAreaProps(new SubjectAreaProps());
    subjectArea.getSubjectAreaProps().setName(new SubjectAreaProps.Name());
    subjectArea.getSubjectAreaProps().getName().setValue(name);
    subjectArea.setStoredDisplayGroups(new StoredDisplayGroups());
    StoredDisplay storedDisplay = new StoredDisplay();
    storedDisplay.setId(getUUID());
    storedDisplay.setName("Display1");
    subjectArea.getStoredDisplayGroups().getStoredDisplay().add(storedDisplay);
    DrawingObjectEntityGroups groups = new DrawingObjectEntityGroups();
    storedDisplay.setDrawingObjectEntityGroups(groups);
    Map<String, String> locationMap = new HashMap<String, String>();
    int idx = 1;
    int row = 1;
    for (Entry<String, Entity> entry : entityMap.entrySet()) {
        if (idx > ENTITY_PER_ROW) {
            idx = 1;
            row++;
        }
        String id = entry.getValue().getId();
        ReferencedEntity entity = new ReferencedEntity();
        entity.setValue(id);
        subjectArea.getSubjectAreaProps().getReferencedEntities().add(entity);
        DrawingObjectEntity dEntity = new DrawingObjectEntity();
        dEntity.setId(getUUID());
        dEntity.setName(entry.getValue().getName());
        dEntity.setDrawingObjectEntityProps(new DrawingObjectEntityProps());
        dEntity.getDrawingObjectEntityProps().setDoEntityHeightAutoResizeable(new DOEntityHeightAutoResizeable());
        dEntity.getDrawingObjectEntityProps().getDoEntityHeightAutoResizeable().setValue(Boolean.TRUE.toString());
        dEntity.getDrawingObjectEntityProps().setDoEntityWidthAutoResizeable(new DOEntityWidthAutoResizeable());
        dEntity.getDrawingObjectEntityProps().getDoEntityWidthAutoResizeable().setValue(Boolean.TRUE.toString());
        dEntity.getDrawingObjectEntityProps().setDoReferenceObject(new DOReferenceObject());
        dEntity.getDrawingObjectEntityProps().getDoReferenceObject().setValue(id);
        dEntity.getDrawingObjectEntityProps().setDolocation(new DOLocation());
        String location = row * 500 + "," + idx * 500;
        dEntity.getDrawingObjectEntityProps().getDolocation().setValue("(" + location + ",0,0)");
        groups.getDrawingObjectEntity().add(dEntity);
        locationMap.put(id, location);
        idx++;
    }
    DrawingObjectRelationshipGroups shipGroups = new DrawingObjectRelationshipGroups();
    storedDisplay.setDrawingObjectRelationshipGroups(shipGroups);
    for (Entry<String, Relationship> entry : relationshipMap.entrySet()) {
        String relId = entry.getKey();
        Relationship relEntity = entry.getValue();
        ReferencedEntity entity = new ReferencedEntity();
        entity.setValue(relId);
        subjectArea.getSubjectAreaProps().getReferencedEntities().add(entity);
        DrawingObjectRelation relation = new DrawingObjectRelation();
        relation.setId(getUUID());
        relation.setName(relEntity.getName());
        shipGroups.getDrawingObjectRelationshipEntity().add(relation);
        relation.setDrawingObjectRelationshipProps(new DrawingObjectRelationshipProps());
        relation.getDrawingObjectRelationshipProps().setDoReferenceObject(new DOReferenceObject());
        relation.getDrawingObjectRelationshipProps().getDoReferenceObject().setValue(relId);
        String pId = relEntity.getRelationshipProps().getRelationshipParentEntity().getValue();
        String cId = relEntity.getRelationshipProps().getRelationshipChildEntity().getValue();
        String pl = locationMap.get(pId);
        String cl = locationMap.get(cId);
        int[] pco = parseLocation(pl);
        int[] cco = parseLocation(cl);
        int ydis = pco[0] - cco[0];
        int xdis = pco[1] - cco[1];
        boolean x = (Math.abs(xdis) > Math.abs(ydis)) ? false : true;
        //			int[] p1 = pco;
        //			int[] p2 = (x) ? new int[] { pco[0], pco[1] - (xdis / 2) }
        //					: new int[] { pco[0] - (ydis / 2), pco[1] };
        //			int[] p3 = (x) ? new int[] { cco[0], cco[1] + (xdis / 2) }
        //					: new int[] { cco[0] + (ydis / 2), cco[1] };
        //			int[] p4 = cco;
        int[] p1 = new int[] { pco[1] + 10, pco[0] + 10 };
        int[] p4 = new int[] { cco[1] + 10, cco[0] + 10 };
        int[] p2 = (x) ? new int[] { p1[0] - (xdis / 2), p1[1] } : new int[] { p1[0], p1[1] - (ydis / 2) };
        int[] p3 = (x) ? new int[] { p4[0] + (xdis / 2), p4[1] } : new int[] { p4[0], p4[1] + (ydis / 2) };
        DORelationshipPath path = new DORelationshipPath();
        path.setValue(arrayToString(p4));
        path = new DORelationshipPath();
        path.setValue(arrayToString(p3));
        relation.getDrawingObjectRelationshipProps().getDoRelationshipPathList().add(path);
        path = new DORelationshipPath();
        path.setValue(arrayToString(p2));
        relation.getDrawingObjectRelationshipProps().getDoRelationshipPathList().add(path);
        path = new DORelationshipPath();
        path.setValue(arrayToString(p1));
        relation.getDrawingObjectRelationshipProps().setDoUserControledPath(new DOUserControledPath());
        relation.getDrawingObjectRelationshipProps().getDoUserControledPath().setValue("true");
    }
}
Also used : SubjectAreaGroups(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.Model.SubjectAreaGroups) RelationshipParentEntity(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.RelationshipPropsList.RelationshipParentEntity) RelationshipChildEntity(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.RelationshipPropsList.RelationshipChildEntity) ReferencedEntity(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.SubjectAreaProps.ReferencedEntity) DrawingObjectEntity(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectEntity) Entity(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.Entity) DrawingObjectRelationshipGroups(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.StoredDisplay.DrawingObjectRelationshipGroups) HashMap(java.util.HashMap) DOUserControledPath(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectRelationshipProps.DOUserControledPath) DOEntityWidthAutoResizeable(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectEntityProps.DOEntityWidthAutoResizeable) DORelationshipPath(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectRelationshipProps.DORelationshipPath) SubjectAreaProps(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.SubjectAreaProps) DrawingObjectRelationshipProps(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectRelationshipProps) SubjectArea(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.SubjectArea) StoredDisplay(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.StoredDisplay) DOEntityHeightAutoResizeable(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectEntityProps.DOEntityHeightAutoResizeable) DrawingObjectEntityProps(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectEntityProps) DOReferenceObject(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DOReferenceObject) ReferencedEntity(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.SubjectAreaProps.ReferencedEntity) DrawingObjectEntityGroups(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.StoredDisplay.DrawingObjectEntityGroups) StoredDisplayGroups(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.SubjectArea.StoredDisplayGroups) DOLocation(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectEntityProps.DOLocation) Constraint(com.cubrid.common.core.common.model.Constraint) DrawingObjectRelation(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectRelation) DrawingObjectEntity(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectEntity) ParentRelationship(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.AttributePropsList.ParentRelationship) Relationship(com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.Relationship)

Aggregations

Constraint (com.cubrid.common.core.common.model.Constraint)1 ParentRelationship (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.AttributePropsList.ParentRelationship)1 DOReferenceObject (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DOReferenceObject)1 DrawingObjectEntity (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectEntity)1 DrawingObjectEntityProps (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectEntityProps)1 DOEntityHeightAutoResizeable (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectEntityProps.DOEntityHeightAutoResizeable)1 DOEntityWidthAutoResizeable (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectEntityProps.DOEntityWidthAutoResizeable)1 DOLocation (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectEntityProps.DOLocation)1 DrawingObjectRelation (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectRelation)1 DrawingObjectRelationshipProps (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectRelationshipProps)1 DORelationshipPath (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectRelationshipProps.DORelationshipPath)1 DOUserControledPath (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectRelationshipProps.DOUserControledPath)1 Entity (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.Entity)1 SubjectAreaGroups (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.Model.SubjectAreaGroups)1 Relationship (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.Relationship)1 RelationshipChildEntity (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.RelationshipPropsList.RelationshipChildEntity)1 RelationshipParentEntity (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.RelationshipPropsList.RelationshipParentEntity)1 StoredDisplay (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.StoredDisplay)1 DrawingObjectEntityGroups (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.StoredDisplay.DrawingObjectEntityGroups)1 DrawingObjectRelationshipGroups (com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.StoredDisplay.DrawingObjectRelationshipGroups)1