Skip to content

Commit

Permalink
Use extensions for entity types
Browse files Browse the repository at this point in the history
  • Loading branch information
javiertuya committed Jun 22, 2024
1 parent ebd37fb commit 6bbd23d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.Set;

import giis.tdrules.client.oa.transform.UpstreamAttribute;
import giis.tdrules.model.EntityTypes;
import giis.tdrules.openapi.model.Ddl;
import giis.tdrules.openapi.model.TdAttribute;
import giis.tdrules.openapi.model.TdEntity;
Expand Down Expand Up @@ -54,7 +53,7 @@ private void drawEntityRelations(TdEntity entity) {
for (TdAttribute attribute : giis.tdrules.model.ModelUtil.safe(entity.getAttributes())) {
if (attribute.isRid()) {
// relation to another entity is drawn differently if it is from an array
if (EntityTypes.DT_ARRAY.equals(entity.getEntitytype())) {
if (entity.isArray()) {
// When the rid entity is not the immediate adjacent upstream, arrays have an extended attribute
// to force drawing the visually correct relation that overrides the rid attribute
String rid = attribute.getRidEntity();
Expand All @@ -65,13 +64,13 @@ private void drawEntityRelations(TdEntity entity) {
} else {
drawReferenceToEntity(entity.getName(), attribute.getRidEntity());
}
} else if (EntityTypes.DT_TYPE.equals(attribute.getCompositetype()))
} else if (attribute.isType())
drawCompositeType(attribute.getDatatype(), entity.getName());
}
}

private void drawTypeDefinitions(TdEntity entity) {
if ((EntityTypes.DT_ARRAY.equals(entity.getEntitytype()) || EntityTypes.DT_TYPE.equals(entity.getEntitytype()))
if (entity.isArray() || entity.isType()
&& (!"".equals(entity.getSubtype())))
drawCompositeDefinition(entity.getName(), entity.getSubtype());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ private TdEntity extractPrimitiveArray(Schema<?> oaObject, TdAttribute attribute
newEntity.addAttributesItem(column);

// same as for object array, however here subtype is not set
newEntity.entitytype(EntityTypes.DT_ARRAY);
attribute.datatype(finalName).compositetype(EntityTypes.DT_ARRAY);
newEntity.setArray();
attribute.datatype(finalName).setArray();
st.addEntity(newEntity);
return newEntity;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.slf4j.LoggerFactory;

import giis.tdrules.client.oa.OaSchemaLogger;
import giis.tdrules.model.EntityTypes;
import giis.tdrules.model.OaExtensions;
import giis.tdrules.openapi.model.TdAttribute;
import giis.tdrules.openapi.model.TdCheck;
Expand Down Expand Up @@ -61,7 +60,7 @@ public SchemaTransformer transform() {
// and a recursive search on all upstreams can't be made because upstream entities are created later.
// This second step gets the rid of arrays that may be missing
for (TdEntity entity : tdSchema.getEntities())
if (EntityTypes.DT_ARRAY.equals(entity.getEntitytype()) && entity.getRids().isEmpty())
if (entity.isArray() && entity.getRids().isEmpty())
fillMissingRid(entity);
// Remove the extended upstream attribute, as it is not part of the current model
for (TdEntity entity : tdSchema.getEntities())
Expand Down Expand Up @@ -115,7 +114,7 @@ TdEntity getEntity(String name, Schema<?> oaSchema, TdEntity upstream) {
TdEntity createNewEntity(String name, TdEntity upstream) {
String upstreamName = upstream == null ? "null" : upstream.getName();
log.debug("Entity: {}, Upstream: {}", name, upstreamName);
TdEntity entity = new TdEntity().name(name).entitytype(EntityTypes.DT_TABLE);
TdEntity entity = new TdEntity().name(name).setObject();
upstreamAttr.setUpstream(entity, upstreamName);
return entity;
}
Expand Down

0 comments on commit 6bbd23d

Please sign in to comment.