Skip to content
Snippets Groups Projects
Trans.java 3.74 KiB
Newer Older
  • Learn to ignore specific revisions
  • package com.ic.er;
    
    import com.ic.er.common.RelatedObjType;
    
    汤伟's avatar
    汤伟 committed
    import com.ic.er.entity.*;
    
    
    import java.util.ArrayList;
    import java.util.List;
    
    public class Trans {
    
        protected static LayoutInfo TransformFromDB(LayoutInfoDO layoutInfoDO) {
            return new LayoutInfo(layoutInfoDO.getID(), layoutInfoDO.getRelatedObjID(), layoutInfoDO.getRelatedObjType(), layoutInfoDO.getLayoutX(), layoutInfoDO.getLayoutY(), layoutInfoDO.getHeight(), layoutInfoDO.getWidth());
        }
    
    
    汤伟's avatar
    汤伟 committed
        protected static List<LayoutInfo> TransLayoutInfoListFormDB(List<LayoutInfoDO> doList) {
    
            List<LayoutInfo> ret = new ArrayList<>();
            for (LayoutInfoDO LayoutInfoDO : doList) {
                ret.add(TransformFromDB(LayoutInfoDO));
            }
            return ret;
        }
    
        protected static Attribute TransformFromDB(AttributeDO attributeDO) {
            LayoutInfo layoutInfo = LayoutInfo.queryByObjIDAndObjType(attributeDO.getID(), RelatedObjType.ATTRIBUTE);
            return new Attribute(attributeDO.getID(), attributeDO.getEntityID(), attributeDO.getViewID(),
                    attributeDO.getName(), attributeDO.getDataType(), attributeDO.getIsPrimary(),
    
    汤伟's avatar
    汤伟 committed
                    layoutInfo, 0.0, 0.0, attributeDO.getGmtCreate(), attributeDO.getGmtModified());
    
    汤伟's avatar
    汤伟 committed
        protected static List<Attribute> TransAttributeListFromDB(List<AttributeDO> doList) {
            List<Attribute> ret = new ArrayList<>();
            for (AttributeDO attributeDO : doList) {
                ret.add(TransformFromDB(attributeDO));
    
    汤伟's avatar
    汤伟 committed
            return ret;
    
    汤伟's avatar
    汤伟 committed
        protected static Entity TransformFromDB(EntityDO entityDO) {
            List<Attribute> attributeList = Attribute.queryByAttribute(new AttributeDO(entityDO.getID(), entityDO.getViewID()));
            LayoutInfo layoutInfo = LayoutInfo.queryByObjIDAndObjType(entityDO.getID(), RelatedObjType.ENTITY);
    
    汤伟's avatar
    汤伟 committed
            return new Entity(entityDO.getID(), entityDO.getName(), entityDO.getViewID(), attributeList, layoutInfo, null, null,
    
    汤伟's avatar
    汤伟 committed
                    entityDO.getGmtCreate(), entityDO.getGmtModified());
        }
    
        protected static List<Entity> TransEntityListFormFromDB(List<EntityDO> doList) {
            List<Entity> ret = new ArrayList<>();
            for (EntityDO EntityDO : doList) {
                ret.add(TransformFromDB(EntityDO));
    
            }
            return ret;
        }
    
    
    汤伟's avatar
    汤伟 committed
    
    
        protected static Relationship TransformFromDB(RelationshipDO relationshipDO) {
            LayoutInfo layoutInfo = LayoutInfo.queryByObjIDAndObjType(relationshipDO.getID(), RelatedObjType.RELATIONSHIP);
            return new Relationship(relationshipDO.getID(), relationshipDO.getName(), relationshipDO.getViewID(),
                    Entity.queryByID(relationshipDO.getFirstEntityID()), Entity.queryByID(relationshipDO.getSecondEntityID()),
    
    汤伟's avatar
    汤伟 committed
                    relationshipDO.getFirstCardinality(), relationshipDO.getSecondCardinality(), layoutInfo,
    
                    relationshipDO.getGmtCreate(), relationshipDO.getGmtModified());
        }
    
    
    汤伟's avatar
    汤伟 committed
        protected static List<Relationship> TransRelationshipListFromDB(List<RelationshipDO> doList) {
    
            List<Relationship> ret = new ArrayList<>();
            for (RelationshipDO RelationshipDO : doList) {
                ret.add(TransformFromDB(RelationshipDO));
            }
            return ret;
        }
    
        protected static View TransformFromDB(ViewDO ViewDO) {
            List<Entity> entityList = Entity.queryByEntity(null);
            List<Relationship> relationshipList = Relationship.queryByRelationship(null);
            return new View(ViewDO.getID(), ViewDO.getName(), entityList, relationshipList, ViewDO.getCreator(),
                    ViewDO.getGmtCreate(), ViewDO.getGmtModified());
        }
    
    
    汤伟's avatar
    汤伟 committed
        protected static List<View> TransViewListFromDB(List<ViewDO> doList) {
    
            List<View> ret = new ArrayList<>();
            for (ViewDO ViewDO : doList) {
                ret.add(TransformFromDB(ViewDO));
            }
            return ret;
        }
    
    }