From 81ffa069db6d48fcb7aeec2ed698e210ffa5cf7e Mon Sep 17 00:00:00 2001 From: Ivan Gomes Date: Sun, 8 Dec 2019 22:39:12 -0800 Subject: [PATCH 01/14] ST5AS-25 Implement versioning concepts #wip --- app/Module.java | 3 + app/config/impl/JPAMetamodelProvider.java | 4 +- app/controllers/CommitController.java | 61 +++++++ app/controllers/ElementController.java | 2 +- app/controllers/ProjectController.java | 2 +- app/controllers/RelationshipController.java | 2 +- app/dao/CommitDao.java | 26 +++ app/dao/ElementDao.java | 6 +- app/dao/ProjectDao.java | 6 +- app/dao/RelationshipDao.java | 8 +- app/dao/impl/jpa/JpaCommitDao.java | 124 +++++++++++++ app/dao/impl/jpa/JpaDao.java | 19 +- app/dao/impl/jpa/JpaElementDao.java | 2 +- app/dao/impl/jpa/JpaProjectDao.java | 2 +- app/dao/impl/jpa/JpaRelationshipDao.java | 2 +- app/jackson/MofObjectDeserializer.java | 2 +- app/jackson/MofObjectSerializer.java | 4 +- .../impl/HibernateObjectMapperFactory.java | 4 +- .../UseExistingOrGenerateUUIDGenerator.java | 1 - .../omg/sysml/extension/impl/ProjectImpl.java | 9 +- .../sysml/extension/impl/package-info.java | 8 +- app/org/omg/sysml/metamodel/MofObject.java | 2 +- .../metamodel/impl/AcceptActionUsageImpl.java | 1 + .../sysml/metamodel/impl/ActionUsageImpl.java | 1 + .../sysml/metamodel/impl/ActivityImpl.java | 1 + .../sysml/metamodel/impl/AnnotationImpl.java | 1 + .../metamodel/impl/AssociationBlockImpl.java | 1 + .../sysml/metamodel/impl/AssociationImpl.java | 1 + .../sysml/metamodel/impl/BehaviorImpl.java | 1 + .../metamodel/impl/BindingConnectorImpl.java | 1 + .../metamodel/impl/BlockExpressionImpl.java | 1 + .../omg/sysml/metamodel/impl/BlockImpl.java | 1 + .../metamodel/impl/BlockPropertyImpl.java | 1 + .../omg/sysml/metamodel/impl/ClassImpl.java | 1 + .../sysml/metamodel/impl/ClassifierImpl.java | 1 + .../omg/sysml/metamodel/impl/CommentImpl.java | 1 + .../metamodel/impl/ConditionalImportImpl.java | 2 + .../impl/ConditionalSuccessionImpl.java | 1 + .../impl/ConjugatedEndPortMembershipImpl.java | 3 + .../impl/ConjugatedPortMembershipImpl.java | 3 + .../metamodel/impl/ConnectionUsageImpl.java | 1 + .../sysml/metamodel/impl/ConnectorImpl.java | 1 + .../sysml/metamodel/impl/ControlNodeImpl.java | 1 + .../sysml/metamodel/impl/DataTypeImpl.java | 1 + .../metamodel/impl/DecisionNodeImpl.java | 1 + .../sysml/metamodel/impl/DefinitionImpl.java | 1 + .../omg/sysml/metamodel/impl/ElementImpl.java | 1 + .../impl/EndFeatureMembershipImpl.java | 3 + .../metamodel/impl/EndPortMembershipImpl.java | 3 + .../sysml/metamodel/impl/ExpressionImpl.java | 1 + .../omg/sysml/metamodel/impl/FeatureImpl.java | 1 + .../metamodel/impl/FeatureMembershipImpl.java | 3 + .../impl/FeatureReferenceExpressionImpl.java | 1 + .../metamodel/impl/FeatureTypingImpl.java | 1 + .../metamodel/impl/FeatureValueImpl.java | 3 + .../sysml/metamodel/impl/ForkNodeImpl.java | 1 + .../sysml/metamodel/impl/FunctionImpl.java | 1 + .../metamodel/impl/GeneralizationImpl.java | 1 + .../metamodel/impl/ImportConditionImpl.java | 1 + .../omg/sysml/metamodel/impl/ImportImpl.java | 2 + .../impl/InstanceCreationExpressionImpl.java | 1 + .../sysml/metamodel/impl/InteractionImpl.java | 1 + .../impl/InterfaceDefinitionImpl.java | 1 + .../metamodel/impl/InterfaceUsageImpl.java | 1 + .../impl/InvocationExpressionImpl.java | 1 + .../sysml/metamodel/impl/ItemFeatureImpl.java | 1 + .../sysml/metamodel/impl/ItemFlowEndImpl.java | 1 + .../metamodel/impl/ItemFlowFeatureImpl.java | 1 + .../sysml/metamodel/impl/ItemFlowImpl.java | 1 + .../sysml/metamodel/impl/JoinNodeImpl.java | 1 + .../metamodel/impl/LiteralBooleanImpl.java | 1 + .../metamodel/impl/LiteralExpressionImpl.java | 1 + .../metamodel/impl/LiteralIntegerImpl.java | 1 + .../sysml/metamodel/impl/LiteralRealImpl.java | 1 + .../metamodel/impl/LiteralStringImpl.java | 1 + .../metamodel/impl/LiteralUnboundedImpl.java | 1 + .../sysml/metamodel/impl/MembershipImpl.java | 2 + .../sysml/metamodel/impl/MergeNodeImpl.java | 1 + .../sysml/metamodel/impl/MofObjectImpl.java | 32 +++- .../metamodel/impl/MultiplicityImpl.java | 1 + .../metamodel/impl/MultiplicityRangeImpl.java | 1 + .../metamodel/impl/NullExpressionImpl.java | 1 + .../impl/OperatorExpressionImpl.java | 1 + .../sysml/metamodel/impl/OwnershipImpl.java | 1 + .../omg/sysml/metamodel/impl/PackageImpl.java | 1 + .../sysml/metamodel/impl/ParameterImpl.java | 1 + .../impl/ParameterMembershipImpl.java | 3 + .../metamodel/impl/PartPropertyImpl.java | 1 + .../impl/PerformActionUsageImpl.java | 1 + .../metamodel/impl/PortDefinitionImpl.java | 1 + .../metamodel/impl/PortMembershipImpl.java | 3 + .../sysml/metamodel/impl/PortUsageImpl.java | 1 + .../sysml/metamodel/impl/PredicateImpl.java | 1 + .../sysml/metamodel/impl/PropertyImpl.java | 1 + .../impl/QueryPathExpressionImpl.java | 1 + .../impl/QueryPathStepExpressionImpl.java | 1 + .../impl/QueryQualifierExpressionImpl.java | 1 + .../metamodel/impl/RedefinitionImpl.java | 1 + .../metamodel/impl/ReferencePropertyImpl.java | 1 + .../metamodel/impl/RelationshipImpl.java | 1 + .../impl/ReturnParameterMembershipImpl.java | 3 + .../metamodel/impl/SendActionUsageImpl.java | 1 + .../SequenceConstructionExpressionImpl.java | 1 + .../sysml/metamodel/impl/SourceEndImpl.java | 1 + .../omg/sysml/metamodel/impl/StepImpl.java | 1 + .../sysml/metamodel/impl/SubsettingImpl.java | 1 + .../sysml/metamodel/impl/SuccessionImpl.java | 1 + .../impl/SuccessionItemFlowImpl.java | 1 + .../metamodel/impl/SuperclassingImpl.java | 1 + .../sysml/metamodel/impl/TargetEndImpl.java | 1 + .../impl/TransferActionUsageImpl.java | 1 + .../omg/sysml/metamodel/impl/TypeImpl.java | 1 + .../omg/sysml/metamodel/impl/UsageImpl.java | 1 + .../metamodel/impl/ValuePropertyImpl.java | 1 + .../sysml/metamodel/impl/ValueTypeImpl.java | 1 + app/org/omg/sysml/versioning/Commit.java | 16 ++ .../omg/sysml/versioning/ElementIdentity.java | 4 + .../omg/sysml/versioning/ElementRecord.java | 9 + app/org/omg/sysml/versioning/Record.java | 7 + .../omg/sysml/versioning/impl/CommitImpl.java | 59 +++++++ .../versioning/impl/ElementIdentityImpl.java | 14 ++ .../versioning/impl/ElementRecordImpl.java | 50 ++++++ .../omg/sysml/versioning/impl/RecordImpl.java | 24 +++ app/services/CommitService.java | 41 +++++ app/services/ProjectService.java | 2 +- conf/META-INF/persistence.xml | 2 +- conf/routes | 27 +-- .../sysml/metamodel/impl/MofObjectImpl_.java | 2 + .../sysml/versioning/impl/CommitImpl_.java | 23 +++ .../omg/sysml/versioning/impl/Commit_.java | 23 +++ .../versioning/impl/ElementIdentityImpl_.java | 13 ++ .../versioning/impl/ElementIdentity_.java | 13 ++ .../versioning/impl/ElementRecordImpl_.java | 16 ++ .../sysml/versioning/impl/ElementRecord_.java | 16 ++ .../sysml/versioning/impl/RecordImpl_.java | 17 ++ .../omg/sysml/versioning/impl/Record_.java | 17 ++ public/swagger/openapi.yaml | 163 ++++++++++++++++++ 137 files changed, 940 insertions(+), 62 deletions(-) create mode 100644 app/controllers/CommitController.java create mode 100644 app/dao/CommitDao.java create mode 100644 app/dao/impl/jpa/JpaCommitDao.java create mode 100644 app/org/omg/sysml/versioning/Commit.java create mode 100644 app/org/omg/sysml/versioning/ElementIdentity.java create mode 100644 app/org/omg/sysml/versioning/ElementRecord.java create mode 100644 app/org/omg/sysml/versioning/Record.java create mode 100644 app/org/omg/sysml/versioning/impl/CommitImpl.java create mode 100644 app/org/omg/sysml/versioning/impl/ElementIdentityImpl.java create mode 100644 app/org/omg/sysml/versioning/impl/ElementRecordImpl.java create mode 100644 app/org/omg/sysml/versioning/impl/RecordImpl.java create mode 100644 app/services/CommitService.java create mode 100644 generated/org/omg/sysml/versioning/impl/CommitImpl_.java create mode 100644 generated/org/omg/sysml/versioning/impl/Commit_.java create mode 100644 generated/org/omg/sysml/versioning/impl/ElementIdentityImpl_.java create mode 100644 generated/org/omg/sysml/versioning/impl/ElementIdentity_.java create mode 100644 generated/org/omg/sysml/versioning/impl/ElementRecordImpl_.java create mode 100644 generated/org/omg/sysml/versioning/impl/ElementRecord_.java create mode 100644 generated/org/omg/sysml/versioning/impl/RecordImpl_.java create mode 100644 generated/org/omg/sysml/versioning/impl/Record_.java diff --git a/app/Module.java b/app/Module.java index a4e04ee7..9f35de31 100644 --- a/app/Module.java +++ b/app/Module.java @@ -1,9 +1,11 @@ import com.google.inject.AbstractModule; import config.MetamodelProvider; import config.impl.JPAMetamodelProvider; +import dao.CommitDao; import dao.ElementDao; import dao.ProjectDao; import dao.RelationshipDao; +import dao.impl.jpa.JpaCommitDao; import dao.impl.jpa.JpaElementDao; import dao.impl.jpa.JpaProjectDao; import dao.impl.jpa.JpaRelationshipDao; @@ -22,5 +24,6 @@ protected void configure() { bind(ElementDao.class).to(JpaElementDao.class); bind(ProjectDao.class).to(JpaProjectDao.class); bind(RelationshipDao.class).to(JpaRelationshipDao.class); + bind(CommitDao.class).to(JpaCommitDao.class); } } \ No newline at end of file diff --git a/app/config/impl/JPAMetamodelProvider.java b/app/config/impl/JPAMetamodelProvider.java index acf03c50..4511192b 100644 --- a/app/config/impl/JPAMetamodelProvider.java +++ b/app/config/impl/JPAMetamodelProvider.java @@ -13,11 +13,11 @@ public class JPAMetamodelProvider implements MetamodelProvider { static { INTERFACES.add(MofObject.class); - for (String pakkage : new String[]{"org.omg.sysml.metamodel", "org.omg.sysml.extension"}) { + for (String pakkage : new String[]{"org.omg.sysml.metamodel", "org.omg.sysml.extension", "org.omg.sysml.versioning"}) { INTERFACES.addAll(new Reflections(pakkage).getSubTypesOf(MofObject.class)); } IMPLEMENTATION_CLASSES.add(MofObjectImpl.class); - for (String pakkage : new String[]{"org.omg.sysml.metamodel.impl", "org.omg.sysml.extension.impl"}) { + for (String pakkage : new String[]{"org.omg.sysml.metamodel.impl", "org.omg.sysml.extension.impl", "org.omg.sysml.versioning.impl"}) { IMPLEMENTATION_CLASSES.addAll(new Reflections(pakkage).getSubTypesOf(MofObjectImpl.class)); } } diff --git a/app/controllers/CommitController.java b/app/controllers/CommitController.java new file mode 100644 index 00000000..9639d48c --- /dev/null +++ b/app/controllers/CommitController.java @@ -0,0 +1,61 @@ +package controllers; + +import com.fasterxml.jackson.databind.JsonNode; +import config.MetamodelProvider; +import jackson.JacksonHelper; +import org.omg.sysml.versioning.Commit; +import play.libs.Json; +import play.mvc.Controller; +import play.mvc.Http; +import play.mvc.Result; +import play.mvc.Results; +import services.CommitService; + +import javax.inject.Inject; +import java.time.ZonedDateTime; +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +public class CommitController extends Controller { + @Inject + private MetamodelProvider metamodelProvider; + + @Inject + private CommitService commitService; + + public Result byId(String id) { + UUID uuid = UUID.fromString(id); + Optional commit = commitService.getById(uuid); + return commit.map(e -> ok(Json.toJson(e))).orElseGet(Results::notFound); + } + + public Result all() { + List commits = commitService.getAll(); + return ok(JacksonHelper.collectionValueToTree(List.class, metamodelProvider.getImplementationClass(Commit.class), commits)); + } + + public Result create(Http.Request request) { + JsonNode requestBodyJson = request.body().asJson(); + Commit requestedObject = Json.fromJson(requestBodyJson, metamodelProvider.getImplementationClass(Commit.class)); + if (requestedObject.getId() != null || requestedObject.getTimestamp() != null) { + return Results.badRequest(); + } + requestedObject.setTimestamp(ZonedDateTime.now()); + Optional responseCommit = commitService.create(requestedObject); + return responseCommit.map(e -> created(Json.toJson(e))).orElseGet(Results::internalServerError); + } + + public Result byProject(String projectId) { + UUID projectUuid = UUID.fromString(projectId); + List commits = commitService.getByProjectId(projectUuid); + return ok(JacksonHelper.collectionValueToTree(List.class, metamodelProvider.getImplementationClass(Commit.class), commits)); + } + + public Result byProjectAndId(String commitId, String projectId) { + UUID commitUuid = UUID.fromString(commitId); + UUID projectUuid = UUID.fromString(projectId); + Optional commit = commitService.getByProjectIdAndId(projectUuid, commitUuid); + return commit.map(e -> ok(Json.toJson(e))).orElseGet(Results::notFound); + } +} diff --git a/app/controllers/ElementController.java b/app/controllers/ElementController.java index db60fb1e..1b034e16 100644 --- a/app/controllers/ElementController.java +++ b/app/controllers/ElementController.java @@ -47,7 +47,7 @@ public Result create(Http.Request request) { return Results.badRequest(); } Optional responseElement = elementService.create(((Element) requestedObject)); - return responseElement.map(e -> created(Json.toJson(e))).orElseGet(Results::badRequest); + return responseElement.map(e -> created(Json.toJson(e))).orElseGet(Results::internalServerError); } public Result byProject(String projectId) { diff --git a/app/controllers/ProjectController.java b/app/controllers/ProjectController.java index 4339a92d..7a0d0643 100644 --- a/app/controllers/ProjectController.java +++ b/app/controllers/ProjectController.java @@ -43,6 +43,6 @@ public Result create(Http.Request request) { JsonNode requestBodyJson = request.body().asJson(); Project requestProject = Json.fromJson(requestBodyJson, metamodelProvider.getImplementationClass(Project.class)); Optional responseProject = projectService.create(requestProject); - return responseProject.map(e -> created(Json.toJson(e))).orElseGet(Results::badRequest); + return responseProject.map(e -> created(Json.toJson(e))).orElseGet(Results::internalServerError); } } diff --git a/app/controllers/RelationshipController.java b/app/controllers/RelationshipController.java index c8f2fb33..40447429 100644 --- a/app/controllers/RelationshipController.java +++ b/app/controllers/RelationshipController.java @@ -47,7 +47,7 @@ public Result create(Http.Request request) { return Results.badRequest(); } Optional responseRelationship = relationshipService.create((Relationship) requestedObject); - return responseRelationship.map(e -> created(Json.toJson(e))).orElseGet(Results::badRequest); + return responseRelationship.map(e -> created(Json.toJson(e))).orElseGet(Results::internalServerError); } public Result byRelatedElementId(String id) { diff --git a/app/dao/CommitDao.java b/app/dao/CommitDao.java new file mode 100644 index 00000000..c1c593eb --- /dev/null +++ b/app/dao/CommitDao.java @@ -0,0 +1,26 @@ +package dao; + +import org.omg.sysml.extension.Project; +import org.omg.sysml.versioning.Commit; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +public interface CommitDao extends Dao { + Optional persist(Commit commit); + + Optional update(Commit commit); + + Optional findById(UUID id); + + List findAll(); + + void delete(Commit commit); + + void deleteAll(); + + List findAllByProject(Project project); + + Optional findByProjectAndId(Project project, UUID id); +} diff --git a/app/dao/ElementDao.java b/app/dao/ElementDao.java index 2a84c069..f78dd88e 100644 --- a/app/dao/ElementDao.java +++ b/app/dao/ElementDao.java @@ -8,15 +8,15 @@ import java.util.UUID; public interface ElementDao extends Dao { - Optional persist(Element Element); + Optional persist(Element element); - Optional update(Element entity); + Optional update(Element element); Optional findById(UUID id); List findAll(); - void delete(Element Element); + void delete(Element element); void deleteAll(); diff --git a/app/dao/ProjectDao.java b/app/dao/ProjectDao.java index cb0c92a3..ec91372b 100644 --- a/app/dao/ProjectDao.java +++ b/app/dao/ProjectDao.java @@ -7,15 +7,15 @@ import java.util.UUID; public interface ProjectDao extends Dao { - Optional persist(Project Project); + Optional persist(Project project); - Optional update(Project entity); + Optional update(Project project); Optional findById(UUID id); List findAll(); - void delete(Project Project); + void delete(Project project); void deleteAll(); } diff --git a/app/dao/RelationshipDao.java b/app/dao/RelationshipDao.java index 0bec8e2f..98fcad7b 100644 --- a/app/dao/RelationshipDao.java +++ b/app/dao/RelationshipDao.java @@ -1,7 +1,7 @@ package dao; -import org.omg.sysml.metamodel.Element; import org.omg.sysml.extension.Project; +import org.omg.sysml.metamodel.Element; import org.omg.sysml.metamodel.Relationship; import java.util.List; @@ -9,15 +9,15 @@ import java.util.UUID; public interface RelationshipDao extends Dao { - Optional persist(Relationship Relationship); + Optional persist(Relationship relationship); - Optional update(Relationship entity); + Optional update(Relationship relationship); Optional findById(UUID id); List findAll(); - void delete(Relationship Relationship); + void delete(Relationship relationship); void deleteAll(); diff --git a/app/dao/impl/jpa/JpaCommitDao.java b/app/dao/impl/jpa/JpaCommitDao.java new file mode 100644 index 00000000..0ead30c5 --- /dev/null +++ b/app/dao/impl/jpa/JpaCommitDao.java @@ -0,0 +1,124 @@ +package dao.impl.jpa; + +import dao.CommitDao; +import jpa.manager.JPAManager; +import org.omg.sysml.extension.Project; +import org.omg.sysml.metamodel.impl.MofObjectImpl; +import org.omg.sysml.versioning.Commit; +import org.omg.sysml.versioning.impl.CommitImpl; +import org.omg.sysml.versioning.impl.CommitImpl_; +import org.omg.sysml.versioning.impl.ElementIdentityImpl; +import org.omg.sysml.versioning.impl.ElementRecordImpl; + +import javax.inject.Inject; +import javax.inject.Singleton; +import javax.persistence.NoResultException; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaDelete; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Singleton +public class JpaCommitDao extends JpaDao implements CommitDao { + @Inject + private JPAManager jpa; + + @Override + protected JPAManager getJpaManager() { + return jpa; + } + + @Override + public Optional persist(Commit commit) { + commit.getChanges().stream().filter(record -> record.getIdentity() == null).filter(record -> record instanceof ElementRecordImpl).map(record -> (ElementRecordImpl) record) + .forEach(record -> { + ElementIdentityImpl identity = new ElementIdentityImpl(); + identity.setId(UUID.randomUUID()); + record.setIdentity(identity); + }); + commit.getChanges().stream().filter(record -> record.getData() != null).filter(record -> record.getData() instanceof MofObjectImpl) + .forEach(record -> { + ((MofObjectImpl) record.getData()).setId(UUID.randomUUID()); + ((MofObjectImpl) record.getData()).setIdentifier(record.getIdentity().getId()); + }); + if (!(commit instanceof CommitImpl)) { + throw new IllegalStateException(); + } + return jpa.transact(em -> { + ((CommitImpl) commit).setChanges(commit.getChanges().stream().map(em::merge).collect(Collectors.toSet())); + return super.persist(commit, em); + }); + } + + @Override + public Optional findById(UUID id) { + return jpa.transact(em -> { + CriteriaBuilder builder = em.getCriteriaBuilder(); + CriteriaQuery query = builder.createQuery(CommitImpl.class); + Root root = query.from(CommitImpl.class); + query.select(root) + .where(builder.equal(root.get(CommitImpl_.id), id)); + try { + return Optional.of(em.createQuery(query).getSingleResult()); + } catch (NoResultException e) { + return Optional.empty(); + } + }); + } + + @Override + public List findAll() { + return jpa.transact(em -> { + CriteriaBuilder builder = em.getCriteriaBuilder(); + CriteriaQuery query = builder.createQuery(CommitImpl.class); + query.select(query.from(CommitImpl.class)); + return em.createQuery(query).getResultStream().collect(Collectors.toList()); + }); + } + + @Override + public void deleteAll() { + jpa.transact(em -> { + CriteriaBuilder builder = em.getCriteriaBuilder(); + CriteriaDelete query = builder.createCriteriaDelete(CommitImpl.class); + query.from(CommitImpl.class); + return ((Stream) em.createQuery(query).getResultStream()).collect(Collectors.toList()); + }); + } + + @Override + public List findAllByProject(Project project) { + return jpa.transact(em -> { + CriteriaBuilder builder = em.getCriteriaBuilder(); + CriteriaQuery query = builder.createQuery(CommitImpl.class); + Root root = query.from(CommitImpl.class); + query.select(root) + .where(builder.equal(root.get(CommitImpl_.containingProject), project)); + return em.createQuery(query).getResultStream().collect(Collectors.toList()); + }); + } + + @Override + public Optional findByProjectAndId(Project project, UUID id) { + return jpa.transact(em -> { + CriteriaBuilder builder = em.getCriteriaBuilder(); + CriteriaQuery query = builder.createQuery(CommitImpl.class); + Root root = query.from(CommitImpl.class); + query.select(root) + .where(builder.and( + builder.equal(root.get(CommitImpl_.containingProject), project), + builder.equal(root.get(CommitImpl_.id), id) + )); + try { + return Optional.of(em.createQuery(query).getSingleResult()); + } catch (NoResultException e) { + return Optional.empty(); + } + }); + } +} diff --git a/app/dao/impl/jpa/JpaDao.java b/app/dao/impl/jpa/JpaDao.java index addb1fff..512f182c 100644 --- a/app/dao/impl/jpa/JpaDao.java +++ b/app/dao/impl/jpa/JpaDao.java @@ -3,6 +3,7 @@ import dao.Dao; import jpa.manager.JPAManager; +import javax.persistence.EntityManager; import javax.persistence.EntityTransaction; import java.util.Optional; @@ -23,13 +24,17 @@ public Optional update(E e) { @Override public Optional persist(E e) { - return Optional.ofNullable(getJpaManager().transact(em -> { - EntityTransaction transaction = em.getTransaction(); - transaction.begin(); - em.persist(e); - transaction.commit(); - return e; - })); + return getJpaManager().transact(em -> { + return persist(e, em); + }); + } + + protected Optional persist(E e, EntityManager em) { + EntityTransaction transaction = em.getTransaction(); + transaction.begin(); + em.persist(e); + transaction.commit(); + return Optional.ofNullable(e); } @Override diff --git a/app/dao/impl/jpa/JpaElementDao.java b/app/dao/impl/jpa/JpaElementDao.java index 36a11fb7..dba0dffa 100644 --- a/app/dao/impl/jpa/JpaElementDao.java +++ b/app/dao/impl/jpa/JpaElementDao.java @@ -41,7 +41,7 @@ public Optional findById(UUID id) { CriteriaQuery query = builder.createQuery(MofObjectImpl.class); Root root = query.from(MofObjectImpl.class); query.select(root).where(builder.and( - builder.equal(root.get(MofObjectImpl_.identifier), id), + builder.equal(root.get(MofObjectImpl_.id), id), getTypeExpression(builder, root) )); try { diff --git a/app/dao/impl/jpa/JpaProjectDao.java b/app/dao/impl/jpa/JpaProjectDao.java index b129dc5d..6bb0b43c 100644 --- a/app/dao/impl/jpa/JpaProjectDao.java +++ b/app/dao/impl/jpa/JpaProjectDao.java @@ -33,7 +33,7 @@ public Optional findById(UUID id) { CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery query = builder.createQuery(ProjectImpl.class); Root root = query.from(ProjectImpl.class); - query.select(root).where(builder.equal(root.get(ProjectImpl_.identifier), id)); + query.select(root).where(builder.equal(root.get(ProjectImpl_.id), id)); try { return Optional.of(em.createQuery(query).getSingleResult()); } catch (NoResultException e) { diff --git a/app/dao/impl/jpa/JpaRelationshipDao.java b/app/dao/impl/jpa/JpaRelationshipDao.java index 8bdca5e3..ecd09ea7 100644 --- a/app/dao/impl/jpa/JpaRelationshipDao.java +++ b/app/dao/impl/jpa/JpaRelationshipDao.java @@ -42,7 +42,7 @@ public Optional findById(UUID id) { CriteriaQuery query = builder.createQuery(MofObjectImpl.class); Root root = query.from(MofObjectImpl.class); query.select(root).where(builder.and( - builder.equal(root.get(MofObjectImpl_.identifier), id), + builder.equal(root.get(MofObjectImpl_.id), id), getTypeExpression(builder, root) )); try { diff --git a/app/jackson/MofObjectDeserializer.java b/app/jackson/MofObjectDeserializer.java index 1ddd16ef..7b5c3e90 100644 --- a/app/jackson/MofObjectDeserializer.java +++ b/app/jackson/MofObjectDeserializer.java @@ -30,7 +30,7 @@ public MofObjectImpl deserialize(JsonParser p, DeserializationContext ctxt) thro JsonToken token; MofObjectImpl mof = null; while ((token = p.nextToken()) != null && token != JsonToken.END_OBJECT) { - if (mof == null && token == JsonToken.FIELD_NAME && "identifier".equals(p.getCurrentName())) { + if (mof == null && token == JsonToken.FIELD_NAME && "id".equals(p.getCurrentName())) { p.nextToken(); Object id = p.getText(); if ("java.util.UUID".endsWith("UUID")) { diff --git a/app/jackson/MofObjectSerializer.java b/app/jackson/MofObjectSerializer.java index cad61719..0a2aaaa8 100644 --- a/app/jackson/MofObjectSerializer.java +++ b/app/jackson/MofObjectSerializer.java @@ -19,7 +19,7 @@ public MofObjectSerializer(Class clazz) { @Override public void serialize(MofObject value, JsonGenerator gen, SerializerProvider provider) throws IOException { try { - if (value == null || value.getIdentifier() == null) { + if (value == null || value.getId() == null) { gen.writeNull(); return; } @@ -28,7 +28,7 @@ public void serialize(MofObject value, JsonGenerator gen, SerializerProvider pro return; } gen.writeStartObject(); - gen.writeObjectField("identifier", value.getIdentifier()); + gen.writeObjectField("id", value.getId()); gen.writeEndObject(); } } \ No newline at end of file diff --git a/app/jackson/databind/impl/HibernateObjectMapperFactory.java b/app/jackson/databind/impl/HibernateObjectMapperFactory.java index 7f14c77f..27379780 100644 --- a/app/jackson/databind/impl/HibernateObjectMapperFactory.java +++ b/app/jackson/databind/impl/HibernateObjectMapperFactory.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.type.ClassKey; @@ -33,7 +34,8 @@ public HibernateObjectMapperFactory(MetamodelProvider metamodelProvider, JPAMana @Override public ObjectMapper getObjectMapper() { ObjectMapper objectMapper = Json.newDefaultMapper(); - objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true); + objectMapper.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY); + objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); Hibernate5Module hibernate5Module = new Hibernate5Module(jpaManager.getEntityManagerFactory().unwrap(SessionFactory.class)); hibernate5Module.enable(Hibernate5Module.Feature.FORCE_LAZY_LOADING); diff --git a/app/jpa/UseExistingOrGenerateUUIDGenerator.java b/app/jpa/UseExistingOrGenerateUUIDGenerator.java index 6bcfd714..9b0b7077 100644 --- a/app/jpa/UseExistingOrGenerateUUIDGenerator.java +++ b/app/jpa/UseExistingOrGenerateUUIDGenerator.java @@ -1,7 +1,6 @@ package jpa; import org.hibernate.HibernateException; -import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.id.UUIDGenerator; diff --git a/app/org/omg/sysml/extension/impl/ProjectImpl.java b/app/org/omg/sysml/extension/impl/ProjectImpl.java index be52cf3c..885721ed 100644 --- a/app/org/omg/sysml/extension/impl/ProjectImpl.java +++ b/app/org/omg/sysml/extension/impl/ProjectImpl.java @@ -1,18 +1,17 @@ package org.omg.sysml.extension.impl; import com.fasterxml.jackson.annotation.*; -import org.omg.sysml.extension.Project; - import org.hibernate.annotations.FetchMode; +import org.omg.sysml.extension.Project; import org.omg.sysml.metamodel.impl.MofObjectImpl; -// import info.archinnov.achilles.annotations.UDT; - +import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.Lob; -import javax.persistence.DiscriminatorValue; import javax.persistence.SecondaryTable; +// import info.archinnov.achilles.annotations.UDT; + @Entity @SecondaryTable(name = "Project") @org.hibernate.annotations.Table(appliesTo = "Project", fetch = FetchMode.SELECT, optional = false) diff --git a/app/org/omg/sysml/extension/impl/package-info.java b/app/org/omg/sysml/extension/impl/package-info.java index b878e929..4f7d3316 100644 --- a/app/org/omg/sysml/extension/impl/package-info.java +++ b/app/org/omg/sysml/extension/impl/package-info.java @@ -11,10 +11,6 @@ }) package org.omg.sysml.extension.impl; -import org.hibernate.annotations.AnyMetaDef; -import org.hibernate.annotations.AnyMetaDefs; -import org.hibernate.annotations.MetaValue; +import org.hibernate.annotations.*; -// TODO Abstract this concept to cli option -import org.hibernate.annotations.GenericGenerators; -import org.hibernate.annotations.GenericGenerator; \ No newline at end of file +// TODO Abstract this concept to cli option \ No newline at end of file diff --git a/app/org/omg/sysml/metamodel/MofObject.java b/app/org/omg/sysml/metamodel/MofObject.java index ae826067..b16daece 100644 --- a/app/org/omg/sysml/metamodel/MofObject.java +++ b/app/org/omg/sysml/metamodel/MofObject.java @@ -1,7 +1,7 @@ package org.omg.sysml.metamodel; public interface MofObject { - java.util.UUID getIdentifier(); + java.util.UUID getId(); // TODO Remove temporary modification for prototyping Project concept diff --git a/app/org/omg/sysml/metamodel/impl/AcceptActionUsageImpl.java b/app/org/omg/sysml/metamodel/impl/AcceptActionUsageImpl.java index 9dfd766a..6b0f86ea 100644 --- a/app/org/omg/sysml/metamodel/impl/AcceptActionUsageImpl.java +++ b/app/org/omg/sysml/metamodel/impl/AcceptActionUsageImpl.java @@ -1115,6 +1115,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "AcceptActionUsage") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ActionUsageImpl.java b/app/org/omg/sysml/metamodel/impl/ActionUsageImpl.java index da5c02b6..e48ad696 100644 --- a/app/org/omg/sysml/metamodel/impl/ActionUsageImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ActionUsageImpl.java @@ -1094,6 +1094,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ActionUsage") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ActivityImpl.java b/app/org/omg/sysml/metamodel/impl/ActivityImpl.java index ff8a9548..288b8622 100644 --- a/app/org/omg/sysml/metamodel/impl/ActivityImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ActivityImpl.java @@ -766,6 +766,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Activity") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/AnnotationImpl.java b/app/org/omg/sysml/metamodel/impl/AnnotationImpl.java index dd03724b..dfae6d85 100644 --- a/app/org/omg/sysml/metamodel/impl/AnnotationImpl.java +++ b/app/org/omg/sysml/metamodel/impl/AnnotationImpl.java @@ -245,6 +245,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Annotation") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/AssociationBlockImpl.java b/app/org/omg/sysml/metamodel/impl/AssociationBlockImpl.java index a3ed9139..c1921f20 100644 --- a/app/org/omg/sysml/metamodel/impl/AssociationBlockImpl.java +++ b/app/org/omg/sysml/metamodel/impl/AssociationBlockImpl.java @@ -280,6 +280,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "AssociationBlock") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/AssociationImpl.java b/app/org/omg/sysml/metamodel/impl/AssociationImpl.java index 2c179cf9..71f80b8e 100644 --- a/app/org/omg/sysml/metamodel/impl/AssociationImpl.java +++ b/app/org/omg/sysml/metamodel/impl/AssociationImpl.java @@ -280,6 +280,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Association") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/BehaviorImpl.java b/app/org/omg/sysml/metamodel/impl/BehaviorImpl.java index e0a9f1e9..042b0c17 100644 --- a/app/org/omg/sysml/metamodel/impl/BehaviorImpl.java +++ b/app/org/omg/sysml/metamodel/impl/BehaviorImpl.java @@ -584,6 +584,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Behavior") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/BindingConnectorImpl.java b/app/org/omg/sysml/metamodel/impl/BindingConnectorImpl.java index 18c9efde..9f4f19fe 100644 --- a/app/org/omg/sysml/metamodel/impl/BindingConnectorImpl.java +++ b/app/org/omg/sysml/metamodel/impl/BindingConnectorImpl.java @@ -327,6 +327,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "BindingConnector") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/BlockExpressionImpl.java b/app/org/omg/sysml/metamodel/impl/BlockExpressionImpl.java index ceee24e6..d7cdb0ff 100644 --- a/app/org/omg/sysml/metamodel/impl/BlockExpressionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/BlockExpressionImpl.java @@ -875,6 +875,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "BlockExpression") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/BlockImpl.java b/app/org/omg/sysml/metamodel/impl/BlockImpl.java index bfb16701..a17ece44 100644 --- a/app/org/omg/sysml/metamodel/impl/BlockImpl.java +++ b/app/org/omg/sysml/metamodel/impl/BlockImpl.java @@ -688,6 +688,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Block") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/BlockPropertyImpl.java b/app/org/omg/sysml/metamodel/impl/BlockPropertyImpl.java index 5d3cafa3..ae1a7d79 100644 --- a/app/org/omg/sysml/metamodel/impl/BlockPropertyImpl.java +++ b/app/org/omg/sysml/metamodel/impl/BlockPropertyImpl.java @@ -1068,6 +1068,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "BlockProperty") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ClassImpl.java b/app/org/omg/sysml/metamodel/impl/ClassImpl.java index a4af2c44..bd8619f2 100644 --- a/app/org/omg/sysml/metamodel/impl/ClassImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ClassImpl.java @@ -532,6 +532,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Class") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ClassifierImpl.java b/app/org/omg/sysml/metamodel/impl/ClassifierImpl.java index 9cc49dc9..980f5316 100644 --- a/app/org/omg/sysml/metamodel/impl/ClassifierImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ClassifierImpl.java @@ -532,6 +532,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Classifier") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/CommentImpl.java b/app/org/omg/sysml/metamodel/impl/CommentImpl.java index 109ef24a..04397263 100644 --- a/app/org/omg/sysml/metamodel/impl/CommentImpl.java +++ b/app/org/omg/sysml/metamodel/impl/CommentImpl.java @@ -148,6 +148,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Comment") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ConditionalImportImpl.java b/app/org/omg/sysml/metamodel/impl/ConditionalImportImpl.java index d30cf9a8..6d2f2db2 100644 --- a/app/org/omg/sysml/metamodel/impl/ConditionalImportImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ConditionalImportImpl.java @@ -132,6 +132,7 @@ public void setImportOwningPackage(Package importOwningPackage) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "visibility", table = "ConditionalImport") public VisibilityKind getVisibility() { return visibility; } @@ -302,6 +303,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ConditionalImport") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ConditionalSuccessionImpl.java b/app/org/omg/sysml/metamodel/impl/ConditionalSuccessionImpl.java index 34cc7928..db84d43e 100644 --- a/app/org/omg/sysml/metamodel/impl/ConditionalSuccessionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ConditionalSuccessionImpl.java @@ -447,6 +447,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ConditionalSuccession") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ConjugatedEndPortMembershipImpl.java b/app/org/omg/sysml/metamodel/impl/ConjugatedEndPortMembershipImpl.java index e71c42a5..89fa5b10 100644 --- a/app/org/omg/sysml/metamodel/impl/ConjugatedEndPortMembershipImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ConjugatedEndPortMembershipImpl.java @@ -191,6 +191,7 @@ public void setIsPort(Boolean isPort) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "direction", table = "ConjugatedEndPortMembership") public FeatureDirectionKind getDirection() { return direction; } @@ -226,6 +227,7 @@ public void setMemberName(String memberName) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "visibility", table = "ConjugatedEndPortMembership") public VisibilityKind getVisibility() { return visibility; } @@ -476,6 +478,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ConjugatedEndPortMembership") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ConjugatedPortMembershipImpl.java b/app/org/omg/sysml/metamodel/impl/ConjugatedPortMembershipImpl.java index 3eee8835..d95b1be6 100644 --- a/app/org/omg/sysml/metamodel/impl/ConjugatedPortMembershipImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ConjugatedPortMembershipImpl.java @@ -210,6 +210,7 @@ public void setIsPort(Boolean isPort) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "direction", table = "ConjugatedPortMembership") public FeatureDirectionKind getDirection() { return direction; } @@ -245,6 +246,7 @@ public void setMemberName(String memberName) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "visibility", table = "ConjugatedPortMembership") public VisibilityKind getVisibility() { return visibility; } @@ -495,6 +497,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ConjugatedPortMembership") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ConnectionUsageImpl.java b/app/org/omg/sysml/metamodel/impl/ConnectionUsageImpl.java index 3cf7fe95..48bf8fa7 100644 --- a/app/org/omg/sysml/metamodel/impl/ConnectionUsageImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ConnectionUsageImpl.java @@ -499,6 +499,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ConnectionUsage") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ConnectorImpl.java b/app/org/omg/sysml/metamodel/impl/ConnectorImpl.java index 60d6a890..de71ae5b 100644 --- a/app/org/omg/sysml/metamodel/impl/ConnectorImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ConnectorImpl.java @@ -327,6 +327,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Connector") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ControlNodeImpl.java b/app/org/omg/sysml/metamodel/impl/ControlNodeImpl.java index 4e8c9b5d..e26dd6ed 100644 --- a/app/org/omg/sysml/metamodel/impl/ControlNodeImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ControlNodeImpl.java @@ -1094,6 +1094,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ControlNode") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/DataTypeImpl.java b/app/org/omg/sysml/metamodel/impl/DataTypeImpl.java index 13931a8e..82559e62 100644 --- a/app/org/omg/sysml/metamodel/impl/DataTypeImpl.java +++ b/app/org/omg/sysml/metamodel/impl/DataTypeImpl.java @@ -532,6 +532,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "DataType") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/DecisionNodeImpl.java b/app/org/omg/sysml/metamodel/impl/DecisionNodeImpl.java index 6a3d43fe..67b8ca9c 100644 --- a/app/org/omg/sysml/metamodel/impl/DecisionNodeImpl.java +++ b/app/org/omg/sysml/metamodel/impl/DecisionNodeImpl.java @@ -1094,6 +1094,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "DecisionNode") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/DefinitionImpl.java b/app/org/omg/sysml/metamodel/impl/DefinitionImpl.java index 6aa97a0d..fffc9040 100644 --- a/app/org/omg/sysml/metamodel/impl/DefinitionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/DefinitionImpl.java @@ -688,6 +688,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Definition") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ElementImpl.java b/app/org/omg/sysml/metamodel/impl/ElementImpl.java index 894dfccd..e28b0ff8 100644 --- a/app/org/omg/sysml/metamodel/impl/ElementImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ElementImpl.java @@ -90,6 +90,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Element") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/EndFeatureMembershipImpl.java b/app/org/omg/sysml/metamodel/impl/EndFeatureMembershipImpl.java index 35de734a..71699a5a 100644 --- a/app/org/omg/sysml/metamodel/impl/EndFeatureMembershipImpl.java +++ b/app/org/omg/sysml/metamodel/impl/EndFeatureMembershipImpl.java @@ -191,6 +191,7 @@ public void setIsPort(Boolean isPort) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "direction", table = "EndFeatureMembership") public FeatureDirectionKind getDirection() { return direction; } @@ -226,6 +227,7 @@ public void setMemberName(String memberName) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "visibility", table = "EndFeatureMembership") public VisibilityKind getVisibility() { return visibility; } @@ -476,6 +478,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "EndFeatureMembership") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/EndPortMembershipImpl.java b/app/org/omg/sysml/metamodel/impl/EndPortMembershipImpl.java index e03cad0e..f7439192 100644 --- a/app/org/omg/sysml/metamodel/impl/EndPortMembershipImpl.java +++ b/app/org/omg/sysml/metamodel/impl/EndPortMembershipImpl.java @@ -191,6 +191,7 @@ public void setIsPort(Boolean isPort) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "direction", table = "EndPortMembership") public FeatureDirectionKind getDirection() { return direction; } @@ -226,6 +227,7 @@ public void setMemberName(String memberName) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "visibility", table = "EndPortMembership") public VisibilityKind getVisibility() { return visibility; } @@ -476,6 +478,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "EndPortMembership") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ExpressionImpl.java b/app/org/omg/sysml/metamodel/impl/ExpressionImpl.java index f97b7439..cb9222a0 100644 --- a/app/org/omg/sysml/metamodel/impl/ExpressionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ExpressionImpl.java @@ -875,6 +875,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Expression") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/FeatureImpl.java b/app/org/omg/sysml/metamodel/impl/FeatureImpl.java index 3bb67620..3986b9e9 100644 --- a/app/org/omg/sysml/metamodel/impl/FeatureImpl.java +++ b/app/org/omg/sysml/metamodel/impl/FeatureImpl.java @@ -828,6 +828,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Feature") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/FeatureMembershipImpl.java b/app/org/omg/sysml/metamodel/impl/FeatureMembershipImpl.java index 258c4a87..71570528 100644 --- a/app/org/omg/sysml/metamodel/impl/FeatureMembershipImpl.java +++ b/app/org/omg/sysml/metamodel/impl/FeatureMembershipImpl.java @@ -191,6 +191,7 @@ public void setIsPort(Boolean isPort) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "direction", table = "FeatureMembership") public FeatureDirectionKind getDirection() { return direction; } @@ -226,6 +227,7 @@ public void setMemberName(String memberName) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "visibility", table = "FeatureMembership") public VisibilityKind getVisibility() { return visibility; } @@ -476,6 +478,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "FeatureMembership") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/FeatureReferenceExpressionImpl.java b/app/org/omg/sysml/metamodel/impl/FeatureReferenceExpressionImpl.java index 5a95c509..115a9066 100644 --- a/app/org/omg/sysml/metamodel/impl/FeatureReferenceExpressionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/FeatureReferenceExpressionImpl.java @@ -894,6 +894,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "FeatureReferenceExpression") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/FeatureTypingImpl.java b/app/org/omg/sysml/metamodel/impl/FeatureTypingImpl.java index 451c683b..d62a22bd 100644 --- a/app/org/omg/sysml/metamodel/impl/FeatureTypingImpl.java +++ b/app/org/omg/sysml/metamodel/impl/FeatureTypingImpl.java @@ -304,6 +304,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "FeatureTyping") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/FeatureValueImpl.java b/app/org/omg/sysml/metamodel/impl/FeatureValueImpl.java index 7c9cc3d0..fbd43e61 100644 --- a/app/org/omg/sysml/metamodel/impl/FeatureValueImpl.java +++ b/app/org/omg/sysml/metamodel/impl/FeatureValueImpl.java @@ -252,6 +252,7 @@ public void setIsPort(Boolean isPort) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "direction", table = "FeatureValue") public FeatureDirectionKind getDirection() { return direction; } @@ -287,6 +288,7 @@ public void setMemberName(String memberName) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "visibility", table = "FeatureValue") public VisibilityKind getVisibility() { return visibility; } @@ -537,6 +539,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "FeatureValue") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ForkNodeImpl.java b/app/org/omg/sysml/metamodel/impl/ForkNodeImpl.java index 4e4022bd..0d221606 100644 --- a/app/org/omg/sysml/metamodel/impl/ForkNodeImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ForkNodeImpl.java @@ -1094,6 +1094,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ForkNode") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/FunctionImpl.java b/app/org/omg/sysml/metamodel/impl/FunctionImpl.java index e88f52a9..af2d2a3a 100644 --- a/app/org/omg/sysml/metamodel/impl/FunctionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/FunctionImpl.java @@ -631,6 +631,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Function") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/GeneralizationImpl.java b/app/org/omg/sysml/metamodel/impl/GeneralizationImpl.java index 86ac6b90..320a8319 100644 --- a/app/org/omg/sysml/metamodel/impl/GeneralizationImpl.java +++ b/app/org/omg/sysml/metamodel/impl/GeneralizationImpl.java @@ -266,6 +266,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Generalization") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ImportConditionImpl.java b/app/org/omg/sysml/metamodel/impl/ImportConditionImpl.java index bdd3d1eb..208e6dd9 100644 --- a/app/org/omg/sysml/metamodel/impl/ImportConditionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ImportConditionImpl.java @@ -245,6 +245,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ImportCondition") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ImportImpl.java b/app/org/omg/sysml/metamodel/impl/ImportImpl.java index f9185e59..a87ea930 100644 --- a/app/org/omg/sysml/metamodel/impl/ImportImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ImportImpl.java @@ -92,6 +92,7 @@ public void setImportOwningPackage(Package importOwningPackage) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "visibility", table = "Import") public VisibilityKind getVisibility() { return visibility; } @@ -262,6 +263,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Import") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/InstanceCreationExpressionImpl.java b/app/org/omg/sysml/metamodel/impl/InstanceCreationExpressionImpl.java index e94327ef..b018386e 100644 --- a/app/org/omg/sysml/metamodel/impl/InstanceCreationExpressionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/InstanceCreationExpressionImpl.java @@ -894,6 +894,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "InstanceCreationExpression") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/InteractionImpl.java b/app/org/omg/sysml/metamodel/impl/InteractionImpl.java index f0cd311c..3aca70f6 100644 --- a/app/org/omg/sysml/metamodel/impl/InteractionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/InteractionImpl.java @@ -280,6 +280,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Interaction") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/InterfaceDefinitionImpl.java b/app/org/omg/sysml/metamodel/impl/InterfaceDefinitionImpl.java index e6a3c2f9..a3a704ee 100644 --- a/app/org/omg/sysml/metamodel/impl/InterfaceDefinitionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/InterfaceDefinitionImpl.java @@ -306,6 +306,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "InterfaceDefinition") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/InterfaceUsageImpl.java b/app/org/omg/sysml/metamodel/impl/InterfaceUsageImpl.java index 08477cd3..76cc9b24 100644 --- a/app/org/omg/sysml/metamodel/impl/InterfaceUsageImpl.java +++ b/app/org/omg/sysml/metamodel/impl/InterfaceUsageImpl.java @@ -520,6 +520,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "InterfaceUsage") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/InvocationExpressionImpl.java b/app/org/omg/sysml/metamodel/impl/InvocationExpressionImpl.java index 9afcf9d0..0f764d30 100644 --- a/app/org/omg/sysml/metamodel/impl/InvocationExpressionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/InvocationExpressionImpl.java @@ -875,6 +875,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "InvocationExpression") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ItemFeatureImpl.java b/app/org/omg/sysml/metamodel/impl/ItemFeatureImpl.java index afc8f5a7..bf654958 100644 --- a/app/org/omg/sysml/metamodel/impl/ItemFeatureImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ItemFeatureImpl.java @@ -828,6 +828,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ItemFeature") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ItemFlowEndImpl.java b/app/org/omg/sysml/metamodel/impl/ItemFlowEndImpl.java index 24211129..e9e82986 100644 --- a/app/org/omg/sysml/metamodel/impl/ItemFlowEndImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ItemFlowEndImpl.java @@ -828,6 +828,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ItemFlowEnd") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ItemFlowFeatureImpl.java b/app/org/omg/sysml/metamodel/impl/ItemFlowFeatureImpl.java index 86558a6c..2c309eae 100644 --- a/app/org/omg/sysml/metamodel/impl/ItemFlowFeatureImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ItemFlowFeatureImpl.java @@ -828,6 +828,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ItemFlowFeature") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ItemFlowImpl.java b/app/org/omg/sysml/metamodel/impl/ItemFlowImpl.java index 48830553..108a7e53 100644 --- a/app/org/omg/sysml/metamodel/impl/ItemFlowImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ItemFlowImpl.java @@ -483,6 +483,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ItemFlow") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/JoinNodeImpl.java b/app/org/omg/sysml/metamodel/impl/JoinNodeImpl.java index f61ad97f..06272d1a 100644 --- a/app/org/omg/sysml/metamodel/impl/JoinNodeImpl.java +++ b/app/org/omg/sysml/metamodel/impl/JoinNodeImpl.java @@ -1094,6 +1094,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "JoinNode") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/LiteralBooleanImpl.java b/app/org/omg/sysml/metamodel/impl/LiteralBooleanImpl.java index fb593650..a6a6413a 100644 --- a/app/org/omg/sysml/metamodel/impl/LiteralBooleanImpl.java +++ b/app/org/omg/sysml/metamodel/impl/LiteralBooleanImpl.java @@ -891,6 +891,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "LiteralBoolean") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/LiteralExpressionImpl.java b/app/org/omg/sysml/metamodel/impl/LiteralExpressionImpl.java index 473d8328..0a7d3765 100644 --- a/app/org/omg/sysml/metamodel/impl/LiteralExpressionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/LiteralExpressionImpl.java @@ -875,6 +875,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "LiteralExpression") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/LiteralIntegerImpl.java b/app/org/omg/sysml/metamodel/impl/LiteralIntegerImpl.java index 581b15f9..f661ee59 100644 --- a/app/org/omg/sysml/metamodel/impl/LiteralIntegerImpl.java +++ b/app/org/omg/sysml/metamodel/impl/LiteralIntegerImpl.java @@ -891,6 +891,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "LiteralInteger") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/LiteralRealImpl.java b/app/org/omg/sysml/metamodel/impl/LiteralRealImpl.java index 7f8c5e98..c1b277d8 100644 --- a/app/org/omg/sysml/metamodel/impl/LiteralRealImpl.java +++ b/app/org/omg/sysml/metamodel/impl/LiteralRealImpl.java @@ -891,6 +891,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "LiteralReal") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/LiteralStringImpl.java b/app/org/omg/sysml/metamodel/impl/LiteralStringImpl.java index 2278d09e..2dd924a3 100644 --- a/app/org/omg/sysml/metamodel/impl/LiteralStringImpl.java +++ b/app/org/omg/sysml/metamodel/impl/LiteralStringImpl.java @@ -893,6 +893,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "LiteralString") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/LiteralUnboundedImpl.java b/app/org/omg/sysml/metamodel/impl/LiteralUnboundedImpl.java index 1e6edecc..0fbcf31a 100644 --- a/app/org/omg/sysml/metamodel/impl/LiteralUnboundedImpl.java +++ b/app/org/omg/sysml/metamodel/impl/LiteralUnboundedImpl.java @@ -875,6 +875,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "LiteralUnbounded") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/MembershipImpl.java b/app/org/omg/sysml/metamodel/impl/MembershipImpl.java index 4f343b4e..4b4aaf0a 100644 --- a/app/org/omg/sysml/metamodel/impl/MembershipImpl.java +++ b/app/org/omg/sysml/metamodel/impl/MembershipImpl.java @@ -72,6 +72,7 @@ public void setMemberName(String memberName) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "visibility", table = "Membership") public VisibilityKind getVisibility() { return visibility; } @@ -322,6 +323,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Membership") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/MergeNodeImpl.java b/app/org/omg/sysml/metamodel/impl/MergeNodeImpl.java index 5a44af8e..ad204cd2 100644 --- a/app/org/omg/sysml/metamodel/impl/MergeNodeImpl.java +++ b/app/org/omg/sysml/metamodel/impl/MergeNodeImpl.java @@ -1094,6 +1094,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "MergeNode") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/MofObjectImpl.java b/app/org/omg/sysml/metamodel/impl/MofObjectImpl.java index dff2b241..53c9b960 100644 --- a/app/org/omg/sysml/metamodel/impl/MofObjectImpl.java +++ b/app/org/omg/sysml/metamodel/impl/MofObjectImpl.java @@ -23,20 +23,20 @@ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME) public abstract class MofObjectImpl implements MofObject { //@PartitionKey - public java.util.UUID identifier; + public java.util.UUID id; @Id // TODO Abstract this concept to cli option @GeneratedValue(generator = "UseExistingOrGenerateUUIDGenerator") - @Column(name = "identifier") - @JsonGetter(value = "identifier") - public java.util.UUID getIdentifier() { - return identifier; + @Column(name = "id") + @JsonGetter(value = "id") + public java.util.UUID getId() { + return id; } - @JsonSetter(value = "identifier") - public void setIdentifier(java.util.UUID identifier) { - this.identifier = identifier; + @JsonSetter(value = "id") + public void setId(java.util.UUID id) { + this.id = id; } // TODO Remove temporary modification for prototyping Project concept @@ -56,4 +56,20 @@ public org.omg.sysml.extension.Project getContainingProject() { public void setContainingProject(org.omg.sysml.extension.Project containingProject) { this.containingProject = containingProject; } + + // TODO Remove hardcoding for identifier + + // @info.archinnov.achilles.annotations.Column("identifier") + private java.util.UUID identifier; + + @JsonGetter + @javax.persistence.Column(name = "identifier", table = "MofObject") + public java.util.UUID getIdentifier() { + return identifier; + } + + @JsonSetter + public void setIdentifier(java.util.UUID identifier) { + this.identifier = identifier; + } } diff --git a/app/org/omg/sysml/metamodel/impl/MultiplicityImpl.java b/app/org/omg/sysml/metamodel/impl/MultiplicityImpl.java index 7dc9c940..1d3a9e3f 100644 --- a/app/org/omg/sysml/metamodel/impl/MultiplicityImpl.java +++ b/app/org/omg/sysml/metamodel/impl/MultiplicityImpl.java @@ -828,6 +828,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Multiplicity") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/MultiplicityRangeImpl.java b/app/org/omg/sysml/metamodel/impl/MultiplicityRangeImpl.java index ab6df8b8..a3e93abb 100644 --- a/app/org/omg/sysml/metamodel/impl/MultiplicityRangeImpl.java +++ b/app/org/omg/sysml/metamodel/impl/MultiplicityRangeImpl.java @@ -891,6 +891,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "MultiplicityRange") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/NullExpressionImpl.java b/app/org/omg/sysml/metamodel/impl/NullExpressionImpl.java index 1062f540..aa0df2df 100644 --- a/app/org/omg/sysml/metamodel/impl/NullExpressionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/NullExpressionImpl.java @@ -875,6 +875,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "NullExpression") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/OperatorExpressionImpl.java b/app/org/omg/sysml/metamodel/impl/OperatorExpressionImpl.java index f58ee65c..139173d2 100644 --- a/app/org/omg/sysml/metamodel/impl/OperatorExpressionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/OperatorExpressionImpl.java @@ -917,6 +917,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "OperatorExpression") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/OwnershipImpl.java b/app/org/omg/sysml/metamodel/impl/OwnershipImpl.java index aa983eb0..0395ae5b 100644 --- a/app/org/omg/sysml/metamodel/impl/OwnershipImpl.java +++ b/app/org/omg/sysml/metamodel/impl/OwnershipImpl.java @@ -245,6 +245,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Ownership") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/PackageImpl.java b/app/org/omg/sysml/metamodel/impl/PackageImpl.java index ef2c527c..d98fab9a 100644 --- a/app/org/omg/sysml/metamodel/impl/PackageImpl.java +++ b/app/org/omg/sysml/metamodel/impl/PackageImpl.java @@ -242,6 +242,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Package") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ParameterImpl.java b/app/org/omg/sysml/metamodel/impl/ParameterImpl.java index 20d23e0a..8418acbb 100644 --- a/app/org/omg/sysml/metamodel/impl/ParameterImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ParameterImpl.java @@ -828,6 +828,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Parameter") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ParameterMembershipImpl.java b/app/org/omg/sysml/metamodel/impl/ParameterMembershipImpl.java index 6230df56..8eb1be24 100644 --- a/app/org/omg/sysml/metamodel/impl/ParameterMembershipImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ParameterMembershipImpl.java @@ -229,6 +229,7 @@ public void setIsPort(Boolean isPort) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "direction", table = "ParameterMembership") public FeatureDirectionKind getDirection() { return direction; } @@ -264,6 +265,7 @@ public void setMemberName(String memberName) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "visibility", table = "ParameterMembership") public VisibilityKind getVisibility() { return visibility; } @@ -514,6 +516,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ParameterMembership") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/PartPropertyImpl.java b/app/org/omg/sysml/metamodel/impl/PartPropertyImpl.java index eb7aa678..1f2a18ce 100644 --- a/app/org/omg/sysml/metamodel/impl/PartPropertyImpl.java +++ b/app/org/omg/sysml/metamodel/impl/PartPropertyImpl.java @@ -1068,6 +1068,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "PartProperty") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/PerformActionUsageImpl.java b/app/org/omg/sysml/metamodel/impl/PerformActionUsageImpl.java index 136f618d..34dfb29d 100644 --- a/app/org/omg/sysml/metamodel/impl/PerformActionUsageImpl.java +++ b/app/org/omg/sysml/metamodel/impl/PerformActionUsageImpl.java @@ -1115,6 +1115,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "PerformActionUsage") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/PortDefinitionImpl.java b/app/org/omg/sysml/metamodel/impl/PortDefinitionImpl.java index 1781665e..8fd25760 100644 --- a/app/org/omg/sysml/metamodel/impl/PortDefinitionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/PortDefinitionImpl.java @@ -688,6 +688,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "PortDefinition") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/PortMembershipImpl.java b/app/org/omg/sysml/metamodel/impl/PortMembershipImpl.java index d2081529..83abfa01 100644 --- a/app/org/omg/sysml/metamodel/impl/PortMembershipImpl.java +++ b/app/org/omg/sysml/metamodel/impl/PortMembershipImpl.java @@ -210,6 +210,7 @@ public void setIsPort(Boolean isPort) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "direction", table = "PortMembership") public FeatureDirectionKind getDirection() { return direction; } @@ -245,6 +246,7 @@ public void setMemberName(String memberName) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "visibility", table = "PortMembership") public VisibilityKind getVisibility() { return visibility; } @@ -495,6 +497,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "PortMembership") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/PortUsageImpl.java b/app/org/omg/sysml/metamodel/impl/PortUsageImpl.java index 194df2a8..0166d615 100644 --- a/app/org/omg/sysml/metamodel/impl/PortUsageImpl.java +++ b/app/org/omg/sysml/metamodel/impl/PortUsageImpl.java @@ -1063,6 +1063,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "PortUsage") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/PredicateImpl.java b/app/org/omg/sysml/metamodel/impl/PredicateImpl.java index 6e102588..2e8228ad 100644 --- a/app/org/omg/sysml/metamodel/impl/PredicateImpl.java +++ b/app/org/omg/sysml/metamodel/impl/PredicateImpl.java @@ -631,6 +631,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Predicate") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/PropertyImpl.java b/app/org/omg/sysml/metamodel/impl/PropertyImpl.java index 0a5b2083..80d36a2c 100644 --- a/app/org/omg/sysml/metamodel/impl/PropertyImpl.java +++ b/app/org/omg/sysml/metamodel/impl/PropertyImpl.java @@ -1042,6 +1042,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Property") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/QueryPathExpressionImpl.java b/app/org/omg/sysml/metamodel/impl/QueryPathExpressionImpl.java index 92707c71..14aae9fa 100644 --- a/app/org/omg/sysml/metamodel/impl/QueryPathExpressionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/QueryPathExpressionImpl.java @@ -894,6 +894,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "QueryPathExpression") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/QueryPathStepExpressionImpl.java b/app/org/omg/sysml/metamodel/impl/QueryPathStepExpressionImpl.java index 2b3b07a8..d9c619a0 100644 --- a/app/org/omg/sysml/metamodel/impl/QueryPathStepExpressionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/QueryPathStepExpressionImpl.java @@ -917,6 +917,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "QueryPathStepExpression") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/QueryQualifierExpressionImpl.java b/app/org/omg/sysml/metamodel/impl/QueryQualifierExpressionImpl.java index 2500a757..fbaa7999 100644 --- a/app/org/omg/sysml/metamodel/impl/QueryQualifierExpressionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/QueryQualifierExpressionImpl.java @@ -917,6 +917,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "QueryQualifierExpression") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/RedefinitionImpl.java b/app/org/omg/sysml/metamodel/impl/RedefinitionImpl.java index 58dbe055..e1f209d9 100644 --- a/app/org/omg/sysml/metamodel/impl/RedefinitionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/RedefinitionImpl.java @@ -363,6 +363,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Redefinition") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ReferencePropertyImpl.java b/app/org/omg/sysml/metamodel/impl/ReferencePropertyImpl.java index f7bb92f0..5d21d463 100644 --- a/app/org/omg/sysml/metamodel/impl/ReferencePropertyImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ReferencePropertyImpl.java @@ -1068,6 +1068,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ReferenceProperty") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/RelationshipImpl.java b/app/org/omg/sysml/metamodel/impl/RelationshipImpl.java index f43a54aa..c766ba32 100644 --- a/app/org/omg/sysml/metamodel/impl/RelationshipImpl.java +++ b/app/org/omg/sysml/metamodel/impl/RelationshipImpl.java @@ -207,6 +207,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Relationship") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ReturnParameterMembershipImpl.java b/app/org/omg/sysml/metamodel/impl/ReturnParameterMembershipImpl.java index 0dda8e03..ef136298 100644 --- a/app/org/omg/sysml/metamodel/impl/ReturnParameterMembershipImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ReturnParameterMembershipImpl.java @@ -229,6 +229,7 @@ public void setIsPort(Boolean isPort) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "direction", table = "ReturnParameterMembership") public FeatureDirectionKind getDirection() { return direction; } @@ -264,6 +265,7 @@ public void setMemberName(String memberName) { @JsonGetter @javax.persistence.Enumerated(EnumType.STRING) + @javax.persistence.Column(name = "visibility", table = "ReturnParameterMembership") public VisibilityKind getVisibility() { return visibility; } @@ -514,6 +516,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ReturnParameterMembership") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/SendActionUsageImpl.java b/app/org/omg/sysml/metamodel/impl/SendActionUsageImpl.java index 22aa5053..1a858ea0 100644 --- a/app/org/omg/sysml/metamodel/impl/SendActionUsageImpl.java +++ b/app/org/omg/sysml/metamodel/impl/SendActionUsageImpl.java @@ -1136,6 +1136,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "SendActionUsage") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/SequenceConstructionExpressionImpl.java b/app/org/omg/sysml/metamodel/impl/SequenceConstructionExpressionImpl.java index a94f8129..9e60fc4e 100644 --- a/app/org/omg/sysml/metamodel/impl/SequenceConstructionExpressionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/SequenceConstructionExpressionImpl.java @@ -899,6 +899,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "SequenceConstructionExpression") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/SourceEndImpl.java b/app/org/omg/sysml/metamodel/impl/SourceEndImpl.java index 103deb9b..84108fd8 100644 --- a/app/org/omg/sysml/metamodel/impl/SourceEndImpl.java +++ b/app/org/omg/sysml/metamodel/impl/SourceEndImpl.java @@ -828,6 +828,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "SourceEnd") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/StepImpl.java b/app/org/omg/sysml/metamodel/impl/StepImpl.java index 9b3229bd..d76fac60 100644 --- a/app/org/omg/sysml/metamodel/impl/StepImpl.java +++ b/app/org/omg/sysml/metamodel/impl/StepImpl.java @@ -854,6 +854,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Step") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/SubsettingImpl.java b/app/org/omg/sysml/metamodel/impl/SubsettingImpl.java index 77f19582..545616fd 100644 --- a/app/org/omg/sysml/metamodel/impl/SubsettingImpl.java +++ b/app/org/omg/sysml/metamodel/impl/SubsettingImpl.java @@ -325,6 +325,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Subsetting") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/SuccessionImpl.java b/app/org/omg/sysml/metamodel/impl/SuccessionImpl.java index 3fcb4b8e..159ba668 100644 --- a/app/org/omg/sysml/metamodel/impl/SuccessionImpl.java +++ b/app/org/omg/sysml/metamodel/impl/SuccessionImpl.java @@ -426,6 +426,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Succession") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/SuccessionItemFlowImpl.java b/app/org/omg/sysml/metamodel/impl/SuccessionItemFlowImpl.java index 348e2eed..c85f7aba 100644 --- a/app/org/omg/sysml/metamodel/impl/SuccessionItemFlowImpl.java +++ b/app/org/omg/sysml/metamodel/impl/SuccessionItemFlowImpl.java @@ -582,6 +582,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "SuccessionItemFlow") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/SuperclassingImpl.java b/app/org/omg/sysml/metamodel/impl/SuperclassingImpl.java index b55f863f..5f8e2051 100644 --- a/app/org/omg/sysml/metamodel/impl/SuperclassingImpl.java +++ b/app/org/omg/sysml/metamodel/impl/SuperclassingImpl.java @@ -325,6 +325,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Superclassing") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/TargetEndImpl.java b/app/org/omg/sysml/metamodel/impl/TargetEndImpl.java index 8d9ffbfc..5e984d93 100644 --- a/app/org/omg/sysml/metamodel/impl/TargetEndImpl.java +++ b/app/org/omg/sysml/metamodel/impl/TargetEndImpl.java @@ -828,6 +828,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "TargetEnd") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/TransferActionUsageImpl.java b/app/org/omg/sysml/metamodel/impl/TransferActionUsageImpl.java index ebdf1e15..14b44737 100644 --- a/app/org/omg/sysml/metamodel/impl/TransferActionUsageImpl.java +++ b/app/org/omg/sysml/metamodel/impl/TransferActionUsageImpl.java @@ -1115,6 +1115,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "TransferActionUsage") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/TypeImpl.java b/app/org/omg/sysml/metamodel/impl/TypeImpl.java index fb9c8ceb..551a9439 100644 --- a/app/org/omg/sysml/metamodel/impl/TypeImpl.java +++ b/app/org/omg/sysml/metamodel/impl/TypeImpl.java @@ -506,6 +506,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Type") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/UsageImpl.java b/app/org/omg/sysml/metamodel/impl/UsageImpl.java index 1c8fd50d..63cd5f86 100644 --- a/app/org/omg/sysml/metamodel/impl/UsageImpl.java +++ b/app/org/omg/sysml/metamodel/impl/UsageImpl.java @@ -1000,6 +1000,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "Usage") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ValuePropertyImpl.java b/app/org/omg/sysml/metamodel/impl/ValuePropertyImpl.java index db5ca9be..7db7a2d2 100644 --- a/app/org/omg/sysml/metamodel/impl/ValuePropertyImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ValuePropertyImpl.java @@ -1068,6 +1068,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ValueProperty") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/metamodel/impl/ValueTypeImpl.java b/app/org/omg/sysml/metamodel/impl/ValueTypeImpl.java index c83daf64..33c3d0af 100644 --- a/app/org/omg/sysml/metamodel/impl/ValueTypeImpl.java +++ b/app/org/omg/sysml/metamodel/impl/ValueTypeImpl.java @@ -688,6 +688,7 @@ public void setOwningRelationship(Relationship owningRelationship) { private java.util.UUID identifier; @JsonGetter + @javax.persistence.Column(name = "identifier", table = "ValueType") public java.util.UUID getIdentifier() { return identifier; } diff --git a/app/org/omg/sysml/versioning/Commit.java b/app/org/omg/sysml/versioning/Commit.java new file mode 100644 index 00000000..578c5c37 --- /dev/null +++ b/app/org/omg/sysml/versioning/Commit.java @@ -0,0 +1,16 @@ +package org.omg.sysml.versioning; + +import org.omg.sysml.extension.Project; + +import java.time.ZonedDateTime; +import java.util.Set; + +public interface Commit extends Record { + Project getContainingProject(); + + Set getChanges(); + + ZonedDateTime getTimestamp(); + + void setTimestamp(ZonedDateTime timestamp); +} diff --git a/app/org/omg/sysml/versioning/ElementIdentity.java b/app/org/omg/sysml/versioning/ElementIdentity.java new file mode 100644 index 00000000..80dab40d --- /dev/null +++ b/app/org/omg/sysml/versioning/ElementIdentity.java @@ -0,0 +1,4 @@ +package org.omg.sysml.versioning; + +public interface ElementIdentity extends Record { +} diff --git a/app/org/omg/sysml/versioning/ElementRecord.java b/app/org/omg/sysml/versioning/ElementRecord.java new file mode 100644 index 00000000..8fba42eb --- /dev/null +++ b/app/org/omg/sysml/versioning/ElementRecord.java @@ -0,0 +1,9 @@ +package org.omg.sysml.versioning; + +import org.omg.sysml.metamodel.MofObject; + +public interface ElementRecord extends Record { + MofObject getData(); + + ElementIdentity getIdentity(); +} diff --git a/app/org/omg/sysml/versioning/Record.java b/app/org/omg/sysml/versioning/Record.java new file mode 100644 index 00000000..b93eb307 --- /dev/null +++ b/app/org/omg/sysml/versioning/Record.java @@ -0,0 +1,7 @@ +package org.omg.sysml.versioning; + +import java.util.UUID; + +public interface Record { + UUID getId(); +} diff --git a/app/org/omg/sysml/versioning/impl/CommitImpl.java b/app/org/omg/sysml/versioning/impl/CommitImpl.java new file mode 100644 index 00000000..c37550e2 --- /dev/null +++ b/app/org/omg/sysml/versioning/impl/CommitImpl.java @@ -0,0 +1,59 @@ +package org.omg.sysml.versioning.impl; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.omg.sysml.extension.Project; +import org.omg.sysml.extension.impl.ProjectImpl; +import org.omg.sysml.versioning.Commit; +import org.omg.sysml.versioning.ElementRecord; + +import javax.persistence.*; +import java.time.ZonedDateTime; +import java.util.HashSet; +import java.util.Set; + +@Entity(name = "Commit") +public class CommitImpl extends RecordImpl implements Commit { + @JsonProperty("@type") + private final String type = Commit.class.getSimpleName(); + + private Project containingProject; + private Set changes; + private ZonedDateTime timestamp; + + @Override + @ManyToOne(targetEntity = ProjectImpl.class, fetch = FetchType.LAZY) + public Project getContainingProject() { + return containingProject; + } + + public void setContainingProject(Project containingProject) { + this.containingProject = containingProject; + } + + @Override + @OneToMany(targetEntity = ElementRecordImpl.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER) + @JsonDeserialize(contentAs = ElementRecordImpl.class) + public Set getChanges() { + if (changes == null) { + changes = new HashSet<>(); + } + return changes; + } + + public void setChanges(Set changes) { + this.changes = changes; + } + + @Override + @Column + public ZonedDateTime getTimestamp() { + return timestamp; + } + + public void setTimestamp(ZonedDateTime timestamp) { + this.timestamp = timestamp; + } +} diff --git a/app/org/omg/sysml/versioning/impl/ElementIdentityImpl.java b/app/org/omg/sysml/versioning/impl/ElementIdentityImpl.java new file mode 100644 index 00000000..95135f76 --- /dev/null +++ b/app/org/omg/sysml/versioning/impl/ElementIdentityImpl.java @@ -0,0 +1,14 @@ +package org.omg.sysml.versioning.impl; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeName; +import org.omg.sysml.versioning.ElementIdentity; + +import javax.persistence.Entity; + +@Entity(name = "ElementIdentity") +@JsonTypeName(value = "ElementIdentity") +public class ElementIdentityImpl extends RecordImpl implements ElementIdentity { + @JsonProperty("@type") + private final String type = ElementIdentity.class.getSimpleName(); +} diff --git a/app/org/omg/sysml/versioning/impl/ElementRecordImpl.java b/app/org/omg/sysml/versioning/impl/ElementRecordImpl.java new file mode 100644 index 00000000..8f60ad84 --- /dev/null +++ b/app/org/omg/sysml/versioning/impl/ElementRecordImpl.java @@ -0,0 +1,50 @@ +package org.omg.sysml.versioning.impl; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.hibernate.annotations.Any; +import org.hibernate.annotations.CascadeType; +import org.omg.sysml.metamodel.MofObject; +import org.omg.sysml.metamodel.impl.MofObjectImpl; +import org.omg.sysml.versioning.ElementIdentity; +import org.omg.sysml.versioning.ElementRecord; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +@Entity(name = "ElementRecord") +@JsonTypeName(value = "ElementRecord") +public class ElementRecordImpl extends RecordImpl implements ElementRecord { + @JsonProperty("@type") + private final String type = ElementRecord.class.getSimpleName(); + + private MofObject data; + private ElementIdentity identity; + + @Any(metaDef = "MofObjectMetaDef", metaColumn = @javax.persistence.Column(name = "dataType"), fetch = FetchType.EAGER) + @JoinColumn(name = "dataId") + @org.hibernate.annotations.Cascade(value = org.hibernate.annotations.CascadeType.ALL) + @JsonDeserialize(as = MofObjectImpl.class) + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME) + public MofObject getData() { + return data; + } + + public void setData(MofObject data) { + this.data = data; + } + + @ManyToOne(targetEntity = ElementIdentityImpl.class, cascade = javax.persistence.CascadeType.ALL, fetch = FetchType.EAGER) + @JsonDeserialize(as = ElementIdentityImpl.class) + public ElementIdentity getIdentity() { + return identity; + } + + public void setIdentity(ElementIdentity identity) { + this.identity = identity; + } +} diff --git a/app/org/omg/sysml/versioning/impl/RecordImpl.java b/app/org/omg/sysml/versioning/impl/RecordImpl.java new file mode 100644 index 00000000..716cf220 --- /dev/null +++ b/app/org/omg/sysml/versioning/impl/RecordImpl.java @@ -0,0 +1,24 @@ +package org.omg.sysml.versioning.impl; + +import org.omg.sysml.versioning.Record; + +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; +import java.util.UUID; + +@MappedSuperclass +public abstract class RecordImpl implements Record { + private UUID id; + + @Override + @Id + @GeneratedValue(generator = "UseExistingOrGenerateUUIDGenerator") + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } +} diff --git a/app/services/CommitService.java b/app/services/CommitService.java new file mode 100644 index 00000000..08003947 --- /dev/null +++ b/app/services/CommitService.java @@ -0,0 +1,41 @@ +package services; + +import dao.CommitDao; +import dao.ProjectDao; +import org.omg.sysml.versioning.Commit; + +import javax.inject.Inject; +import javax.inject.Singleton; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +@Singleton +public class CommitService { + @Inject + private CommitDao commitDao; + + @Inject + private ProjectDao projectDao; + + public List getAll() { + return commitDao.findAll(); + } + + public Optional getById(UUID id) { + return commitDao.findById(id); + } + + public List getByProjectId(UUID projectId) { + return projectDao.findById(projectId).map(m -> commitDao.findAllByProject(m)).orElse(Collections.emptyList()); + } + + public Optional getByProjectIdAndId(UUID projectId, UUID commitId) { + return projectDao.findById(projectId).flatMap(m -> commitDao.findByProjectAndId(m, commitId)); + } + + public Optional create(Commit commit) { + return commit.getId() != null ? commitDao.update(commit) : commitDao.persist(commit); + } +} diff --git a/app/services/ProjectService.java b/app/services/ProjectService.java index 8c536226..226b9c7d 100644 --- a/app/services/ProjectService.java +++ b/app/services/ProjectService.java @@ -29,6 +29,6 @@ public Optional getById(UUID id) { } public Optional create(Project project) { - return project.getIdentifier() != null ? dao.update(project) : dao.persist(project); + return project.getId() != null ? dao.update(project) : dao.persist(project); } } diff --git a/conf/META-INF/persistence.xml b/conf/META-INF/persistence.xml index 5c523f9c..58694970 100644 --- a/conf/META-INF/persistence.xml +++ b/conf/META-INF/persistence.xml @@ -111,7 +111,7 @@ - + diff --git a/conf/routes b/conf/routes index e389924b..5aae36ae 100644 --- a/conf/routes +++ b/conf/routes @@ -3,7 +3,7 @@ # ~~~~ # An example controller showing a sample home page -GET / controllers.HomeController.index +GET / controllers.HomeController.index # Project endpoints GET /projects controllers.ProjectController.all() @@ -11,25 +11,32 @@ GET /projects/:id controllers.ProjectController.by POST /projects controllers.ProjectController.create(request : Request) # Element endpoints -GET /elements controllers.ElementController.all() -GET /elements/:id controllers.ElementController.byId(id : String) +GET /elements controllers.ElementController.all() +GET /elements/:id controllers.ElementController.byId(id : String) GET /projects/:mid/elements/:id controllers.ElementController.byProjectAndId(id : String, mid : String) GET /projects/:mid/elements controllers.ElementController.byProject(mid : String) -POST /elements controllers.ElementController.create(request : Request) +POST /elements controllers.ElementController.create(request : Request) + +# Commit endpoints +GET /commits controllers.CommitController.all() +GET /commits/:id controllers.CommitController.byId(id : String) +GET /projects/:mid/commits/:id controllers.CommitController.byProjectAndId(id : String, mid : String) +GET /projects/:mid/commits controllers.CommitController.byProject(mid : String) +POST /commits controllers.CommitController.create(request : Request) # Relationship endpoints -GET /relationships/:id controllers.RelationshipController.byId(id : String) +GET /relationships/:id controllers.RelationshipController.byId(id : String) # GET /relationship/element/:id controllers.RelationshipController.byRelatedElementId(id : String) # GET /relationship/source/:id controllers.RelationshipController.bySourceElementId(id : String) # GET /relationship/source/:id/type/:type controllers.RelationshipController.bySourceElementId(id : String) # GET /relationship/target/:id controllers.RelationshipController.byTargetElementId(id : String) # GET /relationship/target/:id/type/:type controllers.RelationshipController.byTargetElementId(id : String) -GET /relationships controllers.RelationshipController.all() +GET /relationships controllers.RelationshipController.all() GET /projects/:mid/relationships controllers.RelationshipController.byProject(mid : String) -POST /relationships controllers.RelationshipController.create(request : Request) +POST /relationships controllers.RelationshipController.create(request : Request) # Map static resources from the /public folder to the /assets URL path -GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset) +GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset) -GET /docs/ controllers.Assets.at(path="/public/swagger",file="index.html") -GET /docs/*file controllers.Assets.at(path="/public/swagger",file) \ No newline at end of file +GET /docs/ controllers.Assets.at(path="/public/swagger",file="index.html") +GET /docs/*file controllers.Assets.at(path="/public/swagger",file) \ No newline at end of file diff --git a/generated/org/omg/sysml/metamodel/impl/MofObjectImpl_.java b/generated/org/omg/sysml/metamodel/impl/MofObjectImpl_.java index 85188353..2d9a5f2b 100644 --- a/generated/org/omg/sysml/metamodel/impl/MofObjectImpl_.java +++ b/generated/org/omg/sysml/metamodel/impl/MofObjectImpl_.java @@ -10,8 +10,10 @@ public abstract class MofObjectImpl_ { public static volatile SingularAttribute identifier; + public static volatile SingularAttribute id; public static final String IDENTIFIER = "identifier"; + public static final String ID = "id"; } diff --git a/generated/org/omg/sysml/versioning/impl/CommitImpl_.java b/generated/org/omg/sysml/versioning/impl/CommitImpl_.java new file mode 100644 index 00000000..fcab399b --- /dev/null +++ b/generated/org/omg/sysml/versioning/impl/CommitImpl_.java @@ -0,0 +1,23 @@ +package org.omg.sysml.versioning.impl; + +import java.time.ZonedDateTime; +import javax.annotation.processing.Generated; +import javax.persistence.metamodel.SetAttribute; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; +import org.omg.sysml.extension.impl.ProjectImpl; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(CommitImpl.class) +public abstract class CommitImpl_ extends org.omg.sysml.versioning.impl.RecordImpl_ { + + public static volatile SetAttribute changes; + public static volatile SingularAttribute containingProject; + public static volatile SingularAttribute timestamp; + + public static final String CHANGES = "changes"; + public static final String CONTAINING_PROJECT = "containingProject"; + public static final String TIMESTAMP = "timestamp"; + +} + diff --git a/generated/org/omg/sysml/versioning/impl/Commit_.java b/generated/org/omg/sysml/versioning/impl/Commit_.java new file mode 100644 index 00000000..a38f1fde --- /dev/null +++ b/generated/org/omg/sysml/versioning/impl/Commit_.java @@ -0,0 +1,23 @@ +package org.omg.sysml.versioning.impl; + +import java.time.ZonedDateTime; +import javax.annotation.processing.Generated; +import javax.persistence.metamodel.SetAttribute; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; +import org.omg.sysml.extension.impl.ProjectImpl; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(Commit.class) +public abstract class Commit_ extends org.omg.sysml.versioning.impl.Record_ { + + public static volatile SetAttribute changes; + public static volatile SingularAttribute project; + public static volatile SingularAttribute timestamp; + + public static final String CHANGES = "changes"; + public static final String PROJECT = "project"; + public static final String TIMESTAMP = "timestamp"; + +} + diff --git a/generated/org/omg/sysml/versioning/impl/ElementIdentityImpl_.java b/generated/org/omg/sysml/versioning/impl/ElementIdentityImpl_.java new file mode 100644 index 00000000..d364d48b --- /dev/null +++ b/generated/org/omg/sysml/versioning/impl/ElementIdentityImpl_.java @@ -0,0 +1,13 @@ +package org.omg.sysml.versioning.impl; + +import javax.annotation.processing.Generated; +import javax.persistence.metamodel.StaticMetamodel; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(ElementIdentityImpl.class) +public abstract class ElementIdentityImpl_ extends org.omg.sysml.versioning.impl.RecordImpl_ { + + + +} + diff --git a/generated/org/omg/sysml/versioning/impl/ElementIdentity_.java b/generated/org/omg/sysml/versioning/impl/ElementIdentity_.java new file mode 100644 index 00000000..fc509984 --- /dev/null +++ b/generated/org/omg/sysml/versioning/impl/ElementIdentity_.java @@ -0,0 +1,13 @@ +package org.omg.sysml.versioning.impl; + +import javax.annotation.processing.Generated; +import javax.persistence.metamodel.StaticMetamodel; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(ElementIdentityImpl.class) +public abstract class ElementIdentity_ extends org.omg.sysml.versioning.impl.Record_ { + + + +} + diff --git a/generated/org/omg/sysml/versioning/impl/ElementRecordImpl_.java b/generated/org/omg/sysml/versioning/impl/ElementRecordImpl_.java new file mode 100644 index 00000000..723d41d4 --- /dev/null +++ b/generated/org/omg/sysml/versioning/impl/ElementRecordImpl_.java @@ -0,0 +1,16 @@ +package org.omg.sysml.versioning.impl; + +import javax.annotation.processing.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(ElementRecordImpl.class) +public abstract class ElementRecordImpl_ extends org.omg.sysml.versioning.impl.RecordImpl_ { + + public static volatile SingularAttribute identity; + + public static final String IDENTITY = "identity"; + +} + diff --git a/generated/org/omg/sysml/versioning/impl/ElementRecord_.java b/generated/org/omg/sysml/versioning/impl/ElementRecord_.java new file mode 100644 index 00000000..7203faac --- /dev/null +++ b/generated/org/omg/sysml/versioning/impl/ElementRecord_.java @@ -0,0 +1,16 @@ +package org.omg.sysml.versioning.impl; + +import javax.annotation.processing.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(ElementRecordImpl.class) +public abstract class ElementRecord_ extends org.omg.sysml.versioning.impl.Record_ { + + public static volatile SingularAttribute identity; + + public static final String IDENTITY = "identity"; + +} + diff --git a/generated/org/omg/sysml/versioning/impl/RecordImpl_.java b/generated/org/omg/sysml/versioning/impl/RecordImpl_.java new file mode 100644 index 00000000..3581cb75 --- /dev/null +++ b/generated/org/omg/sysml/versioning/impl/RecordImpl_.java @@ -0,0 +1,17 @@ +package org.omg.sysml.versioning.impl; + +import java.util.UUID; +import javax.annotation.processing.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(RecordImpl.class) +public abstract class RecordImpl_ { + + public static volatile SingularAttribute id; + + public static final String ID = "id"; + +} + diff --git a/generated/org/omg/sysml/versioning/impl/Record_.java b/generated/org/omg/sysml/versioning/impl/Record_.java new file mode 100644 index 00000000..f8dbd9c5 --- /dev/null +++ b/generated/org/omg/sysml/versioning/impl/Record_.java @@ -0,0 +1,17 @@ +package org.omg.sysml.versioning.impl; + +import java.util.UUID; +import javax.annotation.processing.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(RecordImpl.class) +public abstract class Record_ { + + public static volatile SingularAttribute id; + + public static final String ID = "id"; + +} + diff --git a/public/swagger/openapi.yaml b/public/swagger/openapi.yaml index e4622b45..c8acdf66 100644 --- a/public/swagger/openapi.yaml +++ b/public/swagger/openapi.yaml @@ -7,6 +7,7 @@ tags: - name: Project - name: Element - name: Relationship + - name: Commit paths: /projects: @@ -401,6 +402,140 @@ paths: default: $ref: '#/responses/Default' + /commits: + get: + tags: + - Commit + operationId: getCommits + summary: Get all commits + produces: + - application/json + responses: + 200: + description: Ok + schema: + type: array + items: + $ref: '#/definitions/Commit' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' + post: + tags: + - Commit + operationId: createCommit + summary: Add a new commit + consumes: + - application/json + produces: + - application/json + parameters: + - in: body + name: body + required: true + schema: + $ref: '#/definitions/Commit' + responses: + 201: + description: Created + schema: + $ref: '#/definitions/Commit' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' + /commits/{identifier}: + parameters: + - name: identifier + in: path + description: ID of the commit + type: string + required: true + get: + tags: + - Commit + operationId: getCommit + summary: Get commit by its ID + produces: + - application/json + responses: + 200: + description: Ok + schema: + $ref: '#/definitions/Commit' + 404: + $ref: '#/responses/NotFound' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' + /projects/{project_identifier}/commits/{commit_identifier}: + parameters: + - name: project_identifier + in: path + description: ID of the project + type: string + required: true + - name: commit_identifier + in: path + description: ID of the commit + type: string + required: true + get: + tags: + - Commit + operationId: getCommitByProjectAndId + summary: Get commit by project ID and its ID + produces: + - application/json + responses: + 200: + description: Ok + schema: + $ref: '#/definitions/Commit' + 404: + $ref: '#/responses/NotFound' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' + /projects/{project_identifier}/commits: + parameters: + - name: project_identifier + in: path + description: ID of the project + type: string + required: true + get: + tags: + - Commit + operationId: getCommitsInProject + summary: Get all commits in the project + produces: + - application/json + responses: + 200: + description: Ok + schema: + $ref: '#/definitions/Commit' + 404: + $ref: '#/responses/NotFound' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' + definitions: Project: type: object @@ -443,6 +578,34 @@ definitions: identifier: type: string format: uuid + Commit: + type: object + properties: + '@type': + type: string + enum: + - 'Commit' + changes: + type: array + items: + $ref: '#/definitions/ElementRecord' + containingProject: + $ref: '#/definitions/Identified' + identifier: + type: string + format: uuid + ElementRecord: + type: object + properties: + '@type': + type: string + enum: + - 'ElementRecord' + data: + $ref: '#/definitions/Element' + identifier: + type: string + format: uuid Error: type: object properties: From 761f7a293aa61075dd186ac5f9705529ff9e818d Mon Sep 17 00:00:00 2001 From: Ivan Gomes Date: Fri, 27 Dec 2019 19:25:01 -0800 Subject: [PATCH 02/14] ST5AS-11 Update OpenAPI spec and add Commit#previousCommit --- .../omg/sysml/versioning/impl/CommitImpl.java | 20 +++++++++++++--- .../versioning/impl/ElementIdentityImpl.java | 6 ++++- .../versioning/impl/ElementRecordImpl.java | 15 ++++++------ conf/META-INF/persistence.xml | 10 ++++++-- .../sysml/versioning/impl/CommitImpl_.java | 2 ++ .../omg/sysml/versioning/impl/Commit_.java | 23 ------------------- .../versioning/impl/ElementIdentity_.java | 13 ----------- .../sysml/versioning/impl/ElementRecord_.java | 16 ------------- .../omg/sysml/versioning/impl/Record_.java | 17 -------------- public/swagger/openapi.yaml | 16 +++++++++++-- 10 files changed, 53 insertions(+), 85 deletions(-) delete mode 100644 generated/org/omg/sysml/versioning/impl/Commit_.java delete mode 100644 generated/org/omg/sysml/versioning/impl/ElementIdentity_.java delete mode 100644 generated/org/omg/sysml/versioning/impl/ElementRecord_.java delete mode 100644 generated/org/omg/sysml/versioning/impl/Record_.java diff --git a/app/org/omg/sysml/versioning/impl/CommitImpl.java b/app/org/omg/sysml/versioning/impl/CommitImpl.java index c37550e2..ccb81217 100644 --- a/app/org/omg/sysml/versioning/impl/CommitImpl.java +++ b/app/org/omg/sysml/versioning/impl/CommitImpl.java @@ -16,12 +16,10 @@ @Entity(name = "Commit") public class CommitImpl extends RecordImpl implements Commit { - @JsonProperty("@type") - private final String type = Commit.class.getSimpleName(); - private Project containingProject; private Set changes; private ZonedDateTime timestamp; + private Commit previousCommit; @Override @ManyToOne(targetEntity = ProjectImpl.class, fetch = FetchType.LAZY) @@ -56,4 +54,20 @@ public ZonedDateTime getTimestamp() { public void setTimestamp(ZonedDateTime timestamp) { this.timestamp = timestamp; } + + @ManyToOne(targetEntity = CommitImpl.class, fetch = FetchType.LAZY) + @JsonDeserialize(as = CommitImpl.class) + public Commit getPreviousCommit() { + return previousCommit; + } + + public void setPreviousCommit(Commit previousCommit) { + this.previousCommit = previousCommit; + } + + @Transient + @JsonProperty("@type") + public String getType() { + return Commit.class.getSimpleName(); + } } diff --git a/app/org/omg/sysml/versioning/impl/ElementIdentityImpl.java b/app/org/omg/sysml/versioning/impl/ElementIdentityImpl.java index 95135f76..2457f502 100644 --- a/app/org/omg/sysml/versioning/impl/ElementIdentityImpl.java +++ b/app/org/omg/sysml/versioning/impl/ElementIdentityImpl.java @@ -5,10 +5,14 @@ import org.omg.sysml.versioning.ElementIdentity; import javax.persistence.Entity; +import javax.persistence.Transient; @Entity(name = "ElementIdentity") @JsonTypeName(value = "ElementIdentity") public class ElementIdentityImpl extends RecordImpl implements ElementIdentity { + @Transient @JsonProperty("@type") - private final String type = ElementIdentity.class.getSimpleName(); + public String getType() { + return ElementIdentity.class.getSimpleName(); + } } diff --git a/app/org/omg/sysml/versioning/impl/ElementRecordImpl.java b/app/org/omg/sysml/versioning/impl/ElementRecordImpl.java index 8f60ad84..97099119 100644 --- a/app/org/omg/sysml/versioning/impl/ElementRecordImpl.java +++ b/app/org/omg/sysml/versioning/impl/ElementRecordImpl.java @@ -5,23 +5,16 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import org.hibernate.annotations.Any; -import org.hibernate.annotations.CascadeType; import org.omg.sysml.metamodel.MofObject; import org.omg.sysml.metamodel.impl.MofObjectImpl; import org.omg.sysml.versioning.ElementIdentity; import org.omg.sysml.versioning.ElementRecord; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import javax.persistence.*; @Entity(name = "ElementRecord") @JsonTypeName(value = "ElementRecord") public class ElementRecordImpl extends RecordImpl implements ElementRecord { - @JsonProperty("@type") - private final String type = ElementRecord.class.getSimpleName(); - private MofObject data; private ElementIdentity identity; @@ -47,4 +40,10 @@ public ElementIdentity getIdentity() { public void setIdentity(ElementIdentity identity) { this.identity = identity; } + + @Transient + @JsonProperty("@type") + public static String getType() { + return ElementRecord.class.getSimpleName(); + } } diff --git a/conf/META-INF/persistence.xml b/conf/META-INF/persistence.xml index 58694970..bc584f03 100644 --- a/conf/META-INF/persistence.xml +++ b/conf/META-INF/persistence.xml @@ -103,7 +103,13 @@ org.omg.sysml.extension.impl org.omg.sysml.extension.impl.ProjectImpl - + + org.omg.sysml.versioning.impl + org.omg.sysml.versioning.impl.CommitImpl + org.omg.sysml.versioning.impl.ElementIdentityImpl + org.omg.sysml.versioning.impl.ElementRecordImpl + org.omg.sysml.versioning.impl.RecordImpl + @@ -111,7 +117,7 @@ - + diff --git a/generated/org/omg/sysml/versioning/impl/CommitImpl_.java b/generated/org/omg/sysml/versioning/impl/CommitImpl_.java index fcab399b..fffdbd3e 100644 --- a/generated/org/omg/sysml/versioning/impl/CommitImpl_.java +++ b/generated/org/omg/sysml/versioning/impl/CommitImpl_.java @@ -12,10 +12,12 @@ public abstract class CommitImpl_ extends org.omg.sysml.versioning.impl.RecordImpl_ { public static volatile SetAttribute changes; + public static volatile SingularAttribute previousCommit; public static volatile SingularAttribute containingProject; public static volatile SingularAttribute timestamp; public static final String CHANGES = "changes"; + public static final String PREVIOUS_COMMIT = "previousCommit"; public static final String CONTAINING_PROJECT = "containingProject"; public static final String TIMESTAMP = "timestamp"; diff --git a/generated/org/omg/sysml/versioning/impl/Commit_.java b/generated/org/omg/sysml/versioning/impl/Commit_.java deleted file mode 100644 index a38f1fde..00000000 --- a/generated/org/omg/sysml/versioning/impl/Commit_.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.omg.sysml.versioning.impl; - -import java.time.ZonedDateTime; -import javax.annotation.processing.Generated; -import javax.persistence.metamodel.SetAttribute; -import javax.persistence.metamodel.SingularAttribute; -import javax.persistence.metamodel.StaticMetamodel; -import org.omg.sysml.extension.impl.ProjectImpl; - -@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") -@StaticMetamodel(Commit.class) -public abstract class Commit_ extends org.omg.sysml.versioning.impl.Record_ { - - public static volatile SetAttribute changes; - public static volatile SingularAttribute project; - public static volatile SingularAttribute timestamp; - - public static final String CHANGES = "changes"; - public static final String PROJECT = "project"; - public static final String TIMESTAMP = "timestamp"; - -} - diff --git a/generated/org/omg/sysml/versioning/impl/ElementIdentity_.java b/generated/org/omg/sysml/versioning/impl/ElementIdentity_.java deleted file mode 100644 index fc509984..00000000 --- a/generated/org/omg/sysml/versioning/impl/ElementIdentity_.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.omg.sysml.versioning.impl; - -import javax.annotation.processing.Generated; -import javax.persistence.metamodel.StaticMetamodel; - -@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") -@StaticMetamodel(ElementIdentityImpl.class) -public abstract class ElementIdentity_ extends org.omg.sysml.versioning.impl.Record_ { - - - -} - diff --git a/generated/org/omg/sysml/versioning/impl/ElementRecord_.java b/generated/org/omg/sysml/versioning/impl/ElementRecord_.java deleted file mode 100644 index 7203faac..00000000 --- a/generated/org/omg/sysml/versioning/impl/ElementRecord_.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.omg.sysml.versioning.impl; - -import javax.annotation.processing.Generated; -import javax.persistence.metamodel.SingularAttribute; -import javax.persistence.metamodel.StaticMetamodel; - -@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") -@StaticMetamodel(ElementRecordImpl.class) -public abstract class ElementRecord_ extends org.omg.sysml.versioning.impl.Record_ { - - public static volatile SingularAttribute identity; - - public static final String IDENTITY = "identity"; - -} - diff --git a/generated/org/omg/sysml/versioning/impl/Record_.java b/generated/org/omg/sysml/versioning/impl/Record_.java deleted file mode 100644 index f8dbd9c5..00000000 --- a/generated/org/omg/sysml/versioning/impl/Record_.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.omg.sysml.versioning.impl; - -import java.util.UUID; -import javax.annotation.processing.Generated; -import javax.persistence.metamodel.SingularAttribute; -import javax.persistence.metamodel.StaticMetamodel; - -@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") -@StaticMetamodel(RecordImpl.class) -public abstract class Record_ { - - public static volatile SingularAttribute id; - - public static final String ID = "id"; - -} - diff --git a/public/swagger/openapi.yaml b/public/swagger/openapi.yaml index c8acdf66..e0559a05 100644 --- a/public/swagger/openapi.yaml +++ b/public/swagger/openapi.yaml @@ -591,7 +591,7 @@ definitions: $ref: '#/definitions/ElementRecord' containingProject: $ref: '#/definitions/Identified' - identifier: + id: type: string format: uuid ElementRecord: @@ -603,7 +603,19 @@ definitions: - 'ElementRecord' data: $ref: '#/definitions/Element' - identifier: + id: + type: string + format: uuid + identity: + $ref: '#/definitions/ElementIdentity' + ElementIdentity: + type: object + properties: + '@type': + type: string + enum: + - 'ElementIdentity' + id: type: string format: uuid Error: From c1546faa3bdcb25aad988259ee7c707f44a8c69b Mon Sep 17 00:00:00 2001 From: Ivan Gomes Date: Mon, 30 Dec 2019 01:06:44 -0800 Subject: [PATCH 03/14] ST5AS-11 Implement getElementsByCommit and getElementByCommitIdAndId endpoints --- app/controllers/ElementController.java | 14 ++++++ app/dao/ElementDao.java | 6 +++ app/dao/impl/jpa/JpaElementDao.java | 64 ++++++++++++++++++++++-- app/org/omg/sysml/versioning/Commit.java | 2 + app/services/ElementService.java | 17 +++++-- conf/routes | 44 ++++++++-------- public/swagger/openapi.yaml | 59 ++++++++++++++++++++++ 7 files changed, 178 insertions(+), 28 deletions(-) diff --git a/app/controllers/ElementController.java b/app/controllers/ElementController.java index 1b034e16..9d652c64 100644 --- a/app/controllers/ElementController.java +++ b/app/controllers/ElementController.java @@ -15,6 +15,7 @@ import javax.inject.Inject; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.UUID; /** @@ -56,10 +57,23 @@ public Result byProject(String projectId) { return ok(JacksonHelper.collectionValueToTree(List.class, metamodelProvider.getImplementationClass(Element.class), elements)); } + public Result byCommit(String commitId) { + UUID commitUuid = UUID.fromString(commitId); + Set elements = elementService.getByCommitId(commitUuid); + return ok(JacksonHelper.collectionValueToTree(Set.class, metamodelProvider.getImplementationClass(Element.class), elements)); + } + public Result byProjectAndId(String elementId, String projectId) { UUID elementUuid = UUID.fromString(elementId); UUID projectUuid = UUID.fromString(projectId); Optional element = elementService.getByProjectIdAndId(projectUuid, elementUuid); return element.map(e -> ok(Json.toJson(e))).orElseGet(Results::notFound); } + + public Result byCommitAndId(String commitId, String elementId) { + UUID commitUuid = UUID.fromString(commitId); + UUID elementUuid = UUID.fromString(elementId); + Optional element = elementService.getByCommitIdAndId(commitUuid, elementUuid); + return element.map(e -> ok(Json.toJson(e))).orElseGet(Results::notFound); + } } diff --git a/app/dao/ElementDao.java b/app/dao/ElementDao.java index f78dd88e..5235841a 100644 --- a/app/dao/ElementDao.java +++ b/app/dao/ElementDao.java @@ -2,9 +2,11 @@ import org.omg.sysml.extension.Project; import org.omg.sysml.metamodel.Element; +import org.omg.sysml.versioning.Commit; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.UUID; public interface ElementDao extends Dao { @@ -22,5 +24,9 @@ public interface ElementDao extends Dao { List findAllByProject(Project project); + Set findAllByCommit(Commit commit); + Optional findByProjectAndId(Project project, UUID id); + + Optional findByCommitAndId(Commit commit, UUID id); } diff --git a/app/dao/impl/jpa/JpaElementDao.java b/app/dao/impl/jpa/JpaElementDao.java index dba0dffa..9a0e7c3f 100644 --- a/app/dao/impl/jpa/JpaElementDao.java +++ b/app/dao/impl/jpa/JpaElementDao.java @@ -10,14 +10,14 @@ import org.omg.sysml.metamodel.Element; import org.omg.sysml.metamodel.impl.MofObjectImpl; import org.omg.sysml.metamodel.impl.MofObjectImpl_; +import org.omg.sysml.versioning.Commit; import javax.inject.Inject; import javax.inject.Singleton; import javax.persistence.NoResultException; import javax.persistence.criteria.*; -import java.util.List; -import java.util.Optional; -import java.util.UUID; +import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -83,6 +83,19 @@ public List findAllByProject(Project project) { } } + @Override + public Set findAllByCommit(Commit commit) { + return jpa.transact(em -> { + Map map = new LinkedHashMap<>(); + // TODO Commit is detached at this point. This ternary mitigates by requerying for the Commit in this transaction. A better solution would be moving transaction handling up to service layer (supported by general wisdom) and optionally migrating to using Play's @Transactional/JPAApi. Pros would include removal of repetitive transaction handling at the DAO layer and ability to interface with multiple DAOs in the same transaction (consistent view). Cons include increased temptation to keep transaction open for longer than needed, e.g. during JSON serialization due to the convenience of @Transactional (deprecated in >= 2.8.x), and the service, a higher level of abstraction, becoming aware of transactions. An alternative would be DAO-to-DAO calls (generally discouraged) and delegating to non-transactional versions of methods. + queryCommitTree(em.contains(commit) ? commit : em.find(metamodelProvider.getImplementationClass(Commit.class), commit.getId()), c -> { + c.getChanges().stream().filter(record -> record.getIdentity() != null && record.getIdentity().getId() != null && record.getData() instanceof Element).forEach(record -> map.put(record.getIdentity().getId(), map.computeIfAbsent(record.getIdentity().getId(), uuid -> (Element) record.getData()))); + return null; + }); + return new LinkedHashSet<>(map.values()); + }); + } + @Override public Optional findByProjectAndId(Project project, UUID id) { try (Session session = jpa.getEntityManagerFactory().unwrap(SessionFactory.class).openSession()) { @@ -97,6 +110,51 @@ public Optional findByProjectAndId(Project project, UUID id) { } } + /*@Override + public Optional findByCommitAndId(Commit commit, UUID id) { + return jpa.transact(em -> { + Element element = null; + Commit currentCommit = commit; + Set visitedCommits = new HashSet<>(); + while (element == null && currentCommit != null && !visitedCommits.contains(currentCommit)) { + element = currentCommit.getChanges().stream().filter(record -> record.getIdentity() != null && record.getIdentity().getId() != null && record.getData() instanceof Element).filter(record -> id.equals(record.getIdentity().getId())).map(record -> (Element) record.getData()).findAny().orElse(null); + visitedCommits.add(currentCommit); + currentCommit = currentCommit.getPreviousCommit(); + } + return Optional.ofNullable(element); + }); + }*/ + + @Override + public Optional findByCommitAndId(Commit commit, UUID id) { + return jpa.transact(em -> { + return queryCommitTree(em.contains(commit) ? commit : em.find(metamodelProvider.getImplementationClass(Commit.class), commit.getId()), c -> + c.getChanges().stream().filter(record -> record.getIdentity() != null && record.getIdentity().getId() != null && record.getData() instanceof Element).filter(record -> id.equals(record.getIdentity().getId())).map(record -> (Element) record.getData()).findAny(), + Optional::isPresent) + .values().stream().filter(Optional::isPresent).map(Optional::get).findAny(); + }); + } + + protected Map queryCommitTree(Commit commit, Function query) { + return queryCommitTree(commit, query, t -> false); + } + + protected Map queryCommitTree(Commit commit, Function query, java.util.function.Predicate terminationCondition) { + Map results = new LinkedHashMap<>(); + Commit currentCommit = commit; + Set visitedCommits = new HashSet<>(); + while (currentCommit != null && !visitedCommits.contains(currentCommit)) { + T t = query.apply(currentCommit); + results.put(currentCommit, t); + if (terminationCondition.test(t)) { + break; + } + visitedCommits.add(currentCommit); + currentCommit = currentCommit.getPreviousCommit(); + } + return results; + } + private Expression getTypeExpression(CriteriaBuilder builder, Root root) { return builder.or(metamodelProvider.getAllImplementationClasses().stream().filter(Element.class::isAssignableFrom).map(c -> builder.equal(root.type(), c)).toArray(Predicate[]::new)); } diff --git a/app/org/omg/sysml/versioning/Commit.java b/app/org/omg/sysml/versioning/Commit.java index 578c5c37..91feed22 100644 --- a/app/org/omg/sysml/versioning/Commit.java +++ b/app/org/omg/sysml/versioning/Commit.java @@ -10,6 +10,8 @@ public interface Commit extends Record { Set getChanges(); + Commit getPreviousCommit(); + ZonedDateTime getTimestamp(); void setTimestamp(ZonedDateTime timestamp); diff --git a/app/services/ElementService.java b/app/services/ElementService.java index 37ff4f32..9e2de8f1 100644 --- a/app/services/ElementService.java +++ b/app/services/ElementService.java @@ -1,15 +1,13 @@ package services; +import dao.CommitDao; import dao.ElementDao; import dao.ProjectDao; import org.omg.sysml.metamodel.Element; import javax.inject.Inject; import javax.inject.Singleton; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.UUID; +import java.util.*; @Singleton public class ElementService { @@ -19,6 +17,9 @@ public class ElementService { @Inject private ProjectDao projectDao; + @Inject + private CommitDao commitDao; + public List getAll() { return elementDao.findAll(); } @@ -31,10 +32,18 @@ public List getByProjectId(UUID projectId) { return projectDao.findById(projectId).map(m -> elementDao.findAllByProject(m)).orElse(Collections.emptyList()); } + public Set getByCommitId(UUID commitId) { + return commitDao.findById(commitId).map(c -> elementDao.findAllByCommit(c)).orElse(Collections.emptySet()); + } + public Optional getByProjectIdAndId(UUID projectId, UUID elementId) { return projectDao.findById(projectId).flatMap(m -> elementDao.findByProjectAndId(m, elementId)); } + public Optional getByCommitIdAndId(UUID commitId, UUID elementId) { + return commitDao.findById(commitId).flatMap(m -> elementDao.findByCommitAndId(m, elementId)); + } + public Optional create(Element element) { return element.getIdentifier() != null ? elementDao.update(element) : elementDao.persist(element); } diff --git a/conf/routes b/conf/routes index 5aae36ae..2734b590 100644 --- a/conf/routes +++ b/conf/routes @@ -3,40 +3,42 @@ # ~~~~ # An example controller showing a sample home page -GET / controllers.HomeController.index +GET / controllers.HomeController.index # Project endpoints -GET /projects controllers.ProjectController.all() -GET /projects/:id controllers.ProjectController.byId(id : String) -POST /projects controllers.ProjectController.create(request : Request) +GET /projects controllers.ProjectController.all() +GET /projects/:id controllers.ProjectController.byId(id : String) +POST /projects controllers.ProjectController.create(request : Request) # Element endpoints -GET /elements controllers.ElementController.all() -GET /elements/:id controllers.ElementController.byId(id : String) -GET /projects/:mid/elements/:id controllers.ElementController.byProjectAndId(id : String, mid : String) -GET /projects/:mid/elements controllers.ElementController.byProject(mid : String) -POST /elements controllers.ElementController.create(request : Request) +GET /elements controllers.ElementController.all() +GET /elements/:id controllers.ElementController.byId(id : String) +GET /projects/:mid/elements controllers.ElementController.byProject(mid : String) +GET /commits/:commitId/elements controllers.ElementController.byCommit(commitId : String) +GET /projects/:mid/elements/:id controllers.ElementController.byProjectAndId(id : String, mid : String) +GET /commits/:commitId/elements/:elementId controllers.ElementController.byCommitAndId(commitId : String, elementId : String) +POST /elements controllers.ElementController.create(request : Request) # Commit endpoints -GET /commits controllers.CommitController.all() -GET /commits/:id controllers.CommitController.byId(id : String) -GET /projects/:mid/commits/:id controllers.CommitController.byProjectAndId(id : String, mid : String) -GET /projects/:mid/commits controllers.CommitController.byProject(mid : String) -POST /commits controllers.CommitController.create(request : Request) +GET /commits controllers.CommitController.all() +GET /commits/:id controllers.CommitController.byId(id : String) +GET /projects/:mid/commits/:id controllers.CommitController.byProjectAndId(id : String, mid : String) +GET /projects/:mid/commits controllers.CommitController.byProject(mid : String) +POST /commits controllers.CommitController.create(request : Request) # Relationship endpoints -GET /relationships/:id controllers.RelationshipController.byId(id : String) +GET /relationships/:id controllers.RelationshipController.byId(id : String) # GET /relationship/element/:id controllers.RelationshipController.byRelatedElementId(id : String) # GET /relationship/source/:id controllers.RelationshipController.bySourceElementId(id : String) # GET /relationship/source/:id/type/:type controllers.RelationshipController.bySourceElementId(id : String) # GET /relationship/target/:id controllers.RelationshipController.byTargetElementId(id : String) # GET /relationship/target/:id/type/:type controllers.RelationshipController.byTargetElementId(id : String) -GET /relationships controllers.RelationshipController.all() -GET /projects/:mid/relationships controllers.RelationshipController.byProject(mid : String) -POST /relationships controllers.RelationshipController.create(request : Request) +GET /relationships controllers.RelationshipController.all() +GET /projects/:mid/relationships controllers.RelationshipController.byProject(mid : String) +POST /relationships controllers.RelationshipController.create(request : Request) # Map static resources from the /public folder to the /assets URL path -GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset) +GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset) -GET /docs/ controllers.Assets.at(path="/public/swagger",file="index.html") -GET /docs/*file controllers.Assets.at(path="/public/swagger",file) \ No newline at end of file +GET /docs/ controllers.Assets.at(path="/public/swagger",file="index.html") +GET /docs/*file controllers.Assets.at(path="/public/swagger",file) \ No newline at end of file diff --git a/public/swagger/openapi.yaml b/public/swagger/openapi.yaml index e0559a05..31dd21b1 100644 --- a/public/swagger/openapi.yaml +++ b/public/swagger/openapi.yaml @@ -191,6 +191,65 @@ paths: $ref: '#/responses/InternalServerError' default: $ref: '#/responses/Default' + /commits/{commit_id}/elements: + parameters: + - name: commit_id + in: path + description: ID of the commit + type: string + required: true + get: + tags: + - Element + operationId: getElementsByCommitId + summary: Get elements by commit ID + produces: + - application/json + responses: + 200: + description: Ok + schema: + $ref: '#/definitions/Element' + 404: + $ref: '#/responses/NotFound' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' + /commits/{commit_id}/elements/{element_id}: + parameters: + - name: commit_id + in: path + description: ID of the commit + type: string + required: true + - name: element_id + in: path + description: ID of the element + type: string + required: true + get: + tags: + - Element + operationId: getElementByCommitIdAndId + summary: Get element by commit ID and element ID + produces: + - application/json + responses: + 200: + description: Ok + schema: + $ref: '#/definitions/Element' + 404: + $ref: '#/responses/NotFound' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' /projects/{project_identifier}/elements: parameters: - name: project_identifier From b497d87628d3fac67401062b8c350bafd81a3868 Mon Sep 17 00:00:00 2001 From: Ivan Gomes Date: Fri, 3 Jan 2020 19:13:12 -0800 Subject: [PATCH 04/14] ST5AS-11 Merge `extension` and `versioning` metamodels to `lifecycle`. Add commit contextualized endpoints. Deprecate non-contextualized endpoints. Enable JSON error responses. --- app/controllers/CommitController.java | 13 +- app/controllers/ElementController.java | 10 + app/controllers/ProjectController.java | 2 +- app/controllers/RelationshipController.java | 7 + app/dao/CommitDao.java | 4 +- app/dao/ElementDao.java | 6 +- app/dao/ProjectDao.java | 2 +- app/dao/RelationshipDao.java | 10 +- app/dao/impl/jpa/JpaCommitDao.java | 12 +- app/dao/impl/jpa/JpaElementDao.java | 21 +- app/dao/impl/jpa/JpaProjectDao.java | 6 +- app/dao/impl/jpa/JpaRelationshipDao.java | 22 +- app/jackson/JpaIdentityDeserializer.java | 54 ++ app/jackson/JpaIdentitySerializer.java | 35 ++ app/jackson/RecordSerialization.java | 71 +++ app/org/omg/sysml/extension/Project.java | 8 - .../sysml/extension/impl/package-info.java | 16 - .../{versioning => lifecycle}/Commit.java | 10 +- .../ElementIdentity.java | 2 +- .../ElementRecord.java | 2 +- app/org/omg/sysml/lifecycle/Project.java | 6 + .../{versioning => lifecycle}/Record.java | 2 +- .../impl/CommitImpl.java | 20 +- .../impl/ElementIdentityImpl.java | 4 +- .../impl/ElementRecordImpl.java | 6 +- .../impl/ProjectImpl.java | 4 +- .../impl/RecordImpl.java | 4 +- .../sysml/lifecycle/impl/package-info.java | 21 + app/org/omg/sysml/metamodel/MofObject.java | 4 +- .../sysml/metamodel/impl/MofObjectImpl.java | 10 +- app/services/CommitService.java | 7 +- app/services/ElementService.java | 8 + app/services/ProjectService.java | 2 +- app/services/RelationshipService.java | 12 + conf/META-INF/persistence.xml | 14 +- conf/application.conf | 1 + conf/routes | 60 ++- .../impl/CommitImpl_.java | 5 +- .../impl/ElementIdentityImpl_.java | 4 +- .../impl/ElementRecordImpl_.java | 4 +- .../impl/ProjectImpl_.java | 2 +- .../impl/RecordImpl_.java | 2 +- public/swagger/openapi.yaml | 488 +++++++++++------- 43 files changed, 689 insertions(+), 314 deletions(-) create mode 100644 app/jackson/JpaIdentityDeserializer.java create mode 100644 app/jackson/JpaIdentitySerializer.java create mode 100644 app/jackson/RecordSerialization.java delete mode 100644 app/org/omg/sysml/extension/Project.java delete mode 100644 app/org/omg/sysml/extension/impl/package-info.java rename app/org/omg/sysml/{versioning => lifecycle}/Commit.java (60%) rename app/org/omg/sysml/{versioning => lifecycle}/ElementIdentity.java (60%) rename app/org/omg/sysml/{versioning => lifecycle}/ElementRecord.java (82%) create mode 100644 app/org/omg/sysml/lifecycle/Project.java rename app/org/omg/sysml/{versioning => lifecycle}/Record.java (67%) rename app/org/omg/sysml/{versioning => lifecycle}/impl/CommitImpl.java (72%) rename app/org/omg/sysml/{versioning => lifecycle}/impl/ElementIdentityImpl.java (84%) rename app/org/omg/sysml/{versioning => lifecycle}/impl/ElementRecordImpl.java (92%) rename app/org/omg/sysml/{extension => lifecycle}/impl/ProjectImpl.java (96%) rename app/org/omg/sysml/{versioning => lifecycle}/impl/RecordImpl.java (84%) create mode 100644 app/org/omg/sysml/lifecycle/impl/package-info.java rename generated/org/omg/sysml/{versioning => lifecycle}/impl/CommitImpl_.java (83%) rename generated/org/omg/sysml/{versioning => lifecycle}/impl/ElementIdentityImpl_.java (80%) rename generated/org/omg/sysml/{versioning => lifecycle}/impl/ElementRecordImpl_.java (76%) rename generated/org/omg/sysml/{extension => lifecycle}/impl/ProjectImpl_.java (92%) rename generated/org/omg/sysml/{versioning => lifecycle}/impl/RecordImpl_.java (91%) diff --git a/app/controllers/CommitController.java b/app/controllers/CommitController.java index 9639d48c..9bc7a7b4 100644 --- a/app/controllers/CommitController.java +++ b/app/controllers/CommitController.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.databind.JsonNode; import config.MetamodelProvider; import jackson.JacksonHelper; -import org.omg.sysml.versioning.Commit; +import org.omg.sysml.lifecycle.Commit; import play.libs.Json; import play.mvc.Controller; import play.mvc.Http; @@ -46,6 +46,17 @@ public Result create(Http.Request request) { return responseCommit.map(e -> created(Json.toJson(e))).orElseGet(Results::internalServerError); } + public Result createWithProjectId(UUID projectId, Http.Request request) { + JsonNode requestBodyJson = request.body().asJson(); + Commit requestedObject = Json.fromJson(requestBodyJson, metamodelProvider.getImplementationClass(Commit.class)); + if (requestedObject.getId() != null || requestedObject.getTimestamp() != null) { + return Results.badRequest(); + } + requestedObject.setTimestamp(ZonedDateTime.now()); + Optional responseCommit = commitService.create(projectId, requestedObject); + return responseCommit.map(e -> created(Json.toJson(e))).orElseGet(Results::internalServerError); + } + public Result byProject(String projectId) { UUID projectUuid = UUID.fromString(projectId); List commits = commitService.getByProjectId(projectUuid); diff --git a/app/controllers/ElementController.java b/app/controllers/ElementController.java index 9d652c64..bae3e58e 100644 --- a/app/controllers/ElementController.java +++ b/app/controllers/ElementController.java @@ -76,4 +76,14 @@ public Result byCommitAndId(String commitId, String elementId) { Optional element = elementService.getByCommitIdAndId(commitUuid, elementUuid); return element.map(e -> ok(Json.toJson(e))).orElseGet(Results::notFound); } + + public Result getElementsByProjectIdCommitId(UUID projectId, UUID commitId) { + Set elements = elementService.getElementsByProjectIdCommitId(projectId, commitId); + return ok(JacksonHelper.collectionValueToTree(Set.class, metamodelProvider.getImplementationClass(Element.class), elements)); + } + + public Result getElementByProjectIdCommitIdElementId(UUID projectId, UUID commitId, UUID elementId) { + Optional element = elementService.getElementsByProjectIdCommitIdElementId(projectId, commitId, elementId); + return element.map(e -> ok(Json.toJson(e))).orElseGet(Results::notFound); + } } diff --git a/app/controllers/ProjectController.java b/app/controllers/ProjectController.java index 7a0d0643..ce3708e4 100644 --- a/app/controllers/ProjectController.java +++ b/app/controllers/ProjectController.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.databind.JsonNode; import config.MetamodelProvider; import jackson.JacksonHelper; -import org.omg.sysml.extension.Project; +import org.omg.sysml.lifecycle.Project; import play.libs.Json; import play.mvc.Controller; import play.mvc.Http; diff --git a/app/controllers/RelationshipController.java b/app/controllers/RelationshipController.java index 40447429..8336d8d3 100644 --- a/app/controllers/RelationshipController.java +++ b/app/controllers/RelationshipController.java @@ -15,6 +15,7 @@ import javax.inject.Inject; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.UUID; /** @@ -73,4 +74,10 @@ public Result byProject(String projectId) { List relationships = relationshipService.getByProjectId(projectUuid); return ok(JacksonHelper.collectionValueToTree(List.class, metamodelProvider.getImplementationClass(Relationship.class), relationships)); } + + public Result getRelationshipsByProjectIdCommitIdRelatedElementId(UUID projectId, UUID commitId, UUID elementId) { + System.out.println(projectId + " : " + commitId + " : " + elementId); + Set relationships = relationshipService.getRelationshipsByProjectCommitRelatedElement(projectId, commitId, elementId); + return ok(JacksonHelper.collectionValueToTree(Set.class, metamodelProvider.getImplementationClass(Relationship.class), relationships)); + } } diff --git a/app/dao/CommitDao.java b/app/dao/CommitDao.java index c1c593eb..fa2ceb22 100644 --- a/app/dao/CommitDao.java +++ b/app/dao/CommitDao.java @@ -1,7 +1,7 @@ package dao; -import org.omg.sysml.extension.Project; -import org.omg.sysml.versioning.Commit; +import org.omg.sysml.lifecycle.Project; +import org.omg.sysml.lifecycle.Commit; import java.util.List; import java.util.Optional; diff --git a/app/dao/ElementDao.java b/app/dao/ElementDao.java index 5235841a..77e12659 100644 --- a/app/dao/ElementDao.java +++ b/app/dao/ElementDao.java @@ -1,8 +1,8 @@ package dao; -import org.omg.sysml.extension.Project; +import org.omg.sysml.lifecycle.Project; import org.omg.sysml.metamodel.Element; -import org.omg.sysml.versioning.Commit; +import org.omg.sysml.lifecycle.Commit; import java.util.List; import java.util.Optional; @@ -22,10 +22,12 @@ public interface ElementDao extends Dao { void deleteAll(); + @Deprecated List findAllByProject(Project project); Set findAllByCommit(Commit commit); + @Deprecated Optional findByProjectAndId(Project project, UUID id); Optional findByCommitAndId(Commit commit, UUID id); diff --git a/app/dao/ProjectDao.java b/app/dao/ProjectDao.java index ec91372b..5276570e 100644 --- a/app/dao/ProjectDao.java +++ b/app/dao/ProjectDao.java @@ -1,6 +1,6 @@ package dao; -import org.omg.sysml.extension.Project; +import org.omg.sysml.lifecycle.Project; import java.util.List; import java.util.Optional; diff --git a/app/dao/RelationshipDao.java b/app/dao/RelationshipDao.java index 98fcad7b..2e99d6ce 100644 --- a/app/dao/RelationshipDao.java +++ b/app/dao/RelationshipDao.java @@ -1,11 +1,13 @@ package dao; -import org.omg.sysml.extension.Project; +import org.omg.sysml.lifecycle.Commit; +import org.omg.sysml.lifecycle.Project; import org.omg.sysml.metamodel.Element; import org.omg.sysml.metamodel.Relationship; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.UUID; public interface RelationshipDao extends Dao { @@ -21,11 +23,17 @@ public interface RelationshipDao extends Dao { void deleteAll(); + @Deprecated List findAllByRelatedElement(Element element); + @Deprecated List findAllBySourceElement(Element element); + @Deprecated List findAllByTargetElement(Element element); + @Deprecated List findAllByProject(Project project); + + Set findAllByCommitRelatedElement(Commit commit, Element relatedElement); } diff --git a/app/dao/impl/jpa/JpaCommitDao.java b/app/dao/impl/jpa/JpaCommitDao.java index 0ead30c5..378f71e2 100644 --- a/app/dao/impl/jpa/JpaCommitDao.java +++ b/app/dao/impl/jpa/JpaCommitDao.java @@ -2,13 +2,13 @@ import dao.CommitDao; import jpa.manager.JPAManager; -import org.omg.sysml.extension.Project; +import org.omg.sysml.lifecycle.Project; import org.omg.sysml.metamodel.impl.MofObjectImpl; -import org.omg.sysml.versioning.Commit; -import org.omg.sysml.versioning.impl.CommitImpl; -import org.omg.sysml.versioning.impl.CommitImpl_; -import org.omg.sysml.versioning.impl.ElementIdentityImpl; -import org.omg.sysml.versioning.impl.ElementRecordImpl; +import org.omg.sysml.lifecycle.Commit; +import org.omg.sysml.lifecycle.impl.CommitImpl; +import org.omg.sysml.lifecycle.impl.CommitImpl_; +import org.omg.sysml.lifecycle.impl.ElementIdentityImpl; +import org.omg.sysml.lifecycle.impl.ElementRecordImpl; import javax.inject.Inject; import javax.inject.Singleton; diff --git a/app/dao/impl/jpa/JpaElementDao.java b/app/dao/impl/jpa/JpaElementDao.java index 9a0e7c3f..33a5b14d 100644 --- a/app/dao/impl/jpa/JpaElementDao.java +++ b/app/dao/impl/jpa/JpaElementDao.java @@ -6,11 +6,13 @@ import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.query.Query; -import org.omg.sysml.extension.Project; +import org.omg.sysml.lifecycle.ElementRecord; +import org.omg.sysml.lifecycle.Project; import org.omg.sysml.metamodel.Element; +import org.omg.sysml.metamodel.MofObject; import org.omg.sysml.metamodel.impl.MofObjectImpl; import org.omg.sysml.metamodel.impl.MofObjectImpl_; -import org.omg.sysml.versioning.Commit; +import org.omg.sysml.lifecycle.Commit; import javax.inject.Inject; import javax.inject.Singleton; @@ -86,13 +88,9 @@ public List findAllByProject(Project project) { @Override public Set findAllByCommit(Commit commit) { return jpa.transact(em -> { - Map map = new LinkedHashMap<>(); // TODO Commit is detached at this point. This ternary mitigates by requerying for the Commit in this transaction. A better solution would be moving transaction handling up to service layer (supported by general wisdom) and optionally migrating to using Play's @Transactional/JPAApi. Pros would include removal of repetitive transaction handling at the DAO layer and ability to interface with multiple DAOs in the same transaction (consistent view). Cons include increased temptation to keep transaction open for longer than needed, e.g. during JSON serialization due to the convenience of @Transactional (deprecated in >= 2.8.x), and the service, a higher level of abstraction, becoming aware of transactions. An alternative would be DAO-to-DAO calls (generally discouraged) and delegating to non-transactional versions of methods. - queryCommitTree(em.contains(commit) ? commit : em.find(metamodelProvider.getImplementationClass(Commit.class), commit.getId()), c -> { - c.getChanges().stream().filter(record -> record.getIdentity() != null && record.getIdentity().getId() != null && record.getData() instanceof Element).forEach(record -> map.put(record.getIdentity().getId(), map.computeIfAbsent(record.getIdentity().getId(), uuid -> (Element) record.getData()))); - return null; - }); - return new LinkedHashSet<>(map.values()); + Commit c = em.contains(commit) ? commit : em.find(metamodelProvider.getImplementationClass(Commit.class), commit.getId()); + return streamFlattenedElements(c).collect(Collectors.toSet()); }); } @@ -155,6 +153,13 @@ protected Map queryCommitTree(Commit commit, Function return results; } + protected Stream streamFlattenedElements(Commit commit) { + Set visitedElements = new HashSet<>(); + Map> results = queryCommitTree(commit, + c -> c.getChanges().stream().filter(record -> record.getIdentity() != null && record.getIdentity().getId() != null && record.getData() instanceof Element).filter(record -> !visitedElements.contains(record.getIdentity().getId())).peek(record -> visitedElements.add(record.getIdentity().getId())).map(record -> (Element) record.getData())); + return results.values().stream().flatMap(Function.identity()); + } + private Expression getTypeExpression(CriteriaBuilder builder, Root root) { return builder.or(metamodelProvider.getAllImplementationClasses().stream().filter(Element.class::isAssignableFrom).map(c -> builder.equal(root.type(), c)).toArray(Predicate[]::new)); } diff --git a/app/dao/impl/jpa/JpaProjectDao.java b/app/dao/impl/jpa/JpaProjectDao.java index 6bb0b43c..cff90d5e 100644 --- a/app/dao/impl/jpa/JpaProjectDao.java +++ b/app/dao/impl/jpa/JpaProjectDao.java @@ -2,9 +2,9 @@ import dao.ProjectDao; import jpa.manager.JPAManager; -import org.omg.sysml.extension.Project; -import org.omg.sysml.extension.impl.ProjectImpl; -import org.omg.sysml.extension.impl.ProjectImpl_; +import org.omg.sysml.lifecycle.Project; +import org.omg.sysml.lifecycle.impl.ProjectImpl; +import org.omg.sysml.lifecycle.impl.ProjectImpl_; import javax.inject.Inject; import javax.inject.Singleton; diff --git a/app/dao/impl/jpa/JpaRelationshipDao.java b/app/dao/impl/jpa/JpaRelationshipDao.java index ecd09ea7..cee5c005 100644 --- a/app/dao/impl/jpa/JpaRelationshipDao.java +++ b/app/dao/impl/jpa/JpaRelationshipDao.java @@ -1,11 +1,13 @@ package dao.impl.jpa; import config.MetamodelProvider; +import dao.ElementDao; import dao.RelationshipDao; import jpa.manager.JPAManager; import org.hibernate.Session; import org.hibernate.SessionFactory; -import org.omg.sysml.extension.Project; +import org.omg.sysml.lifecycle.Commit; +import org.omg.sysml.lifecycle.Project; import org.omg.sysml.metamodel.Element; import org.omg.sysml.metamodel.Relationship; import org.omg.sysml.metamodel.impl.MofObjectImpl; @@ -15,10 +17,7 @@ import javax.inject.Singleton; import javax.persistence.NoResultException; import javax.persistence.criteria.*; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -30,6 +29,8 @@ public class JpaRelationshipDao extends JpaDao implements Relation @Inject private JPAManager jpa; + private JpaElementDao elementDao = new JpaElementDao(); + @Override protected JPAManager getJpaManager() { return jpa; @@ -175,6 +176,17 @@ public List findAllByProject(Project project) { } } + @Override + public Set findAllByCommitRelatedElement(Commit commit, Element relatedElement) { + return jpa.transact(em -> { + // TODO Commit is detached at this point. This ternary mitigates by requerying for the Commit in this transaction. A better solution would be moving transaction handling up to service layer (supported by general wisdom) and optionally migrating to using Play's @Transactional/JPAApi. Pros would include removal of repetitive transaction handling at the DAO layer and ability to interface with multiple DAOs in the same transaction (consistent view). Cons include increased temptation to keep transaction open for longer than needed, e.g. during JSON serialization due to the convenience of @Transactional (deprecated in >= 2.8.x), and the service, a higher level of abstraction, becoming aware of transactions. An alternative would be DAO-to-DAO calls (generally discouraged) and delegating to non-transactional versions of methods. + Commit c = em.contains(commit) ? commit : em.find(metamodelProvider.getImplementationClass(Commit.class), commit.getId()); + return elementDao.streamFlattenedElements(c).peek(System.out::println).filter(e -> e instanceof Relationship).map(e -> (Relationship) e) + .filter(relationship -> Stream.concat(relationship.getSource().stream(), relationship.getTarget().stream()).map(Element::getIdentifier).anyMatch(id -> id.equals(relatedElement.getIdentifier()))) + .collect(Collectors.toSet()); + }); + } + private Stream> getTypeStream() { return metamodelProvider.getAllImplementationClasses().stream().filter(Relationship.class::isAssignableFrom); } diff --git a/app/jackson/JpaIdentityDeserializer.java b/app/jackson/JpaIdentityDeserializer.java new file mode 100644 index 00000000..51435b48 --- /dev/null +++ b/app/jackson/JpaIdentityDeserializer.java @@ -0,0 +1,54 @@ +package jackson; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; + +import javax.persistence.EntityManager; +import java.io.IOException; + +public abstract class JpaIdentityDeserializer extends StdDeserializer { + private EntityManager entityManager; + + public JpaIdentityDeserializer(EntityManager entityManager) { + super((Class) null); + this.entityManager = entityManager; + } + + public JpaIdentityDeserializer() { + this(null); + } + + protected abstract boolean isIdentityField(String field); + + protected abstract T deserializeFromIdentity(JsonParser parser) throws IOException; + + @Override + public T deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + if (p.currentToken() != JsonToken.START_OBJECT) { + throw new JsonParseException(p, "Expected START_OBJECT. Received " + p.getCurrentName() + "."); + } + JsonToken token; + while ((token = p.nextToken()) != null && token != JsonToken.END_OBJECT) { + if (token == JsonToken.FIELD_NAME && isIdentityField(p.getCurrentName())) { + if (p.nextToken() == null) { + throw new JsonParseException(p, "No value for identity field."); + } + return deserializeFromIdentity(p); + } + } + return null; + } + + @Override + public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException { + return deserialize(p, ctxt); + } + + public EntityManager getEntityManager() { + return entityManager; + } +} \ No newline at end of file diff --git a/app/jackson/JpaIdentitySerializer.java b/app/jackson/JpaIdentitySerializer.java new file mode 100644 index 00000000..b06421ac --- /dev/null +++ b/app/jackson/JpaIdentitySerializer.java @@ -0,0 +1,35 @@ +package jackson; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import org.omg.sysml.metamodel.MofObject; + +import javax.persistence.PersistenceException; +import java.io.IOException; + +public abstract class JpaIdentitySerializer extends StdSerializer { + public JpaIdentitySerializer() { + this(null); + } + + public JpaIdentitySerializer(Class clazz) { + super(clazz); + } + + protected abstract String getIdentityField(); + + protected abstract Object serializeToIdentity(T t); + + @Override + public void serialize(T value, JsonGenerator gen, SerializerProvider provider) throws IOException { + Object o = serializeToIdentity(value); + if (o == null) { + gen.writeNull(); + return; + } + gen.writeStartObject(); + gen.writeObjectField(getIdentityField(), o); + gen.writeEndObject(); + } +} \ No newline at end of file diff --git a/app/jackson/RecordSerialization.java b/app/jackson/RecordSerialization.java new file mode 100644 index 00000000..d25a40b1 --- /dev/null +++ b/app/jackson/RecordSerialization.java @@ -0,0 +1,71 @@ +package jackson; + +import com.fasterxml.jackson.core.JsonParser; +import org.omg.sysml.lifecycle.Commit; +import org.omg.sysml.lifecycle.Record; +import org.omg.sysml.lifecycle.impl.CommitImpl; +import org.omg.sysml.lifecycle.impl.RecordImpl; +import org.omg.sysml.lifecycle.impl.RecordImpl_; + +import javax.persistence.EntityManager; +import javax.persistence.EntityNotFoundException; +import java.io.IOException; +import java.util.UUID; + +public class RecordSerialization { + public static class RecordSerializer extends JpaIdentitySerializer { + + @Override + protected String getIdentityField() { + return RecordImpl_.ID; + } + + @Override + protected Object serializeToIdentity(Record record) { + return record != null ? record.getId() : null; + } + } + + public static abstract class RecordDeserializer extends JpaIdentityDeserializer { + public RecordDeserializer(EntityManager entityManager) { + super(entityManager); + } + + public RecordDeserializer() { + super(); + } + + protected abstract Class getRecordClass(); + + @Override + protected boolean isIdentityField(String field) { + return RecordImpl_.ID.equals(field); + } + + @Override + @SuppressWarnings("unchecked") + protected R deserializeFromIdentity(JsonParser parser) throws IOException { + UUID id = UUID.fromString(parser.getText()); + Record record = getEntityManager().find(getRecordClass(), id); + if (record == null) { + throw new IOException(new EntityNotFoundException("Record " + id + " not found.")); + } + return (R) record; + } + } + + public static class CommitDeserializer extends RecordDeserializer { + public CommitDeserializer(EntityManager entityManager) { + super(entityManager); + } + + public CommitDeserializer() { + super(); + } + + @Override + protected Class getRecordClass() { + return CommitImpl.class; + } + } +} diff --git a/app/org/omg/sysml/extension/Project.java b/app/org/omg/sysml/extension/Project.java deleted file mode 100644 index daf66665..00000000 --- a/app/org/omg/sysml/extension/Project.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.omg.sysml.extension; - -import org.omg.sysml.metamodel.MofObject; - -public interface Project extends MofObject { - // Collection getContainedElement(); - String getName(); -} diff --git a/app/org/omg/sysml/extension/impl/package-info.java b/app/org/omg/sysml/extension/impl/package-info.java deleted file mode 100644 index 4f7d3316..00000000 --- a/app/org/omg/sysml/extension/impl/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -@AnyMetaDefs(value = { - @AnyMetaDef(name = "ProjectMetaDef", metaType = "string", idType = "java.util.UUID", - metaValues = { - @MetaValue(value = "Project", targetEntity = ProjectImpl.class), - }), -}) - -// TODO Abstract this concept to cli option -@GenericGenerators(value = { - @GenericGenerator(name = "UseExistingOrGenerateUUIDGenerator", strategy = "jpa.UseExistingOrGenerateUUIDGenerator") -}) -package org.omg.sysml.extension.impl; - -import org.hibernate.annotations.*; - -// TODO Abstract this concept to cli option \ No newline at end of file diff --git a/app/org/omg/sysml/versioning/Commit.java b/app/org/omg/sysml/lifecycle/Commit.java similarity index 60% rename from app/org/omg/sysml/versioning/Commit.java rename to app/org/omg/sysml/lifecycle/Commit.java index 91feed22..3d11bbdc 100644 --- a/app/org/omg/sysml/versioning/Commit.java +++ b/app/org/omg/sysml/lifecycle/Commit.java @@ -1,6 +1,4 @@ -package org.omg.sysml.versioning; - -import org.omg.sysml.extension.Project; +package org.omg.sysml.lifecycle; import java.time.ZonedDateTime; import java.util.Set; @@ -8,10 +6,16 @@ public interface Commit extends Record { Project getContainingProject(); + void setContainingProject(Project containingProject); + Set getChanges(); + void setChanges(Set changes); + Commit getPreviousCommit(); + void setPreviousCommit(Commit previousCommit); + ZonedDateTime getTimestamp(); void setTimestamp(ZonedDateTime timestamp); diff --git a/app/org/omg/sysml/versioning/ElementIdentity.java b/app/org/omg/sysml/lifecycle/ElementIdentity.java similarity index 60% rename from app/org/omg/sysml/versioning/ElementIdentity.java rename to app/org/omg/sysml/lifecycle/ElementIdentity.java index 80dab40d..487cc0f0 100644 --- a/app/org/omg/sysml/versioning/ElementIdentity.java +++ b/app/org/omg/sysml/lifecycle/ElementIdentity.java @@ -1,4 +1,4 @@ -package org.omg.sysml.versioning; +package org.omg.sysml.lifecycle; public interface ElementIdentity extends Record { } diff --git a/app/org/omg/sysml/versioning/ElementRecord.java b/app/org/omg/sysml/lifecycle/ElementRecord.java similarity index 82% rename from app/org/omg/sysml/versioning/ElementRecord.java rename to app/org/omg/sysml/lifecycle/ElementRecord.java index 8fba42eb..3ef8f952 100644 --- a/app/org/omg/sysml/versioning/ElementRecord.java +++ b/app/org/omg/sysml/lifecycle/ElementRecord.java @@ -1,4 +1,4 @@ -package org.omg.sysml.versioning; +package org.omg.sysml.lifecycle; import org.omg.sysml.metamodel.MofObject; diff --git a/app/org/omg/sysml/lifecycle/Project.java b/app/org/omg/sysml/lifecycle/Project.java new file mode 100644 index 00000000..41773333 --- /dev/null +++ b/app/org/omg/sysml/lifecycle/Project.java @@ -0,0 +1,6 @@ +package org.omg.sysml.lifecycle; + +public interface Project extends Record { + // Collection getContainedElement(); + String getName(); +} diff --git a/app/org/omg/sysml/versioning/Record.java b/app/org/omg/sysml/lifecycle/Record.java similarity index 67% rename from app/org/omg/sysml/versioning/Record.java rename to app/org/omg/sysml/lifecycle/Record.java index b93eb307..fcb5852a 100644 --- a/app/org/omg/sysml/versioning/Record.java +++ b/app/org/omg/sysml/lifecycle/Record.java @@ -1,4 +1,4 @@ -package org.omg.sysml.versioning; +package org.omg.sysml.lifecycle; import java.util.UUID; diff --git a/app/org/omg/sysml/versioning/impl/CommitImpl.java b/app/org/omg/sysml/lifecycle/impl/CommitImpl.java similarity index 72% rename from app/org/omg/sysml/versioning/impl/CommitImpl.java rename to app/org/omg/sysml/lifecycle/impl/CommitImpl.java index ccb81217..08343c4c 100644 --- a/app/org/omg/sysml/versioning/impl/CommitImpl.java +++ b/app/org/omg/sysml/lifecycle/impl/CommitImpl.java @@ -1,13 +1,14 @@ -package org.omg.sysml.versioning.impl; +package org.omg.sysml.lifecycle.impl; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.omg.sysml.extension.Project; -import org.omg.sysml.extension.impl.ProjectImpl; -import org.omg.sysml.versioning.Commit; -import org.omg.sysml.versioning.ElementRecord; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import jackson.MofObjectDeserializer; +import jackson.MofObjectSerializer; +import jackson.RecordSerialization; +import org.omg.sysml.lifecycle.Project; +import org.omg.sysml.lifecycle.Commit; +import org.omg.sysml.lifecycle.ElementRecord; import javax.persistence.*; import java.time.ZonedDateTime; @@ -23,10 +24,12 @@ public class CommitImpl extends RecordImpl implements Commit { @Override @ManyToOne(targetEntity = ProjectImpl.class, fetch = FetchType.LAZY) + @JsonSerialize(as = ProjectImpl.class, using = MofObjectSerializer.class) public Project getContainingProject() { return containingProject; } + @JsonDeserialize(as = ProjectImpl.class, using = MofObjectDeserializer.class) public void setContainingProject(Project containingProject) { this.containingProject = containingProject; } @@ -56,11 +59,12 @@ public void setTimestamp(ZonedDateTime timestamp) { } @ManyToOne(targetEntity = CommitImpl.class, fetch = FetchType.LAZY) - @JsonDeserialize(as = CommitImpl.class) + @JsonSerialize(as = CommitImpl.class, using = RecordSerialization.RecordSerializer.class) public Commit getPreviousCommit() { return previousCommit; } + @JsonDeserialize(as = CommitImpl.class, using = RecordSerialization.CommitDeserializer.class) public void setPreviousCommit(Commit previousCommit) { this.previousCommit = previousCommit; } diff --git a/app/org/omg/sysml/versioning/impl/ElementIdentityImpl.java b/app/org/omg/sysml/lifecycle/impl/ElementIdentityImpl.java similarity index 84% rename from app/org/omg/sysml/versioning/impl/ElementIdentityImpl.java rename to app/org/omg/sysml/lifecycle/impl/ElementIdentityImpl.java index 2457f502..3cfd9329 100644 --- a/app/org/omg/sysml/versioning/impl/ElementIdentityImpl.java +++ b/app/org/omg/sysml/lifecycle/impl/ElementIdentityImpl.java @@ -1,8 +1,8 @@ -package org.omg.sysml.versioning.impl; +package org.omg.sysml.lifecycle.impl; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeName; -import org.omg.sysml.versioning.ElementIdentity; +import org.omg.sysml.lifecycle.ElementIdentity; import javax.persistence.Entity; import javax.persistence.Transient; diff --git a/app/org/omg/sysml/versioning/impl/ElementRecordImpl.java b/app/org/omg/sysml/lifecycle/impl/ElementRecordImpl.java similarity index 92% rename from app/org/omg/sysml/versioning/impl/ElementRecordImpl.java rename to app/org/omg/sysml/lifecycle/impl/ElementRecordImpl.java index 97099119..3162739f 100644 --- a/app/org/omg/sysml/versioning/impl/ElementRecordImpl.java +++ b/app/org/omg/sysml/lifecycle/impl/ElementRecordImpl.java @@ -1,4 +1,4 @@ -package org.omg.sysml.versioning.impl; +package org.omg.sysml.lifecycle.impl; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; @@ -7,8 +7,8 @@ import org.hibernate.annotations.Any; import org.omg.sysml.metamodel.MofObject; import org.omg.sysml.metamodel.impl.MofObjectImpl; -import org.omg.sysml.versioning.ElementIdentity; -import org.omg.sysml.versioning.ElementRecord; +import org.omg.sysml.lifecycle.ElementIdentity; +import org.omg.sysml.lifecycle.ElementRecord; import javax.persistence.*; diff --git a/app/org/omg/sysml/extension/impl/ProjectImpl.java b/app/org/omg/sysml/lifecycle/impl/ProjectImpl.java similarity index 96% rename from app/org/omg/sysml/extension/impl/ProjectImpl.java rename to app/org/omg/sysml/lifecycle/impl/ProjectImpl.java index 885721ed..12de2415 100644 --- a/app/org/omg/sysml/extension/impl/ProjectImpl.java +++ b/app/org/omg/sysml/lifecycle/impl/ProjectImpl.java @@ -1,8 +1,8 @@ -package org.omg.sysml.extension.impl; +package org.omg.sysml.lifecycle.impl; import com.fasterxml.jackson.annotation.*; import org.hibernate.annotations.FetchMode; -import org.omg.sysml.extension.Project; +import org.omg.sysml.lifecycle.Project; import org.omg.sysml.metamodel.impl.MofObjectImpl; import javax.persistence.DiscriminatorValue; diff --git a/app/org/omg/sysml/versioning/impl/RecordImpl.java b/app/org/omg/sysml/lifecycle/impl/RecordImpl.java similarity index 84% rename from app/org/omg/sysml/versioning/impl/RecordImpl.java rename to app/org/omg/sysml/lifecycle/impl/RecordImpl.java index 716cf220..797908ff 100644 --- a/app/org/omg/sysml/versioning/impl/RecordImpl.java +++ b/app/org/omg/sysml/lifecycle/impl/RecordImpl.java @@ -1,6 +1,6 @@ -package org.omg.sysml.versioning.impl; +package org.omg.sysml.lifecycle.impl; -import org.omg.sysml.versioning.Record; +import org.omg.sysml.lifecycle.Record; import javax.persistence.GeneratedValue; import javax.persistence.Id; diff --git a/app/org/omg/sysml/lifecycle/impl/package-info.java b/app/org/omg/sysml/lifecycle/impl/package-info.java new file mode 100644 index 00000000..9984993d --- /dev/null +++ b/app/org/omg/sysml/lifecycle/impl/package-info.java @@ -0,0 +1,21 @@ +@AnyMetaDefs(value = { + @AnyMetaDef(name = "ProjectMetaDef", metaType = "string", idType = "java.util.UUID", + metaValues = { + @MetaValue(value = "Project", targetEntity = ProjectImpl.class), + }), + @AnyMetaDef(name = "RecordMetaDef", metaType = "string", idType = "java.util.UUID", + metaValues = { + @MetaValue(value = "Commit", targetEntity = CommitImpl.class), + @MetaValue(value = "ElementIdentity", targetEntity = ElementIdentityImpl.class), + @MetaValue(value = "ElementRecord", targetEntity = ElementRecordImpl.class), + @MetaValue(value = "Project", targetEntity = ProjectImpl.class), + @MetaValue(value = "Record", targetEntity = RecordImpl.class), + }), +}) + +@GenericGenerators(value = { + @GenericGenerator(name = "UseExistingOrGenerateUUIDGenerator", strategy = "jpa.UseExistingOrGenerateUUIDGenerator") +}) +package org.omg.sysml.lifecycle.impl; + +import org.hibernate.annotations.*; \ No newline at end of file diff --git a/app/org/omg/sysml/metamodel/MofObject.java b/app/org/omg/sysml/metamodel/MofObject.java index b16daece..19bbee47 100644 --- a/app/org/omg/sysml/metamodel/MofObject.java +++ b/app/org/omg/sysml/metamodel/MofObject.java @@ -1,9 +1,11 @@ package org.omg.sysml.metamodel; +import org.omg.sysml.lifecycle.Project; + public interface MofObject { java.util.UUID getId(); // TODO Remove temporary modification for prototyping Project concept - org.omg.sysml.extension.Project getContainingProject(); + Project getContainingProject(); } \ No newline at end of file diff --git a/app/org/omg/sysml/metamodel/impl/MofObjectImpl.java b/app/org/omg/sysml/metamodel/impl/MofObjectImpl.java index 53c9b960..237c5b8b 100644 --- a/app/org/omg/sysml/metamodel/impl/MofObjectImpl.java +++ b/app/org/omg/sysml/metamodel/impl/MofObjectImpl.java @@ -2,6 +2,8 @@ import com.fasterxml.jackson.annotation.*; +import org.omg.sysml.lifecycle.Project; +import org.omg.sysml.lifecycle.impl.ProjectImpl; import org.omg.sysml.metamodel.MofObject; //import info.archinnov.achilles.annotations.PartitionKey; @@ -41,19 +43,19 @@ public void setId(java.util.UUID id) { // TODO Remove temporary modification for prototyping Project concept - private org.omg.sysml.extension.Project containingProject; + private Project containingProject; @JsonGetter @JsonSerialize(using = MofObjectSerializer.class) @Any(metaDef = "ProjectMetaDef", metaColumn = @javax.persistence.Column(name = "containingProjectType"), fetch = FetchType.LAZY) @JoinColumn(name = "containingProjectId", table = "MofObject") - public org.omg.sysml.extension.Project getContainingProject() { + public Project getContainingProject() { return containingProject; } @JsonSetter - @JsonDeserialize(using = MofObjectDeserializer.class, as = org.omg.sysml.extension.impl.ProjectImpl.class) - public void setContainingProject(org.omg.sysml.extension.Project containingProject) { + @JsonDeserialize(using = MofObjectDeserializer.class, as = ProjectImpl.class) + public void setContainingProject(Project containingProject) { this.containingProject = containingProject; } diff --git a/app/services/CommitService.java b/app/services/CommitService.java index 08003947..07df9048 100644 --- a/app/services/CommitService.java +++ b/app/services/CommitService.java @@ -2,7 +2,7 @@ import dao.CommitDao; import dao.ProjectDao; -import org.omg.sysml.versioning.Commit; +import org.omg.sysml.lifecycle.Commit; import javax.inject.Inject; import javax.inject.Singleton; @@ -38,4 +38,9 @@ public Optional getByProjectIdAndId(UUID projectId, UUID commitId) { public Optional create(Commit commit) { return commit.getId() != null ? commitDao.update(commit) : commitDao.persist(commit); } + + public Optional create(UUID projectId, Commit commit) { + commit.setContainingProject(projectDao.findById(projectId).orElseThrow(() -> new IllegalArgumentException("Project " + projectId + " not found."))); + return create(commit); + } } diff --git a/app/services/ElementService.java b/app/services/ElementService.java index 9e2de8f1..92aac070 100644 --- a/app/services/ElementService.java +++ b/app/services/ElementService.java @@ -47,4 +47,12 @@ public Optional getByCommitIdAndId(UUID commitId, UUID elementId) { public Optional create(Element element) { return element.getIdentifier() != null ? elementDao.update(element) : elementDao.persist(element); } + + public Set getElementsByProjectIdCommitId(UUID projectId, UUID commitId) { + return projectDao.findById(projectId).flatMap(project -> commitDao.findByProjectAndId(project, commitId)).map(commit -> elementDao.findAllByCommit(commit)).orElse(Collections.emptySet()); + } + + public Optional getElementsByProjectIdCommitIdElementId(UUID projectId, UUID commitId, UUID elementId) { + return projectDao.findById(projectId).flatMap(project -> commitDao.findByProjectAndId(project, commitId)).flatMap(commit -> elementDao.findByCommitAndId(commit, elementId)); + } } diff --git a/app/services/ProjectService.java b/app/services/ProjectService.java index 226b9c7d..1e03ff8e 100644 --- a/app/services/ProjectService.java +++ b/app/services/ProjectService.java @@ -1,7 +1,7 @@ package services; import dao.ProjectDao; -import org.omg.sysml.extension.Project; +import org.omg.sysml.lifecycle.Project; import javax.inject.Inject; import javax.inject.Singleton; diff --git a/app/services/RelationshipService.java b/app/services/RelationshipService.java index 1eeca97a..7708b099 100644 --- a/app/services/RelationshipService.java +++ b/app/services/RelationshipService.java @@ -1,9 +1,12 @@ package services; +import dao.CommitDao; import dao.ElementDao; import dao.ProjectDao; import dao.RelationshipDao; +import org.omg.sysml.lifecycle.Commit; +import org.omg.sysml.metamodel.Element; import org.omg.sysml.metamodel.Relationship; import javax.inject.Inject; @@ -21,6 +24,9 @@ public class RelationshipService { @Inject private ProjectDao projectDao; + @Inject + private CommitDao commitDao; + public List getAll() { return relationshipDao.findAll(); } @@ -48,4 +54,10 @@ public List getByTargetElementId(UUID elementId) { public List getByProjectId(UUID projectId) { return projectDao.findById(projectId).map(m -> relationshipDao.findAllByProject(m)).orElse(Collections.emptyList()); } + + public Set getRelationshipsByProjectCommitRelatedElement(UUID projectId, UUID commitId, UUID relatedElementId) { + Commit commit = projectDao.findById(projectId).flatMap(project -> commitDao.findByProjectAndId(project, commitId)).orElseThrow(() -> new IllegalArgumentException("Commit " + commitId + " not found.")); + Element relatedElement = elementDao.findByCommitAndId(commit, relatedElementId).orElseThrow(() -> new IllegalArgumentException("Element " + relatedElementId + " not found.")); + return relationshipDao.findAllByCommitRelatedElement(commit, relatedElement); + } } diff --git a/conf/META-INF/persistence.xml b/conf/META-INF/persistence.xml index bc584f03..e72e4b07 100644 --- a/conf/META-INF/persistence.xml +++ b/conf/META-INF/persistence.xml @@ -101,14 +101,12 @@ org.omg.sysml.metamodel.impl.ValuePropertyImpl org.omg.sysml.metamodel.impl.ValueTypeImpl - org.omg.sysml.extension.impl - org.omg.sysml.extension.impl.ProjectImpl - - org.omg.sysml.versioning.impl - org.omg.sysml.versioning.impl.CommitImpl - org.omg.sysml.versioning.impl.ElementIdentityImpl - org.omg.sysml.versioning.impl.ElementRecordImpl - org.omg.sysml.versioning.impl.RecordImpl + org.omg.sysml.lifecycle.impl + org.omg.sysml.lifecycle.impl.CommitImpl + org.omg.sysml.lifecycle.impl.ElementIdentityImpl + org.omg.sysml.lifecycle.impl.ElementRecordImpl + org.omg.sysml.lifecycle.impl.ProjectImpl + org.omg.sysml.lifecycle.impl.RecordImpl diff --git a/conf/application.conf b/conf/application.conf index 85ebe9d9..efb0452c 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -5,6 +5,7 @@ play.http.secret.key="whatever" play.modules.enabled += "play.modules.swagger.SwaggerModule" play.filters.headers.contentSecurityPolicy = null play.filters.disabled+=play.filters.csrf.CSRFFilter +play.http.errorHandler = play.api.http.HtmlOrJsonHttpErrorHandler # https://www.playframework.com/documentation/2.7.x/JavaJPA db.default.jndiName=DefaultDS diff --git a/conf/routes b/conf/routes index 2734b590..4ca4c81d 100644 --- a/conf/routes +++ b/conf/routes @@ -3,42 +3,46 @@ # ~~~~ # An example controller showing a sample home page -GET / controllers.HomeController.index +GET / controllers.HomeController.index # Project endpoints -GET /projects controllers.ProjectController.all() -GET /projects/:id controllers.ProjectController.byId(id : String) -POST /projects controllers.ProjectController.create(request : Request) +GET /projects controllers.ProjectController.all() +GET /projects/:id controllers.ProjectController.byId(id : String) +POST /projects controllers.ProjectController.create(request : Request) # Element endpoints -GET /elements controllers.ElementController.all() -GET /elements/:id controllers.ElementController.byId(id : String) -GET /projects/:mid/elements controllers.ElementController.byProject(mid : String) -GET /commits/:commitId/elements controllers.ElementController.byCommit(commitId : String) -GET /projects/:mid/elements/:id controllers.ElementController.byProjectAndId(id : String, mid : String) -GET /commits/:commitId/elements/:elementId controllers.ElementController.byCommitAndId(commitId : String, elementId : String) -POST /elements controllers.ElementController.create(request : Request) +GET /elements controllers.ElementController.all() +GET /elements/:id controllers.ElementController.byId(id : String) +GET /projects/:mid/elements controllers.ElementController.byProject(mid : String) +GET /commits/:commitId/elements controllers.ElementController.byCommit(commitId : String) +GET /projects/:projectId/commits/:commitId/elements controllers.ElementController.getElementsByProjectIdCommitId(projectId : java.util.UUID, commitId : java.util.UUID) +GET /projects/:mid/elements/:id controllers.ElementController.byProjectAndId(id : String, mid : String) +GET /commits/:commitId/elements/:elementId controllers.ElementController.byCommitAndId(commitId : String, elementId : String) +GET /projects/:projectId/commits/:commitId/elements/:elementId controllers.ElementController.getElementByProjectIdCommitIdElementId(projectId : java.util.UUID, commitId : java.util.UUID, elementId : java.util.UUID) +POST /elements controllers.ElementController.create(request : Request) # Commit endpoints -GET /commits controllers.CommitController.all() -GET /commits/:id controllers.CommitController.byId(id : String) -GET /projects/:mid/commits/:id controllers.CommitController.byProjectAndId(id : String, mid : String) -GET /projects/:mid/commits controllers.CommitController.byProject(mid : String) -POST /commits controllers.CommitController.create(request : Request) +GET /commits controllers.CommitController.all() +GET /commits/:id controllers.CommitController.byId(id : String) +GET /projects/:mid/commits/:id controllers.CommitController.byProjectAndId(id : String, mid : String) +GET /projects/:mid/commits controllers.CommitController.byProject(mid : String) +POST /commits controllers.CommitController.create(request : Request) +POST /projects/:projectId/commits controllers.CommitController.createWithProjectId(projectId : java.util.UUID, request : Request) # Relationship endpoints -GET /relationships/:id controllers.RelationshipController.byId(id : String) -# GET /relationship/element/:id controllers.RelationshipController.byRelatedElementId(id : String) -# GET /relationship/source/:id controllers.RelationshipController.bySourceElementId(id : String) -# GET /relationship/source/:id/type/:type controllers.RelationshipController.bySourceElementId(id : String) -# GET /relationship/target/:id controllers.RelationshipController.byTargetElementId(id : String) -# GET /relationship/target/:id/type/:type controllers.RelationshipController.byTargetElementId(id : String) -GET /relationships controllers.RelationshipController.all() -GET /projects/:mid/relationships controllers.RelationshipController.byProject(mid : String) -POST /relationships controllers.RelationshipController.create(request : Request) +GET /relationships/:id controllers.RelationshipController.byId(id : String) +# GET /relationship/element/:id controllers.RelationshipController.byRelatedElementId(id : String) +# GET /relationship/source/:id controllers.RelationshipController.bySourceElementId(id : String) +# GET /relationship/source/:id/type/:type controllers.RelationshipController.bySourceElementId(id : String) +# GET /relationship/target/:id controllers.RelationshipController.byTargetElementId(id : String) +# GET /relationship/target/:id/type/:type controllers.RelationshipController.byTargetElementId(id : String) +GET /relationships controllers.RelationshipController.all() +GET /projects/:mid/relationships controllers.RelationshipController.byProject(mid : String) +GET /projects/:projectId/commits/:commitId/elements/:relatedElementId/relationships controllers.RelationshipController.getRelationshipsByProjectIdCommitIdRelatedElementId(projectId : java.util.UUID, commitId : java.util.UUID, relatedElementId : java.util.UUID) +POST /relationships controllers.RelationshipController.create(request : Request) # Map static resources from the /public folder to the /assets URL path -GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset) +GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset) -GET /docs/ controllers.Assets.at(path="/public/swagger",file="index.html") -GET /docs/*file controllers.Assets.at(path="/public/swagger",file) \ No newline at end of file +GET /docs/ controllers.Assets.at(path="/public/swagger",file="index.html") +GET /docs/*file controllers.Assets.at(path="/public/swagger",file) \ No newline at end of file diff --git a/generated/org/omg/sysml/versioning/impl/CommitImpl_.java b/generated/org/omg/sysml/lifecycle/impl/CommitImpl_.java similarity index 83% rename from generated/org/omg/sysml/versioning/impl/CommitImpl_.java rename to generated/org/omg/sysml/lifecycle/impl/CommitImpl_.java index fffdbd3e..2be1f25c 100644 --- a/generated/org/omg/sysml/versioning/impl/CommitImpl_.java +++ b/generated/org/omg/sysml/lifecycle/impl/CommitImpl_.java @@ -1,15 +1,14 @@ -package org.omg.sysml.versioning.impl; +package org.omg.sysml.lifecycle.impl; import java.time.ZonedDateTime; import javax.annotation.processing.Generated; import javax.persistence.metamodel.SetAttribute; import javax.persistence.metamodel.SingularAttribute; import javax.persistence.metamodel.StaticMetamodel; -import org.omg.sysml.extension.impl.ProjectImpl; @Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") @StaticMetamodel(CommitImpl.class) -public abstract class CommitImpl_ extends org.omg.sysml.versioning.impl.RecordImpl_ { +public abstract class CommitImpl_ extends org.omg.sysml.lifecycle.impl.RecordImpl_ { public static volatile SetAttribute changes; public static volatile SingularAttribute previousCommit; diff --git a/generated/org/omg/sysml/versioning/impl/ElementIdentityImpl_.java b/generated/org/omg/sysml/lifecycle/impl/ElementIdentityImpl_.java similarity index 80% rename from generated/org/omg/sysml/versioning/impl/ElementIdentityImpl_.java rename to generated/org/omg/sysml/lifecycle/impl/ElementIdentityImpl_.java index d364d48b..c5abfc2b 100644 --- a/generated/org/omg/sysml/versioning/impl/ElementIdentityImpl_.java +++ b/generated/org/omg/sysml/lifecycle/impl/ElementIdentityImpl_.java @@ -1,11 +1,11 @@ -package org.omg.sysml.versioning.impl; +package org.omg.sysml.lifecycle.impl; import javax.annotation.processing.Generated; import javax.persistence.metamodel.StaticMetamodel; @Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") @StaticMetamodel(ElementIdentityImpl.class) -public abstract class ElementIdentityImpl_ extends org.omg.sysml.versioning.impl.RecordImpl_ { +public abstract class ElementIdentityImpl_ extends org.omg.sysml.lifecycle.impl.RecordImpl_ { diff --git a/generated/org/omg/sysml/versioning/impl/ElementRecordImpl_.java b/generated/org/omg/sysml/lifecycle/impl/ElementRecordImpl_.java similarity index 76% rename from generated/org/omg/sysml/versioning/impl/ElementRecordImpl_.java rename to generated/org/omg/sysml/lifecycle/impl/ElementRecordImpl_.java index 723d41d4..26d7c22b 100644 --- a/generated/org/omg/sysml/versioning/impl/ElementRecordImpl_.java +++ b/generated/org/omg/sysml/lifecycle/impl/ElementRecordImpl_.java @@ -1,4 +1,4 @@ -package org.omg.sysml.versioning.impl; +package org.omg.sysml.lifecycle.impl; import javax.annotation.processing.Generated; import javax.persistence.metamodel.SingularAttribute; @@ -6,7 +6,7 @@ @Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") @StaticMetamodel(ElementRecordImpl.class) -public abstract class ElementRecordImpl_ extends org.omg.sysml.versioning.impl.RecordImpl_ { +public abstract class ElementRecordImpl_ extends org.omg.sysml.lifecycle.impl.RecordImpl_ { public static volatile SingularAttribute identity; diff --git a/generated/org/omg/sysml/extension/impl/ProjectImpl_.java b/generated/org/omg/sysml/lifecycle/impl/ProjectImpl_.java similarity index 92% rename from generated/org/omg/sysml/extension/impl/ProjectImpl_.java rename to generated/org/omg/sysml/lifecycle/impl/ProjectImpl_.java index 11af296e..e717eb3c 100644 --- a/generated/org/omg/sysml/extension/impl/ProjectImpl_.java +++ b/generated/org/omg/sysml/lifecycle/impl/ProjectImpl_.java @@ -1,4 +1,4 @@ -package org.omg.sysml.extension.impl; +package org.omg.sysml.lifecycle.impl; import javax.annotation.processing.Generated; import javax.persistence.metamodel.SingularAttribute; diff --git a/generated/org/omg/sysml/versioning/impl/RecordImpl_.java b/generated/org/omg/sysml/lifecycle/impl/RecordImpl_.java similarity index 91% rename from generated/org/omg/sysml/versioning/impl/RecordImpl_.java rename to generated/org/omg/sysml/lifecycle/impl/RecordImpl_.java index 3581cb75..168e7b41 100644 --- a/generated/org/omg/sysml/versioning/impl/RecordImpl_.java +++ b/generated/org/omg/sysml/lifecycle/impl/RecordImpl_.java @@ -1,4 +1,4 @@ -package org.omg.sysml.versioning.impl; +package org.omg.sysml.lifecycle.impl; import java.util.UUID; import javax.annotation.processing.Generated; diff --git a/public/swagger/openapi.yaml b/public/swagger/openapi.yaml index 31dd21b1..3e820510 100644 --- a/public/swagger/openapi.yaml +++ b/public/swagger/openapi.yaml @@ -5,9 +5,13 @@ info: version: 1.0.0 tags: - name: Project + - name: Commit - name: Element - name: Relationship - - name: Commit + - name: zzProject + - name: zzCommit + - name: zzElement + - name: zzRelationship paths: /projects: @@ -15,7 +19,7 @@ paths: tags: - Project operationId: getProjects - summary: Get all projects + summary: Get projects produces: - application/json responses: @@ -34,8 +38,8 @@ paths: post: tags: - Project - operationId: createProject - summary: Add a new project + operationId: postProject + summary: Create project consumes: - application/json produces: @@ -56,18 +60,19 @@ paths: $ref: '#/responses/InternalServerError' default: $ref: '#/responses/Default' - /projects/{identifier}: + /projects/{projectId}: parameters: - - name: identifier + - name: projectId in: path description: ID of the project type: string + format: uuid required: true get: tags: - Project - operationId: getProject - summary: Get project by its ID + operationId: getProjectById + summary: Get project by ID produces: - application/json responses: @@ -84,13 +89,173 @@ paths: default: $ref: '#/responses/Default' + /commits: + get: + tags: + - zzCommit + operationId: getCommits + summary: Get commits + produces: + - application/json + responses: + 200: + description: Ok + schema: + type: array + items: + $ref: '#/definitions/Commit' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' + post: + tags: + - zzCommit + operationId: postCommit + summary: Create commit + consumes: + - application/json + produces: + - application/json + parameters: + - in: body + name: body + required: true + schema: + $ref: '#/definitions/Commit' + responses: + 201: + description: Created + schema: + $ref: '#/definitions/Commit' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' + /commits/{identifier}: + parameters: + - name: identifier + in: path + description: ID of the commit + type: string + required: true + get: + tags: + - zzCommit + operationId: getCommitById + summary: Get commit by ID + produces: + - application/json + responses: + 200: + description: Ok + schema: + $ref: '#/definitions/Commit' + 404: + $ref: '#/responses/NotFound' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' + /projects/{project_identifier}/commits/{commit_identifier}: + parameters: + - name: project_identifier + in: path + description: ID of the project + type: string + required: true + - name: commit_identifier + in: path + description: ID of the commit + type: string + required: true + get: + tags: + - zzCommit + operationId: getCommitByProjectAndId + summary: Get commit by project ID and its ID + produces: + - application/json + responses: + 200: + description: Ok + schema: + $ref: '#/definitions/Commit' + 404: + $ref: '#/responses/NotFound' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' + /projects/{projectId}/commits: + parameters: + - name: projectId + in: path + description: ID of the project + type: string + format: uuid + required: true + get: + tags: + - Commit + operationId: getCommitsByProject + summary: Get commits by project + produces: + - application/json + responses: + 200: + description: Ok + schema: + $ref: '#/definitions/Commit' + 404: + $ref: '#/responses/NotFound' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' + post: + tags: + - Commit + operationId: postCommitByProject + summary: Create commit by project + consumes: + - application/json + produces: + - application/json + parameters: + - in: body + name: body + required: true + schema: + $ref: '#/definitions/Commit' + responses: + 201: + description: Created + schema: + $ref: '#/definitions/Commit' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' /elements: get: tags: - - Element + - zzElement operationId: getElements - summary: Get all elements + summary: Get elements produces: - application/json responses: @@ -108,7 +273,7 @@ paths: $ref: '#/responses/Default' post: tags: - - Element + - zzElement operationId: createElement summary: Add a new element consumes: @@ -141,7 +306,7 @@ paths: required: true get: tags: - - Element + - zzElement operationId: getElement summary: Get element by its ID produces: @@ -173,9 +338,9 @@ paths: required: true get: tags: - - Element - operationId: getElementByProjectAndId - summary: Get element by project ID and its ID + - zzElement + operationId: getElementByProjectId + summary: Get element by project and ID produces: - application/json responses: @@ -198,11 +363,45 @@ paths: description: ID of the commit type: string required: true + get: + tags: + - zzElement + operationId: getElementsByCommit + summary: Get elements by commit + produces: + - application/json + responses: + 200: + description: Ok + schema: + $ref: '#/definitions/Element' + 404: + $ref: '#/responses/NotFound' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' + /projects/{projectId}/commits/{commitId}/elements: + parameters: + - name: projectId + in: path + description: ID of the project + type: string + format: uuid + required: true + - name: commitId + in: path + description: ID of the commit + type: string + format: uuid + required: true get: tags: - Element - operationId: getElementsByCommitId - summary: Get elements by commit ID + operationId: getElementsByProjectCommit + summary: Get elements by project and commit produces: - application/json responses: @@ -230,11 +429,51 @@ paths: description: ID of the element type: string required: true + get: + tags: + - zzElement + operationId: getElementByCommitId + summary: Get element by commit and ID + produces: + - application/json + responses: + 200: + description: Ok + schema: + $ref: '#/definitions/Element' + 404: + $ref: '#/responses/NotFound' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' + /projects/{projectId}/commits/{commitId}/elements/{elementId}: + parameters: + - name: projectId + in: path + description: ID of the project + type: string + format: uuid + required: true + - name: commitId + in: path + description: ID of the commit + type: string + format: uuid + required: true + - name: elementId + in: path + description: ID of the element + type: string + format: uuid + required: true get: tags: - Element - operationId: getElementByCommitIdAndId - summary: Get element by commit ID and element ID + operationId: getElementByProjectCommitId + summary: Get element by project, commit and ID produces: - application/json responses: @@ -259,7 +498,7 @@ paths: required: true get: tags: - - Element + - zzElement operationId: getElementsInProject summary: Get all elements in the project produces: @@ -281,7 +520,7 @@ paths: /relationships: get: tags: - - Relationship + - zzRelationship operationId: getRelationships summary: Get all relationships produces: @@ -301,7 +540,7 @@ paths: $ref: '#/responses/Default' post: tags: - - Relationship + - zzRelationship operationId: createRelationship summary: Add a new relationship consumes: @@ -334,7 +573,7 @@ paths: required: true get: tags: - - Relationship + - zzRelationship operationId: getRelationship summary: Get relationship by its ID produces: @@ -352,33 +591,46 @@ paths: $ref: '#/responses/InternalServerError' default: $ref: '#/responses/Default' - # /relationships/elements/{element_identifier}: - # parameters: - # - name: element_identifier - # in: path - # description: ID of the element that is the source or target of relationships - # type: string - # required: true - # get: - # tags: - # - Relationship - # operationId: getRelationshipsByElement - # summary: Get all relationships with the given element as either source or target - # produces: - # - application/json - # responses: - # 200: - # description: Ok - # schema: - # type: array - # items: - # $ref: '#/definitions/Relationship' - # 415: - # $ref: '#/responses/BadContentType' - # 500: - # $ref: '#/responses/InternalServerError' - # default: - # $ref: '#/responses/Default' + /projects/{projectId}/commits/{commitId}/elements/{relatedElementId}/relationships: + parameters: + - name: projectId + in: path + description: ID of the project + type: string + format: uuid + required: true + - name: commitId + in: path + description: ID of the commit + type: string + format: uuid + required: true + - name: relatedElementId + in: path + description: ID of the related element + type: string + format: uuid + required: true + get: + tags: + - Relationship + operationId: getRelationshipsByProjectCommitRelatedElement + summary: Get relationships by project, commit, and related element. + produces: + - application/json + responses: + 200: + description: Ok + schema: + type: array + items: + $ref: '#/definitions/Relationship' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' # /relationship/source/{source_identifier}: # parameters: # - name: source_identifier @@ -442,7 +694,7 @@ paths: required: true get: tags: - - Relationship + - zzRelationship operationId: getRelationshipsByProject summary: Get all relationships in the project produces: @@ -461,140 +713,6 @@ paths: default: $ref: '#/responses/Default' - /commits: - get: - tags: - - Commit - operationId: getCommits - summary: Get all commits - produces: - - application/json - responses: - 200: - description: Ok - schema: - type: array - items: - $ref: '#/definitions/Commit' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' - post: - tags: - - Commit - operationId: createCommit - summary: Add a new commit - consumes: - - application/json - produces: - - application/json - parameters: - - in: body - name: body - required: true - schema: - $ref: '#/definitions/Commit' - responses: - 201: - description: Created - schema: - $ref: '#/definitions/Commit' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' - /commits/{identifier}: - parameters: - - name: identifier - in: path - description: ID of the commit - type: string - required: true - get: - tags: - - Commit - operationId: getCommit - summary: Get commit by its ID - produces: - - application/json - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/Commit' - 404: - $ref: '#/responses/NotFound' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' - /projects/{project_identifier}/commits/{commit_identifier}: - parameters: - - name: project_identifier - in: path - description: ID of the project - type: string - required: true - - name: commit_identifier - in: path - description: ID of the commit - type: string - required: true - get: - tags: - - Commit - operationId: getCommitByProjectAndId - summary: Get commit by project ID and its ID - produces: - - application/json - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/Commit' - 404: - $ref: '#/responses/NotFound' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' - /projects/{project_identifier}/commits: - parameters: - - name: project_identifier - in: path - description: ID of the project - type: string - required: true - get: - tags: - - Commit - operationId: getCommitsInProject - summary: Get all commits in the project - produces: - - application/json - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/Commit' - 404: - $ref: '#/responses/NotFound' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' - definitions: Project: type: object From 7cb47ce538c49f7be711739e888c5f69334b522b Mon Sep 17 00:00:00 2001 From: Ivan Gomes Date: Wed, 29 Jan 2020 21:22:05 -0800 Subject: [PATCH 05/14] Remove API calls deprecated by lifecycle implementation --- app/controllers/CommitController.java | 11 +- app/controllers/ElementController.java | 13 - app/controllers/ProjectController.java | 5 +- app/controllers/RelationshipController.java | 24 -- app/dao/ElementDao.java | 9 +- app/dao/RelationshipDao.java | 12 - app/dao/impl/jpa/JpaCommitDao.java | 2 +- app/dao/impl/jpa/JpaElementDao.java | 46 +- app/dao/impl/jpa/JpaRelationshipDao.java | 100 ----- app/services/ElementService.java | 8 - app/services/RelationshipService.java | 16 - conf/routes | 31 +- public/swagger/openapi.yaml | 445 +------------------- 13 files changed, 22 insertions(+), 700 deletions(-) diff --git a/app/controllers/CommitController.java b/app/controllers/CommitController.java index 9bc7a7b4..697488d2 100644 --- a/app/controllers/CommitController.java +++ b/app/controllers/CommitController.java @@ -57,16 +57,13 @@ public Result createWithProjectId(UUID projectId, Http.Request request) { return responseCommit.map(e -> created(Json.toJson(e))).orElseGet(Results::internalServerError); } - public Result byProject(String projectId) { - UUID projectUuid = UUID.fromString(projectId); - List commits = commitService.getByProjectId(projectUuid); + public Result byProject(UUID projectId) { + List commits = commitService.getByProjectId(projectId); return ok(JacksonHelper.collectionValueToTree(List.class, metamodelProvider.getImplementationClass(Commit.class), commits)); } - public Result byProjectAndId(String commitId, String projectId) { - UUID commitUuid = UUID.fromString(commitId); - UUID projectUuid = UUID.fromString(projectId); - Optional commit = commitService.getByProjectIdAndId(projectUuid, commitUuid); + public Result byProjectAndId(UUID projectId, UUID commitId) { + Optional commit = commitService.getByProjectIdAndId(projectId, commitId); return commit.map(e -> ok(Json.toJson(e))).orElseGet(Results::notFound); } } diff --git a/app/controllers/ElementController.java b/app/controllers/ElementController.java index bae3e58e..dd85920d 100644 --- a/app/controllers/ElementController.java +++ b/app/controllers/ElementController.java @@ -51,25 +51,12 @@ public Result create(Http.Request request) { return responseElement.map(e -> created(Json.toJson(e))).orElseGet(Results::internalServerError); } - public Result byProject(String projectId) { - UUID projectUuid = UUID.fromString(projectId); - List elements = elementService.getByProjectId(projectUuid); - return ok(JacksonHelper.collectionValueToTree(List.class, metamodelProvider.getImplementationClass(Element.class), elements)); - } - public Result byCommit(String commitId) { UUID commitUuid = UUID.fromString(commitId); Set elements = elementService.getByCommitId(commitUuid); return ok(JacksonHelper.collectionValueToTree(Set.class, metamodelProvider.getImplementationClass(Element.class), elements)); } - public Result byProjectAndId(String elementId, String projectId) { - UUID elementUuid = UUID.fromString(elementId); - UUID projectUuid = UUID.fromString(projectId); - Optional element = elementService.getByProjectIdAndId(projectUuid, elementUuid); - return element.map(e -> ok(Json.toJson(e))).orElseGet(Results::notFound); - } - public Result byCommitAndId(String commitId, String elementId) { UUID commitUuid = UUID.fromString(commitId); UUID elementUuid = UUID.fromString(elementId); diff --git a/app/controllers/ProjectController.java b/app/controllers/ProjectController.java index ce3708e4..c65d210c 100644 --- a/app/controllers/ProjectController.java +++ b/app/controllers/ProjectController.java @@ -28,9 +28,8 @@ public class ProjectController extends Controller { @Inject private ProjectService projectService; - public Result byId(String id) { - UUID uuid = UUID.fromString(id); - Optional project = projectService.getById(uuid); + public Result byId(UUID id) { + Optional project = projectService.getById(id); return project.map(m -> ok(Json.toJson(m))).orElseGet(Results::notFound); } diff --git a/app/controllers/RelationshipController.java b/app/controllers/RelationshipController.java index 8336d8d3..be02df22 100644 --- a/app/controllers/RelationshipController.java +++ b/app/controllers/RelationshipController.java @@ -51,30 +51,6 @@ public Result create(Http.Request request) { return responseRelationship.map(e -> created(Json.toJson(e))).orElseGet(Results::internalServerError); } - public Result byRelatedElementId(String id) { - UUID elementUuid = UUID.fromString(id); - List relationships = relationshipService.getByRelatedElementId(elementUuid); - return ok(JacksonHelper.collectionValueToTree(List.class, metamodelProvider.getImplementationClass(Relationship.class), relationships)); - } - - public Result bySourceElementId(String id) { - UUID elementUuid = UUID.fromString(id); - List relationships = relationshipService.getBySourceElementId(elementUuid); - return ok(JacksonHelper.collectionValueToTree(List.class, metamodelProvider.getImplementationClass(Relationship.class), relationships)); - } - - public Result byTargetElementId(String id) { - UUID elementUuid = UUID.fromString(id); - List relationships = relationshipService.getByTargetElementId(elementUuid); - return ok(JacksonHelper.collectionValueToTree(List.class, metamodelProvider.getImplementationClass(Relationship.class), relationships)); - } - - public Result byProject(String projectId) { - UUID projectUuid = UUID.fromString(projectId); - List relationships = relationshipService.getByProjectId(projectUuid); - return ok(JacksonHelper.collectionValueToTree(List.class, metamodelProvider.getImplementationClass(Relationship.class), relationships)); - } - public Result getRelationshipsByProjectIdCommitIdRelatedElementId(UUID projectId, UUID commitId, UUID elementId) { System.out.println(projectId + " : " + commitId + " : " + elementId); Set relationships = relationshipService.getRelationshipsByProjectCommitRelatedElement(projectId, commitId, elementId); diff --git a/app/dao/ElementDao.java b/app/dao/ElementDao.java index 77e12659..321a1617 100644 --- a/app/dao/ElementDao.java +++ b/app/dao/ElementDao.java @@ -1,8 +1,7 @@ package dao; -import org.omg.sysml.lifecycle.Project; -import org.omg.sysml.metamodel.Element; import org.omg.sysml.lifecycle.Commit; +import org.omg.sysml.metamodel.Element; import java.util.List; import java.util.Optional; @@ -22,13 +21,7 @@ public interface ElementDao extends Dao { void deleteAll(); - @Deprecated - List findAllByProject(Project project); - Set findAllByCommit(Commit commit); - @Deprecated - Optional findByProjectAndId(Project project, UUID id); - Optional findByCommitAndId(Commit commit, UUID id); } diff --git a/app/dao/RelationshipDao.java b/app/dao/RelationshipDao.java index 2e99d6ce..57c99a11 100644 --- a/app/dao/RelationshipDao.java +++ b/app/dao/RelationshipDao.java @@ -23,17 +23,5 @@ public interface RelationshipDao extends Dao { void deleteAll(); - @Deprecated - List findAllByRelatedElement(Element element); - - @Deprecated - List findAllBySourceElement(Element element); - - @Deprecated - List findAllByTargetElement(Element element); - - @Deprecated - List findAllByProject(Project project); - Set findAllByCommitRelatedElement(Commit commit, Element relatedElement); } diff --git a/app/dao/impl/jpa/JpaCommitDao.java b/app/dao/impl/jpa/JpaCommitDao.java index 378f71e2..e8d6e867 100644 --- a/app/dao/impl/jpa/JpaCommitDao.java +++ b/app/dao/impl/jpa/JpaCommitDao.java @@ -50,7 +50,7 @@ public Optional persist(Commit commit) { throw new IllegalStateException(); } return jpa.transact(em -> { - ((CommitImpl) commit).setChanges(commit.getChanges().stream().map(em::merge).collect(Collectors.toSet())); + commit.setChanges(commit.getChanges().stream().map(em::merge).collect(Collectors.toSet())); return super.persist(commit, em); }); } diff --git a/app/dao/impl/jpa/JpaElementDao.java b/app/dao/impl/jpa/JpaElementDao.java index 33a5b14d..40d86a13 100644 --- a/app/dao/impl/jpa/JpaElementDao.java +++ b/app/dao/impl/jpa/JpaElementDao.java @@ -3,16 +3,10 @@ import config.MetamodelProvider; import dao.ElementDao; import jpa.manager.JPAManager; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.query.Query; -import org.omg.sysml.lifecycle.ElementRecord; -import org.omg.sysml.lifecycle.Project; +import org.omg.sysml.lifecycle.Commit; import org.omg.sysml.metamodel.Element; -import org.omg.sysml.metamodel.MofObject; import org.omg.sysml.metamodel.impl.MofObjectImpl; import org.omg.sysml.metamodel.impl.MofObjectImpl_; -import org.omg.sysml.lifecycle.Commit; import javax.inject.Inject; import javax.inject.Singleton; @@ -76,15 +70,6 @@ public void deleteAll() { }); } - @Override - public List findAllByProject(Project project) { - try (Session session = jpa.getEntityManagerFactory().unwrap(SessionFactory.class).openSession()) { - Query query = session.createQuery("FROM org.omg.sysml.metamodel.Element WHERE containingProject = :project", Element.class); - query.setParameter("project", project); - return query.getResultList(); - } - } - @Override public Set findAllByCommit(Commit commit) { return jpa.transact(em -> { @@ -94,35 +79,6 @@ public Set findAllByCommit(Commit commit) { }); } - @Override - public Optional findByProjectAndId(Project project, UUID id) { - try (Session session = jpa.getEntityManagerFactory().unwrap(SessionFactory.class).openSession()) { - Query query = session.createQuery("FROM org.omg.sysml.metamodel.Element WHERE identifier = :identifier AND containingProject = :project", Element.class); - query.setParameter("identifier", id); - query.setParameter("project", project); - try { - return Optional.of(query.getSingleResult()); - } catch (NoResultException e) { - return Optional.empty(); - } - } - } - - /*@Override - public Optional findByCommitAndId(Commit commit, UUID id) { - return jpa.transact(em -> { - Element element = null; - Commit currentCommit = commit; - Set visitedCommits = new HashSet<>(); - while (element == null && currentCommit != null && !visitedCommits.contains(currentCommit)) { - element = currentCommit.getChanges().stream().filter(record -> record.getIdentity() != null && record.getIdentity().getId() != null && record.getData() instanceof Element).filter(record -> id.equals(record.getIdentity().getId())).map(record -> (Element) record.getData()).findAny().orElse(null); - visitedCommits.add(currentCommit); - currentCommit = currentCommit.getPreviousCommit(); - } - return Optional.ofNullable(element); - }); - }*/ - @Override public Optional findByCommitAndId(Commit commit, UUID id) { return jpa.transact(em -> { diff --git a/app/dao/impl/jpa/JpaRelationshipDao.java b/app/dao/impl/jpa/JpaRelationshipDao.java index cee5c005..8d948772 100644 --- a/app/dao/impl/jpa/JpaRelationshipDao.java +++ b/app/dao/impl/jpa/JpaRelationshipDao.java @@ -76,106 +76,6 @@ public void deleteAll() { }); } - // TODO Change to use relatedElement when derived attributes are implemented - // TODO Implement. The @ManyToAny (polymorphism plus OneToMany in conjunction) of source and target makes this surprisingly difficult. Deferring to after versioning concept is introduced as that will likely break anything we implement now. - @Override - public List findAllByRelatedElement(Element element) { - /*try (Session session = jpa.getEntityManagerFactory().unwrap(SessionFactory.class).openSession()) { - Query query = session.createQuery("SELECT relationship FROM org.omg.sysml.metamodel.Relationship AS relationship JOIN relationship.source AS s JOIN org.omg.sysml.metamodel.Element AS ss ON s.identifier = ss.identifier WHERE ss.identifier = :elementIdentifier", Relationship.class); - Query query = session.createQuery("FROM org.omg.sysml.metamodel.Relationship", Relationship.class); - query.setParameter("elementIdentifier", element.getIdentifier()); - return query.getResultList(); - - CriteriaBuilder builder = session.getCriteriaBuilder(); - CriteriaQuery query = builder.createQuery(Relationship.class); - Root root = query.from(Relationship.class); - query.select(root).where( - builder.or( - builder.isMember(element, root.get("source")), - builder.isMember(element, root.get("target")) - ) - ); - return session.createQuery(query).getResultList(); - - - // Iterate types and SQL (union *_source and *_target, join mofobject and typetable) - /eturn getTypeStream().map(type -> { - System.out.println("FOO " + type.getName()); - CriteriaBuilder builder = session.getCriteriaBuilder(); - CriteriaQuery query = (CriteriaQuery) builder.createQuery(type); - Root root = (Root) query.from(type); - query.select(root).where( - builder.or( - builder.isMember(element.getIdentifier(), root.get("source").get(MofObjectImpl_.IDENTIFIER)), - builder.isMember(element.getIdentifier(), root.get("target").get(MofObjectImpl_.IDENTIFIER)) - ) - ); - return session.createQuery(query).getResultList(); - }).flatMap(Collection::stream).collect(Collectors.toList()); - } - - return jpa.transact(em -> { - CriteriaBuilder builder = em.getCriteriaBuilder(); - CriteriaQuery query = builder.createQuery(Relationship.class); - Root root = query.from(RelationshipImpl.class); - query.select(root).where( - builder.or( - builder.isMember(element, root.get(RelationshipImpl_.source)), - builder.isMember(element, root.get(RelationshipImpl_.target)) - ) - ); - return em.createQuery(query).getResultList(); - }); - - return jpa.transact(em -> { - Query query = em.createNativeQuery("SELECT CAST(Ownership.identifier AS text) FROM Ownership_source UNION INNER JOIN Ownership ON (Ownership.identifier = Ownership_source.OwnershipId) WHERE Ownership_source.sourceId = :elementIdentifier"); - query.setParameter("elementIdentifier", element.getIdentifier()); - List relationships = query.getResultList(); - System.out.println(relationships); - return Collections.emptyList(); - //return query.getResultList(); - }); - */ - return Collections.emptyList(); - } - - @Override - public List findAllBySourceElement(Element element) { - /* - return jpa.transact(em -> { - CriteriaBuilder builder = em.getCriteriaBuilder(); - CriteriaQuery query = builder.createQuery(Relationship.class); - Root root = query.from(RelationshipImpl.class); - query.select(root).where(builder.isMember(element, root.get(RelationshipImpl_.source))); - return em.createQuery(query).getResultList(); - }); - */ - return Collections.emptyList(); - } - - @Override - public List findAllByTargetElement(Element element) { - /* - return jpa.transact(em -> { - CriteriaBuilder builder = em.getCriteriaBuilder(); - CriteriaQuery query = builder.createQuery(Relationship.class); - Root root = query.from(RelationshipImpl.class); - query.select(root).where(builder.isMember(element, root.get(RelationshipImpl_.target))); - return em.createQuery(query).getResultList(); - }); - */ - return Collections.emptyList(); - } - - @Override - public List findAllByProject(Project project) { - try (Session session = jpa.getEntityManagerFactory().unwrap(SessionFactory.class).openSession()) { - org.hibernate.query.Query query = session.createQuery("FROM org.omg.sysml.metamodel.Relationship WHERE containingProject = :project", Relationship.class); - query.setParameter("project", project); - return query.getResultList(); - } - } - @Override public Set findAllByCommitRelatedElement(Commit commit, Element relatedElement) { return jpa.transact(em -> { diff --git a/app/services/ElementService.java b/app/services/ElementService.java index 92aac070..8294b7fa 100644 --- a/app/services/ElementService.java +++ b/app/services/ElementService.java @@ -28,18 +28,10 @@ public Optional getById(UUID id) { return elementDao.findById(id); } - public List getByProjectId(UUID projectId) { - return projectDao.findById(projectId).map(m -> elementDao.findAllByProject(m)).orElse(Collections.emptyList()); - } - public Set getByCommitId(UUID commitId) { return commitDao.findById(commitId).map(c -> elementDao.findAllByCommit(c)).orElse(Collections.emptySet()); } - public Optional getByProjectIdAndId(UUID projectId, UUID elementId) { - return projectDao.findById(projectId).flatMap(m -> elementDao.findByProjectAndId(m, elementId)); - } - public Optional getByCommitIdAndId(UUID commitId, UUID elementId) { return commitDao.findById(commitId).flatMap(m -> elementDao.findByCommitAndId(m, elementId)); } diff --git a/app/services/RelationshipService.java b/app/services/RelationshipService.java index 7708b099..aada4e38 100644 --- a/app/services/RelationshipService.java +++ b/app/services/RelationshipService.java @@ -39,22 +39,6 @@ public Optional create(Relationship relationship) { return relationship.getIdentifier() != null ? relationshipDao.update(relationship) : relationshipDao.persist(relationship); } - public List getByRelatedElementId(UUID elementId) { - return elementDao.findById(elementId).map(e -> relationshipDao.findAllByRelatedElement(e)).orElse(Collections.emptyList()); - } - - public List getBySourceElementId(UUID elementId) { - return elementDao.findById(elementId).map(e -> relationshipDao.findAllBySourceElement(e)).orElse(Collections.emptyList()); - } - - public List getByTargetElementId(UUID elementId) { - return elementDao.findById(elementId).map(e -> relationshipDao.findAllByTargetElement(e)).orElse(Collections.emptyList()); - } - - public List getByProjectId(UUID projectId) { - return projectDao.findById(projectId).map(m -> relationshipDao.findAllByProject(m)).orElse(Collections.emptyList()); - } - public Set getRelationshipsByProjectCommitRelatedElement(UUID projectId, UUID commitId, UUID relatedElementId) { Commit commit = projectDao.findById(projectId).flatMap(project -> commitDao.findByProjectAndId(project, commitId)).orElseThrow(() -> new IllegalArgumentException("Commit " + commitId + " not found.")); Element relatedElement = elementDao.findByCommitAndId(commit, relatedElementId).orElseThrow(() -> new IllegalArgumentException("Element " + relatedElementId + " not found.")); diff --git a/conf/routes b/conf/routes index 4ca4c81d..167b6c39 100644 --- a/conf/routes +++ b/conf/routes @@ -7,39 +7,20 @@ GET / # Project endpoints GET /projects controllers.ProjectController.all() -GET /projects/:id controllers.ProjectController.byId(id : String) POST /projects controllers.ProjectController.create(request : Request) +GET /projects/:projectId controllers.ProjectController.byId(projectId : java.util.UUID) + +# Commit endpoints +GET /projects/:projectId/commits controllers.CommitController.byProject(projectId : java.util.UUID) +POST /projects/:projectId/commits controllers.CommitController.createWithProjectId(projectId : java.util.UUID, request : Request) +GET /projects/:projectId/commits/:commitId controllers.CommitController.byProjectAndId(projectId : java.util.UUID, commitId : java.util.UUID) # Element endpoints -GET /elements controllers.ElementController.all() -GET /elements/:id controllers.ElementController.byId(id : String) -GET /projects/:mid/elements controllers.ElementController.byProject(mid : String) -GET /commits/:commitId/elements controllers.ElementController.byCommit(commitId : String) GET /projects/:projectId/commits/:commitId/elements controllers.ElementController.getElementsByProjectIdCommitId(projectId : java.util.UUID, commitId : java.util.UUID) -GET /projects/:mid/elements/:id controllers.ElementController.byProjectAndId(id : String, mid : String) -GET /commits/:commitId/elements/:elementId controllers.ElementController.byCommitAndId(commitId : String, elementId : String) GET /projects/:projectId/commits/:commitId/elements/:elementId controllers.ElementController.getElementByProjectIdCommitIdElementId(projectId : java.util.UUID, commitId : java.util.UUID, elementId : java.util.UUID) -POST /elements controllers.ElementController.create(request : Request) - -# Commit endpoints -GET /commits controllers.CommitController.all() -GET /commits/:id controllers.CommitController.byId(id : String) -GET /projects/:mid/commits/:id controllers.CommitController.byProjectAndId(id : String, mid : String) -GET /projects/:mid/commits controllers.CommitController.byProject(mid : String) -POST /commits controllers.CommitController.create(request : Request) -POST /projects/:projectId/commits controllers.CommitController.createWithProjectId(projectId : java.util.UUID, request : Request) # Relationship endpoints -GET /relationships/:id controllers.RelationshipController.byId(id : String) -# GET /relationship/element/:id controllers.RelationshipController.byRelatedElementId(id : String) -# GET /relationship/source/:id controllers.RelationshipController.bySourceElementId(id : String) -# GET /relationship/source/:id/type/:type controllers.RelationshipController.bySourceElementId(id : String) -# GET /relationship/target/:id controllers.RelationshipController.byTargetElementId(id : String) -# GET /relationship/target/:id/type/:type controllers.RelationshipController.byTargetElementId(id : String) -GET /relationships controllers.RelationshipController.all() -GET /projects/:mid/relationships controllers.RelationshipController.byProject(mid : String) GET /projects/:projectId/commits/:commitId/elements/:relatedElementId/relationships controllers.RelationshipController.getRelationshipsByProjectIdCommitIdRelatedElementId(projectId : java.util.UUID, commitId : java.util.UUID, relatedElementId : java.util.UUID) -POST /relationships controllers.RelationshipController.create(request : Request) # Map static resources from the /public folder to the /assets URL path GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset) diff --git a/public/swagger/openapi.yaml b/public/swagger/openapi.yaml index 3e820510..89ef5eb0 100644 --- a/public/swagger/openapi.yaml +++ b/public/swagger/openapi.yaml @@ -8,10 +8,6 @@ tags: - name: Commit - name: Element - name: Relationship - - name: zzProject - - name: zzCommit - - name: zzElement - - name: zzRelationship paths: /projects: @@ -88,113 +84,6 @@ paths: $ref: '#/responses/InternalServerError' default: $ref: '#/responses/Default' - - /commits: - get: - tags: - - zzCommit - operationId: getCommits - summary: Get commits - produces: - - application/json - responses: - 200: - description: Ok - schema: - type: array - items: - $ref: '#/definitions/Commit' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' - post: - tags: - - zzCommit - operationId: postCommit - summary: Create commit - consumes: - - application/json - produces: - - application/json - parameters: - - in: body - name: body - required: true - schema: - $ref: '#/definitions/Commit' - responses: - 201: - description: Created - schema: - $ref: '#/definitions/Commit' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' - /commits/{identifier}: - parameters: - - name: identifier - in: path - description: ID of the commit - type: string - required: true - get: - tags: - - zzCommit - operationId: getCommitById - summary: Get commit by ID - produces: - - application/json - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/Commit' - 404: - $ref: '#/responses/NotFound' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' - /projects/{project_identifier}/commits/{commit_identifier}: - parameters: - - name: project_identifier - in: path - description: ID of the project - type: string - required: true - - name: commit_identifier - in: path - description: ID of the commit - type: string - required: true - get: - tags: - - zzCommit - operationId: getCommitByProjectAndId - summary: Get commit by project ID and its ID - produces: - - application/json - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/Commit' - 404: - $ref: '#/responses/NotFound' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' /projects/{projectId}/commits: parameters: - name: projectId @@ -249,132 +138,30 @@ paths: $ref: '#/responses/InternalServerError' default: $ref: '#/responses/Default' - - /elements: - get: - tags: - - zzElement - operationId: getElements - summary: Get elements - produces: - - application/json - responses: - 200: - description: Ok - schema: - type: array - items: - $ref: '#/definitions/Element' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' - post: - tags: - - zzElement - operationId: createElement - summary: Add a new element - consumes: - - application/json - produces: - - application/json - parameters: - - in: body - name: body - required: true - schema: - $ref: '#/definitions/Element' - responses: - 201: - description: Created - schema: - $ref: '#/definitions/Element' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' - /elements/{identifier}: + /projects/{projectId}/commits/{commitId}: parameters: - - name: identifier - in: path - description: ID of the element - type: string - required: true - get: - tags: - - zzElement - operationId: getElement - summary: Get element by its ID - produces: - - application/json - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/Element' - 404: - $ref: '#/responses/NotFound' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' - /projects/{project_identifier}/elements/{element_identifier}: - parameters: - - name: project_identifier + - name: projectId in: path description: ID of the project type: string required: true - - name: element_identifier - in: path - description: ID of the element - type: string - required: true - get: - tags: - - zzElement - operationId: getElementByProjectId - summary: Get element by project and ID - produces: - - application/json - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/Element' - 404: - $ref: '#/responses/NotFound' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' - /commits/{commit_id}/elements: - parameters: - - name: commit_id + - name: commitId in: path description: ID of the commit type: string required: true get: tags: - - zzElement - operationId: getElementsByCommit - summary: Get elements by commit + - Commit + operationId: getCommitByProjectAndId + summary: Get commit by project and ID produces: - application/json responses: 200: description: Ok schema: - $ref: '#/definitions/Element' + $ref: '#/definitions/Commit' 404: $ref: '#/responses/NotFound' 415: @@ -417,38 +204,6 @@ paths: $ref: '#/responses/InternalServerError' default: $ref: '#/responses/Default' - /commits/{commit_id}/elements/{element_id}: - parameters: - - name: commit_id - in: path - description: ID of the commit - type: string - required: true - - name: element_id - in: path - description: ID of the element - type: string - required: true - get: - tags: - - zzElement - operationId: getElementByCommitId - summary: Get element by commit and ID - produces: - - application/json - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/Element' - 404: - $ref: '#/responses/NotFound' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' /projects/{projectId}/commits/{commitId}/elements/{elementId}: parameters: - name: projectId @@ -489,108 +244,6 @@ paths: $ref: '#/responses/InternalServerError' default: $ref: '#/responses/Default' - /projects/{project_identifier}/elements: - parameters: - - name: project_identifier - in: path - description: ID of the project - type: string - required: true - get: - tags: - - zzElement - operationId: getElementsInProject - summary: Get all elements in the project - produces: - - application/json - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/Element' - 404: - $ref: '#/responses/NotFound' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' - - /relationships: - get: - tags: - - zzRelationship - operationId: getRelationships - summary: Get all relationships - produces: - - application/json - responses: - 200: - description: Ok - schema: - type: array - items: - $ref: '#/definitions/Relationship' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' - post: - tags: - - zzRelationship - operationId: createRelationship - summary: Add a new relationship - consumes: - - application/json - produces: - - application/json - parameters: - - in: body - name: body - required: true - schema: - $ref: '#/definitions/Relationship' - responses: - 201: - description: Created - schema: - $ref: '#/definitions/Relationship' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' - /relationships/{identifier}: - parameters: - - name: identifier - in: path - description: ID of the relationship - type: string - required: true - get: - tags: - - zzRelationship - operationId: getRelationship - summary: Get relationship by its ID - produces: - - application/json - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/Relationship' - 404: - $ref: '#/responses/NotFound' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' /projects/{projectId}/commits/{commitId}/elements/{relatedElementId}/relationships: parameters: - name: projectId @@ -631,88 +284,6 @@ paths: $ref: '#/responses/InternalServerError' default: $ref: '#/responses/Default' - # /relationship/source/{source_identifier}: - # parameters: - # - name: source_identifier - # in: path - # description: ID of the element that is the source of relationships - # type: string - # required: true - # get: - # tags: - # - Relationship - # operationId: getRelationshipsBySource - # summary: Get all relationships with the given element as the source - # produces: - # - application/json - # responses: - # 200: - # description: Ok - # schema: - # type: array - # items: - # $ref: '#/definitions/Relationship' - # 415: - # $ref: '#/responses/BadContentType' - # 500: - # $ref: '#/responses/InternalServerError' - # default: - # $ref: '#/responses/Default' - # /relationship/target/{target_identifier}: - # parameters: - # - name: target_identifier - # in: path - # description: ID of the element that is the target of relationships - # type: string - # required: true - # get: - # tags: - # - Relationship - # operationId: getRelationshipsByTarget - # summary: Get all relationships with the given element as the target - # produces: - # - application/json - # responses: - # 200: - # description: Ok - # schema: - # type: array - # items: - # $ref: '#/definitions/Relationship' - # 415: - # $ref: '#/responses/BadContentType' - # 500: - # $ref: '#/responses/InternalServerError' - # default: - # $ref: '#/responses/Default' - /projects/{project_identifier}/relationships: - parameters: - - name: project_identifier - in: path - description: ID of the project - type: string - required: true - get: - tags: - - zzRelationship - operationId: getRelationshipsByProject - summary: Get all relationships in the project - produces: - - application/json - responses: - 200: - description: Ok - schema: - type: array - items: - $ref: '#/definitions/Relationship' - 415: - $ref: '#/responses/BadContentType' - 500: - $ref: '#/responses/InternalServerError' - default: - $ref: '#/responses/Default' - definitions: Project: type: object @@ -729,8 +300,6 @@ definitions: properties: '@type': type: string - containingProject: - $ref: '#/definitions/Identified' identifier: type: string format: uuid From f5ce7a00e91e52adc9316f8ebf0f95f5a8bf2cfd Mon Sep 17 00:00:00 2001 From: Ivan Gomes Date: Wed, 29 Jan 2020 22:12:49 -0800 Subject: [PATCH 06/14] Exclude Commit#changes from getCommitsByProject --- app/controllers/CommitController.java | 3 ++- app/jackson/JacksonHelper.java | 10 ++++++++-- app/org/omg/sysml/lifecycle/impl/CommitImpl.java | 15 +++++++++++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/controllers/CommitController.java b/app/controllers/CommitController.java index 697488d2..7f6155da 100644 --- a/app/controllers/CommitController.java +++ b/app/controllers/CommitController.java @@ -4,6 +4,7 @@ import config.MetamodelProvider; import jackson.JacksonHelper; import org.omg.sysml.lifecycle.Commit; +import org.omg.sysml.lifecycle.impl.CommitImpl; import play.libs.Json; import play.mvc.Controller; import play.mvc.Http; @@ -59,7 +60,7 @@ public Result createWithProjectId(UUID projectId, Http.Request request) { public Result byProject(UUID projectId) { List commits = commitService.getByProjectId(projectId); - return ok(JacksonHelper.collectionValueToTree(List.class, metamodelProvider.getImplementationClass(Commit.class), commits)); + return ok(JacksonHelper.collectionValueToTree(List.class, metamodelProvider.getImplementationClass(Commit.class), commits, writer -> writer.withView(CommitImpl.Views.Compact.class))); } public Result byProjectAndId(UUID projectId, UUID commitId) { diff --git a/app/jackson/JacksonHelper.java b/app/jackson/JacksonHelper.java index 864ecc6b..240c91bc 100644 --- a/app/jackson/JacksonHelper.java +++ b/app/jackson/JacksonHelper.java @@ -2,17 +2,23 @@ import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectWriter; import play.libs.Json; import java.io.IOException; import java.util.Collection; +import java.util.function.Function; public class JacksonHelper { - // Java type erasure necessitates explicitly specifying JavaType for Collections. See https://github.com/FasterXML/jackson-databind/issues/23#issuecomment-6251193. public static JsonNode collectionValueToTree(@SuppressWarnings("rawtypes") Class collectionClass, Class elementClass, Collection collection) { + return collectionValueToTree(collectionClass, elementClass, collection, Function.identity()); + } + + // Java type erasure necessitates explicitly specifying JavaType for Collections. See https://github.com/FasterXML/jackson-databind/issues/23#issuecomment-6251193. + public static JsonNode collectionValueToTree(@SuppressWarnings("rawtypes") Class collectionClass, Class elementClass, Collection collection, Function objectWriterFunction) { JavaType javaType = Json.mapper().getTypeFactory().constructCollectionType(collectionClass, elementClass); try { - return Json.mapper().readerFor(javaType).readTree(Json.mapper().writerFor(javaType).writeValueAsString(collection)); + return Json.mapper().readerFor(javaType).readTree(objectWriterFunction.apply(Json.mapper().writerFor(javaType)).writeValueAsString(collection)); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/app/org/omg/sysml/lifecycle/impl/CommitImpl.java b/app/org/omg/sysml/lifecycle/impl/CommitImpl.java index 08343c4c..8cc81b52 100644 --- a/app/org/omg/sysml/lifecycle/impl/CommitImpl.java +++ b/app/org/omg/sysml/lifecycle/impl/CommitImpl.java @@ -1,6 +1,7 @@ package org.omg.sysml.lifecycle.impl; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonView; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import jackson.MofObjectDeserializer; @@ -25,6 +26,7 @@ public class CommitImpl extends RecordImpl implements Commit { @Override @ManyToOne(targetEntity = ProjectImpl.class, fetch = FetchType.LAZY) @JsonSerialize(as = ProjectImpl.class, using = MofObjectSerializer.class) + @JsonView(Views.Compact.class) public Project getContainingProject() { return containingProject; } @@ -35,8 +37,8 @@ public void setContainingProject(Project containingProject) { } @Override - @OneToMany(targetEntity = ElementRecordImpl.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER) - @JsonDeserialize(contentAs = ElementRecordImpl.class) + @OneToMany(targetEntity = ElementRecordImpl.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JsonView(Views.Complete.class) public Set getChanges() { if (changes == null) { changes = new HashSet<>(); @@ -44,12 +46,14 @@ public Set getChanges() { return changes; } + @JsonDeserialize(contentAs = ElementRecordImpl.class) public void setChanges(Set changes) { this.changes = changes; } @Override @Column + @JsonView(Views.Compact.class) public ZonedDateTime getTimestamp() { return timestamp; } @@ -60,6 +64,7 @@ public void setTimestamp(ZonedDateTime timestamp) { @ManyToOne(targetEntity = CommitImpl.class, fetch = FetchType.LAZY) @JsonSerialize(as = CommitImpl.class, using = RecordSerialization.RecordSerializer.class) + @JsonView(Views.Compact.class) public Commit getPreviousCommit() { return previousCommit; } @@ -71,7 +76,13 @@ public void setPreviousCommit(Commit previousCommit) { @Transient @JsonProperty("@type") + @JsonView(Views.Compact.class) public String getType() { return Commit.class.getSimpleName(); } + + public static class Views { + public interface Compact {} + public interface Complete extends Compact {} + } } From 0053b92225d1810194dcffdbe2e0b03f0eeff384 Mon Sep 17 00:00:00 2001 From: Ivan Gomes Date: Sat, 1 Feb 2020 15:08:17 -0800 Subject: [PATCH 07/14] Clean and document commit pre-processing --- app/dao/impl/jpa/JpaCommitDao.java | 32 ++++++++++++++++++------------ 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/app/dao/impl/jpa/JpaCommitDao.java b/app/dao/impl/jpa/JpaCommitDao.java index e8d6e867..d34cc428 100644 --- a/app/dao/impl/jpa/JpaCommitDao.java +++ b/app/dao/impl/jpa/JpaCommitDao.java @@ -2,13 +2,15 @@ import dao.CommitDao; import jpa.manager.JPAManager; -import org.omg.sysml.lifecycle.Project; -import org.omg.sysml.metamodel.impl.MofObjectImpl; import org.omg.sysml.lifecycle.Commit; +import org.omg.sysml.lifecycle.ElementRecord; +import org.omg.sysml.lifecycle.Project; import org.omg.sysml.lifecycle.impl.CommitImpl; import org.omg.sysml.lifecycle.impl.CommitImpl_; import org.omg.sysml.lifecycle.impl.ElementIdentityImpl; import org.omg.sysml.lifecycle.impl.ElementRecordImpl; +import org.omg.sysml.metamodel.MofObject; +import org.omg.sysml.metamodel.impl.MofObjectImpl; import javax.inject.Inject; import javax.inject.Singleton; @@ -18,8 +20,10 @@ import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.UUID; +import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -35,17 +39,19 @@ protected JPAManager getJpaManager() { @Override public Optional persist(Commit commit) { - commit.getChanges().stream().filter(record -> record.getIdentity() == null).filter(record -> record instanceof ElementRecordImpl).map(record -> (ElementRecordImpl) record) - .forEach(record -> { - ElementIdentityImpl identity = new ElementIdentityImpl(); - identity.setId(UUID.randomUUID()); - record.setIdentity(identity); - }); - commit.getChanges().stream().filter(record -> record.getData() != null).filter(record -> record.getData() instanceof MofObjectImpl) - .forEach(record -> { - ((MofObjectImpl) record.getData()).setId(UUID.randomUUID()); - ((MofObjectImpl) record.getData()).setIdentifier(record.getIdentity().getId()); - }); + UUID tombstoneUuid = UUID.randomUUID(); + + Supplier> changeStream = () -> commit.getChanges().stream().filter(change -> change instanceof ElementRecordImpl).map(change -> (ElementRecordImpl) change); + + // Give all Commit#changes an identity, if they don't already have one, and all Commit#changes#identity an id, if they don't already have one. + changeStream.get().peek(change -> change.setIdentity(change.getIdentity() != null ? change.getIdentity() : new ElementIdentityImpl())).map(ElementRecord::getIdentity).filter(identity -> identity instanceof ElementIdentityImpl).map(identity -> (ElementIdentityImpl) identity).forEach(identity -> identity.setId(identity.getId() != null ? identity.getId() : UUID.randomUUID())); + + // Copy all Commit#changes#identity#id to Commit#changes#data#identifier and give all Commit#changes#data a random id. + Map identifierToIdMap = changeStream.get().peek(change -> Optional.ofNullable(change.getData()).filter(mof -> mof instanceof MofObjectImpl).map(mof -> (MofObjectImpl) mof).ifPresent(mof -> { + mof.setIdentifier(change.getIdentity().getId()); + mof.setId(UUID.randomUUID()); + })).collect(Collectors.toMap(change -> change.getIdentity().getId(), change -> Optional.ofNullable(change.getData()).map(MofObject::getId).orElse(tombstoneUuid))); + if (!(commit instanceof CommitImpl)) { throw new IllegalStateException(); } From 7df70846cb5b20844b26d9adb2a835c5edaf7f0b Mon Sep 17 00:00:00 2001 From: Ivan Gomes Date: Tue, 4 Feb 2020 09:47:02 -0800 Subject: [PATCH 08/14] Refactor ProjectImpl to extend RecordImpl. Clean up models and their inheritance in OpenAPI spec. --- .../omg/sysml/lifecycle/impl/ProjectImpl.java | 51 ++------ .../sysml/lifecycle/impl/ProjectImpl_.java | 2 +- public/swagger/openapi.yaml | 113 +++++++++--------- 3 files changed, 67 insertions(+), 99 deletions(-) diff --git a/app/org/omg/sysml/lifecycle/impl/ProjectImpl.java b/app/org/omg/sysml/lifecycle/impl/ProjectImpl.java index 12de2415..1c1d566b 100644 --- a/app/org/omg/sysml/lifecycle/impl/ProjectImpl.java +++ b/app/org/omg/sysml/lifecycle/impl/ProjectImpl.java @@ -2,23 +2,16 @@ import com.fasterxml.jackson.annotation.*; import org.hibernate.annotations.FetchMode; +import org.omg.sysml.lifecycle.Commit; import org.omg.sysml.lifecycle.Project; import org.omg.sysml.metamodel.impl.MofObjectImpl; -import javax.persistence.DiscriminatorValue; -import javax.persistence.Entity; -import javax.persistence.Lob; -import javax.persistence.SecondaryTable; +import javax.persistence.*; // import info.archinnov.achilles.annotations.UDT; -@Entity -@SecondaryTable(name = "Project") -@org.hibernate.annotations.Table(appliesTo = "Project", fetch = FetchMode.SELECT, optional = false) -// @info.archinnov.achilles.annotations.Table(table = "Project") -@DiscriminatorValue(value = "Project") -@JsonTypeName(value = "Project") -public class ProjectImpl extends MofObjectImpl implements Project { +@Entity(name = "Project") +public class ProjectImpl extends RecordImpl implements Project { private String name; @JsonProperty(required = true) @@ -36,37 +29,9 @@ public void setName(String name) { this.name = name; } - @Override - @JsonIgnore - public Project getContainingProject() { - return null; + @Transient + @JsonProperty("@type") + public String getType() { + return Project.class.getSimpleName(); } - - /* - - // @info.archinnov.achilles.annotations.Column("ownedRelationship") - private Collection containedElement; - - @JsonProperty(required = true) - @JsonGetter - @JsonSerialize(contentUsing = MofObjectSerializer.class) - @ManyToAny(metaDef = "RelationshipMetaDef", metaColumn = @javax.persistence.Column(name = "ownedRelationshipType"), fetch = FetchType.LAZY) - @JoinTable(name = "Package_ownedRelationship", - joinColumns = @JoinColumn(name = "PackageId"), - inverseJoinColumns = @JoinColumn(name = "ownedRelationshipId")) - public Collection getContainedElement() { - if (containedElement == null) { - containedElement = new ArrayList<>(); - } - return containedElement; - } - - @JsonProperty(required = true) - @JsonSetter - @JsonDeserialize(contentUsing = MofObjectDeserializer.class, contentAs = RelationshipImpl.class) - public void setContainedElement(Collection containedElement) { - this.containedElement = containedElement; - } - - */ } diff --git a/generated/org/omg/sysml/lifecycle/impl/ProjectImpl_.java b/generated/org/omg/sysml/lifecycle/impl/ProjectImpl_.java index e717eb3c..5d0930e3 100644 --- a/generated/org/omg/sysml/lifecycle/impl/ProjectImpl_.java +++ b/generated/org/omg/sysml/lifecycle/impl/ProjectImpl_.java @@ -6,7 +6,7 @@ @Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") @StaticMetamodel(ProjectImpl.class) -public abstract class ProjectImpl_ extends org.omg.sysml.metamodel.impl.MofObjectImpl_ { +public abstract class ProjectImpl_ extends org.omg.sysml.lifecycle.impl.RecordImpl_ { public static volatile SingularAttribute name; diff --git a/public/swagger/openapi.yaml b/public/swagger/openapi.yaml index 89ef5eb0..e4314df2 100644 --- a/public/swagger/openapi.yaml +++ b/public/swagger/openapi.yaml @@ -285,24 +285,73 @@ paths: default: $ref: '#/responses/Default' definitions: - Project: + Record: type: object properties: - '@type': - type: string - name: - type: string - identifier: + id: type: string format: uuid - Element: + Project: + type: object + allOf: + - $ref: '#/definitions/Record' + - properties: + '@type': + type: string + enum: + - 'Project' + name: + type: string + Commit: + type: object + allOf: + - $ref: '#/definitions/Record' + - properties: + '@type': + type: string + enum: + - 'Commit' + changes: + type: array + items: + $ref: '#/definitions/ElementRecord' + containingProject: + $ref: '#/definitions/Record' + ElementRecord: + type: object + allOf: + - $ref: '#/definitions/Record' + - properties: + '@type': + type: string + enum: + - 'ElementRecord' + data: + $ref: '#/definitions/Element' + identity: + $ref: '#/definitions/ElementIdentity' + ElementIdentity: + type: object + allOf: + - $ref: '#/definitions/Record' + - properties: + '@type': + type: string + enum: + - 'ElementIdentity' + Identified: type: object properties: - '@type': - type: string identifier: type: string format: uuid + Element: + type: object + allOf: + - $ref: '#/definitions/Identified' + - properties: + '@type': + type: string additionalProperties: type: object Relationship: @@ -318,52 +367,6 @@ definitions: type: array items: $ref: '#/definitions/Identified' - Identified: - type: object - properties: - identifier: - type: string - format: uuid - Commit: - type: object - properties: - '@type': - type: string - enum: - - 'Commit' - changes: - type: array - items: - $ref: '#/definitions/ElementRecord' - containingProject: - $ref: '#/definitions/Identified' - id: - type: string - format: uuid - ElementRecord: - type: object - properties: - '@type': - type: string - enum: - - 'ElementRecord' - data: - $ref: '#/definitions/Element' - id: - type: string - format: uuid - identity: - $ref: '#/definitions/ElementIdentity' - ElementIdentity: - type: object - properties: - '@type': - type: string - enum: - - 'ElementIdentity' - id: - type: string - format: uuid Error: type: object properties: From 5797545ed5b8645b59f2292412ec4a10dd6d73fe Mon Sep 17 00:00:00 2001 From: Ivan Gomes Date: Tue, 4 Feb 2020 12:21:38 -0800 Subject: [PATCH 09/14] Fix Project serialization. Refactor ElementRecord to ElementVersion. WIP for attribute by identifier and two pass commit. --- app/dao/impl/jpa/JpaCommitDao.java | 24 +++++++++++------ app/jackson/MofObjectDeserializer.java | 20 +++++++------- app/jackson/MofObjectSerializer.java | 7 +++++ app/jackson/RecordSerialization.java | 16 +++++++++++ app/org/omg/sysml/lifecycle/Commit.java | 4 +-- ...ElementRecord.java => ElementVersion.java} | 2 +- .../omg/sysml/lifecycle/impl/CommitImpl.java | 27 ++++++++++--------- ...ecordImpl.java => ElementVersionImpl.java} | 10 +++---- .../sysml/lifecycle/impl/package-info.java | 2 +- .../sysml/metamodel/impl/MofObjectImpl.java | 22 +++++++-------- conf/META-INF/persistence.xml | 2 +- .../omg/sysml/lifecycle/impl/CommitImpl_.java | 2 +- ...ordImpl_.java => ElementVersionImpl_.java} | 6 ++--- public/swagger/openapi.yaml | 6 ++--- 14 files changed, 90 insertions(+), 60 deletions(-) rename app/org/omg/sysml/lifecycle/{ElementRecord.java => ElementVersion.java} (74%) rename app/org/omg/sysml/lifecycle/impl/{ElementRecordImpl.java => ElementVersionImpl.java} (85%) rename generated/org/omg/sysml/lifecycle/impl/{ElementRecordImpl_.java => ElementVersionImpl_.java} (58%) diff --git a/app/dao/impl/jpa/JpaCommitDao.java b/app/dao/impl/jpa/JpaCommitDao.java index d34cc428..425681d4 100644 --- a/app/dao/impl/jpa/JpaCommitDao.java +++ b/app/dao/impl/jpa/JpaCommitDao.java @@ -3,12 +3,12 @@ import dao.CommitDao; import jpa.manager.JPAManager; import org.omg.sysml.lifecycle.Commit; -import org.omg.sysml.lifecycle.ElementRecord; +import org.omg.sysml.lifecycle.ElementVersion; import org.omg.sysml.lifecycle.Project; import org.omg.sysml.lifecycle.impl.CommitImpl; import org.omg.sysml.lifecycle.impl.CommitImpl_; import org.omg.sysml.lifecycle.impl.ElementIdentityImpl; -import org.omg.sysml.lifecycle.impl.ElementRecordImpl; +import org.omg.sysml.lifecycle.impl.ElementVersionImpl; import org.omg.sysml.metamodel.MofObject; import org.omg.sysml.metamodel.impl.MofObjectImpl; @@ -19,10 +19,7 @@ import javax.persistence.criteria.CriteriaDelete; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; +import java.util.*; import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -41,10 +38,10 @@ protected JPAManager getJpaManager() { public Optional persist(Commit commit) { UUID tombstoneUuid = UUID.randomUUID(); - Supplier> changeStream = () -> commit.getChanges().stream().filter(change -> change instanceof ElementRecordImpl).map(change -> (ElementRecordImpl) change); + Supplier> changeStream = () -> commit.getChanges().stream().filter(change -> change instanceof ElementVersionImpl).map(change -> (ElementVersionImpl) change); // Give all Commit#changes an identity, if they don't already have one, and all Commit#changes#identity an id, if they don't already have one. - changeStream.get().peek(change -> change.setIdentity(change.getIdentity() != null ? change.getIdentity() : new ElementIdentityImpl())).map(ElementRecord::getIdentity).filter(identity -> identity instanceof ElementIdentityImpl).map(identity -> (ElementIdentityImpl) identity).forEach(identity -> identity.setId(identity.getId() != null ? identity.getId() : UUID.randomUUID())); + changeStream.get().peek(change -> change.setIdentity(change.getIdentity() != null ? change.getIdentity() : new ElementIdentityImpl())).map(ElementVersion::getIdentity).filter(identity -> identity instanceof ElementIdentityImpl).map(identity -> (ElementIdentityImpl) identity).forEach(identity -> identity.setId(identity.getId() != null ? identity.getId() : UUID.randomUUID())); // Copy all Commit#changes#identity#id to Commit#changes#data#identifier and give all Commit#changes#data a random id. Map identifierToIdMap = changeStream.get().peek(change -> Optional.ofNullable(change.getData()).filter(mof -> mof instanceof MofObjectImpl).map(mof -> (MofObjectImpl) mof).ifPresent(mof -> { @@ -52,10 +49,21 @@ public Optional persist(Commit commit) { mof.setId(UUID.randomUUID()); })).collect(Collectors.toMap(change -> change.getIdentity().getId(), change -> Optional.ofNullable(change.getData()).map(MofObject::getId).orElse(tombstoneUuid))); + // TODO Resolve/set all identifier -> id, reflectively. Hopefully that's enough for Hibernate to try to make the relationships and give a meaningful error when types are incompatible. + if (!(commit instanceof CommitImpl)) { throw new IllegalStateException(); } return jpa.transact(em -> { + commit.getChanges().stream().map(ElementVersion::getData).filter(mof -> mof instanceof MofObjectImpl).map(mof -> (MofObjectImpl) mof).map(mof -> { + try { + MofObjectImpl firstPassMof = mof.getClass().getConstructor().newInstance(); + firstPassMof.setId(mof.getId()); + return firstPassMof; + } catch (ReflectiveOperationException e) { + throw new RuntimeException(e); + } + }).forEach(em::merge); commit.setChanges(commit.getChanges().stream().map(em::merge).collect(Collectors.toSet())); return super.persist(commit, em); }); diff --git a/app/jackson/MofObjectDeserializer.java b/app/jackson/MofObjectDeserializer.java index 7b5c3e90..f638138b 100644 --- a/app/jackson/MofObjectDeserializer.java +++ b/app/jackson/MofObjectDeserializer.java @@ -9,6 +9,7 @@ import javax.persistence.EntityManager; import org.omg.sysml.metamodel.impl.MofObjectImpl; import java.io.IOException; +import java.util.UUID; public class MofObjectDeserializer extends StdDeserializer { private EntityManager entityManager; @@ -27,19 +28,18 @@ public MofObjectImpl deserialize(JsonParser p, DeserializationContext ctxt) thro if (p.currentToken() != JsonToken.START_OBJECT) { throw new JsonParseException(p, "Expected START_OBJECT. Received " + p.getCurrentName() + "."); } + MofObjectImpl mof; + try { + mof = (MofObjectImpl) ctxt.getContextualType().getRawClass().getConstructor().newInstance(); + } catch (ReflectiveOperationException e) { + throw new IOException(e); + } + JsonToken token; - MofObjectImpl mof = null; while ((token = p.nextToken()) != null && token != JsonToken.END_OBJECT) { - if (mof == null && token == JsonToken.FIELD_NAME && "id".equals(p.getCurrentName())) { + if (token == JsonToken.FIELD_NAME && "identifier".equals(p.getCurrentName())) { p.nextToken(); - Object id = p.getText(); - if ("java.util.UUID".endsWith("UUID")) { - id = java.util.UUID.fromString(id.toString()); - } - mof = entityManager.find(MofObjectImpl.class, id); - if (mof == null) { - throw new IOException("Unable to find an object with id " + id); - } + mof.setIdentifier(UUID.fromString(p.getText())); } } return mof; diff --git a/app/jackson/MofObjectSerializer.java b/app/jackson/MofObjectSerializer.java index 0a2aaaa8..11269c5f 100644 --- a/app/jackson/MofObjectSerializer.java +++ b/app/jackson/MofObjectSerializer.java @@ -5,6 +5,8 @@ import com.fasterxml.jackson.databind.ser.std.StdSerializer; import javax.persistence.PersistenceException; import org.omg.sysml.metamodel.MofObject; +import org.omg.sysml.metamodel.impl.MofObjectImpl; + import java.io.IOException; public class MofObjectSerializer extends StdSerializer { @@ -28,7 +30,12 @@ public void serialize(MofObject value, JsonGenerator gen, SerializerProvider pro return; } gen.writeStartObject(); + // TODO Decide if @type and id should be exposed + gen.writeObjectField("@type", value.getClass().getSimpleName()); gen.writeObjectField("id", value.getId()); + if (value instanceof MofObjectImpl) { + gen.writeObjectField("identifier", ((MofObjectImpl) value).getIdentifier()); + } gen.writeEndObject(); } } \ No newline at end of file diff --git a/app/jackson/RecordSerialization.java b/app/jackson/RecordSerialization.java index d25a40b1..feedda74 100644 --- a/app/jackson/RecordSerialization.java +++ b/app/jackson/RecordSerialization.java @@ -4,6 +4,7 @@ import org.omg.sysml.lifecycle.Commit; import org.omg.sysml.lifecycle.Record; import org.omg.sysml.lifecycle.impl.CommitImpl; +import org.omg.sysml.lifecycle.impl.ProjectImpl; import org.omg.sysml.lifecycle.impl.RecordImpl; import org.omg.sysml.lifecycle.impl.RecordImpl_; @@ -68,4 +69,19 @@ protected Class getRecordClass() { return CommitImpl.class; } } + + public static class ProjectDeserializer extends RecordDeserializer { + public ProjectDeserializer(EntityManager entityManager) { + super(entityManager); + } + + public ProjectDeserializer() { + super(); + } + + @Override + protected Class getRecordClass() { + return ProjectImpl.class; + } + } } diff --git a/app/org/omg/sysml/lifecycle/Commit.java b/app/org/omg/sysml/lifecycle/Commit.java index 3d11bbdc..0a3dd89b 100644 --- a/app/org/omg/sysml/lifecycle/Commit.java +++ b/app/org/omg/sysml/lifecycle/Commit.java @@ -8,9 +8,9 @@ public interface Commit extends Record { void setContainingProject(Project containingProject); - Set getChanges(); + Set getChanges(); - void setChanges(Set changes); + void setChanges(Set changes); Commit getPreviousCommit(); diff --git a/app/org/omg/sysml/lifecycle/ElementRecord.java b/app/org/omg/sysml/lifecycle/ElementVersion.java similarity index 74% rename from app/org/omg/sysml/lifecycle/ElementRecord.java rename to app/org/omg/sysml/lifecycle/ElementVersion.java index 3ef8f952..fc20a044 100644 --- a/app/org/omg/sysml/lifecycle/ElementRecord.java +++ b/app/org/omg/sysml/lifecycle/ElementVersion.java @@ -2,7 +2,7 @@ import org.omg.sysml.metamodel.MofObject; -public interface ElementRecord extends Record { +public interface ElementVersion extends Record { MofObject getData(); ElementIdentity getIdentity(); diff --git a/app/org/omg/sysml/lifecycle/impl/CommitImpl.java b/app/org/omg/sysml/lifecycle/impl/CommitImpl.java index 8cc81b52..6e18dd65 100644 --- a/app/org/omg/sysml/lifecycle/impl/CommitImpl.java +++ b/app/org/omg/sysml/lifecycle/impl/CommitImpl.java @@ -4,12 +4,10 @@ import com.fasterxml.jackson.annotation.JsonView; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import jackson.MofObjectDeserializer; -import jackson.MofObjectSerializer; import jackson.RecordSerialization; -import org.omg.sysml.lifecycle.Project; import org.omg.sysml.lifecycle.Commit; -import org.omg.sysml.lifecycle.ElementRecord; +import org.omg.sysml.lifecycle.ElementVersion; +import org.omg.sysml.lifecycle.Project; import javax.persistence.*; import java.time.ZonedDateTime; @@ -19,35 +17,35 @@ @Entity(name = "Commit") public class CommitImpl extends RecordImpl implements Commit { private Project containingProject; - private Set changes; + private Set changes; private ZonedDateTime timestamp; private Commit previousCommit; @Override @ManyToOne(targetEntity = ProjectImpl.class, fetch = FetchType.LAZY) - @JsonSerialize(as = ProjectImpl.class, using = MofObjectSerializer.class) + @JsonSerialize(as = ProjectImpl.class, using = RecordSerialization.RecordSerializer.class) @JsonView(Views.Compact.class) public Project getContainingProject() { return containingProject; } - @JsonDeserialize(as = ProjectImpl.class, using = MofObjectDeserializer.class) + @JsonDeserialize(as = ProjectImpl.class, using = RecordSerialization.ProjectDeserializer.class) public void setContainingProject(Project containingProject) { this.containingProject = containingProject; } @Override - @OneToMany(targetEntity = ElementRecordImpl.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @OneToMany(targetEntity = ElementVersionImpl.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JsonView(Views.Complete.class) - public Set getChanges() { + public Set getChanges() { if (changes == null) { changes = new HashSet<>(); } return changes; } - @JsonDeserialize(contentAs = ElementRecordImpl.class) - public void setChanges(Set changes) { + @JsonDeserialize(contentAs = ElementVersionImpl.class) + public void setChanges(Set changes) { this.changes = changes; } @@ -82,7 +80,10 @@ public String getType() { } public static class Views { - public interface Compact {} - public interface Complete extends Compact {} + public interface Compact { + } + + public interface Complete extends Compact { + } } } diff --git a/app/org/omg/sysml/lifecycle/impl/ElementRecordImpl.java b/app/org/omg/sysml/lifecycle/impl/ElementVersionImpl.java similarity index 85% rename from app/org/omg/sysml/lifecycle/impl/ElementRecordImpl.java rename to app/org/omg/sysml/lifecycle/impl/ElementVersionImpl.java index 3162739f..f598c35f 100644 --- a/app/org/omg/sysml/lifecycle/impl/ElementRecordImpl.java +++ b/app/org/omg/sysml/lifecycle/impl/ElementVersionImpl.java @@ -5,16 +5,16 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import org.hibernate.annotations.Any; +import org.omg.sysml.lifecycle.ElementVersion; import org.omg.sysml.metamodel.MofObject; import org.omg.sysml.metamodel.impl.MofObjectImpl; import org.omg.sysml.lifecycle.ElementIdentity; -import org.omg.sysml.lifecycle.ElementRecord; import javax.persistence.*; -@Entity(name = "ElementRecord") -@JsonTypeName(value = "ElementRecord") -public class ElementRecordImpl extends RecordImpl implements ElementRecord { +@Entity(name = "ElementVersion") +@JsonTypeName(value = "ElementVersion") +public class ElementVersionImpl extends RecordImpl implements ElementVersion { private MofObject data; private ElementIdentity identity; @@ -44,6 +44,6 @@ public void setIdentity(ElementIdentity identity) { @Transient @JsonProperty("@type") public static String getType() { - return ElementRecord.class.getSimpleName(); + return ElementVersion.class.getSimpleName(); } } diff --git a/app/org/omg/sysml/lifecycle/impl/package-info.java b/app/org/omg/sysml/lifecycle/impl/package-info.java index 9984993d..423ef04e 100644 --- a/app/org/omg/sysml/lifecycle/impl/package-info.java +++ b/app/org/omg/sysml/lifecycle/impl/package-info.java @@ -7,7 +7,7 @@ metaValues = { @MetaValue(value = "Commit", targetEntity = CommitImpl.class), @MetaValue(value = "ElementIdentity", targetEntity = ElementIdentityImpl.class), - @MetaValue(value = "ElementRecord", targetEntity = ElementRecordImpl.class), + @MetaValue(value = "ElementVersion", targetEntity = ElementVersionImpl.class), @MetaValue(value = "Project", targetEntity = ProjectImpl.class), @MetaValue(value = "Record", targetEntity = RecordImpl.class), }), diff --git a/app/org/omg/sysml/metamodel/impl/MofObjectImpl.java b/app/org/omg/sysml/metamodel/impl/MofObjectImpl.java index 237c5b8b..e3889b6d 100644 --- a/app/org/omg/sysml/metamodel/impl/MofObjectImpl.java +++ b/app/org/omg/sysml/metamodel/impl/MofObjectImpl.java @@ -1,23 +1,21 @@ package org.omg.sysml.metamodel.impl; -import com.fasterxml.jackson.annotation.*; - +import com.fasterxml.jackson.annotation.JsonGetter; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import jackson.RecordSerialization; +import org.hibernate.annotations.Any; import org.omg.sysml.lifecycle.Project; import org.omg.sysml.lifecycle.impl.ProjectImpl; import org.omg.sysml.metamodel.MofObject; -//import info.archinnov.achilles.annotations.PartitionKey; - import javax.persistence.*; +//import info.archinnov.achilles.annotations.PartitionKey; // TODO Remove temporary modification for prototyping Project concept -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import jackson.MofObjectDeserializer; -import jackson.MofObjectSerializer; -import org.hibernate.annotations.Any; - @Entity(name = "MofObjectImpl") @Table(name = "MofObject") @DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING) @@ -46,7 +44,7 @@ public void setId(java.util.UUID id) { private Project containingProject; @JsonGetter - @JsonSerialize(using = MofObjectSerializer.class) + @JsonSerialize(using = RecordSerialization.RecordSerializer.class) @Any(metaDef = "ProjectMetaDef", metaColumn = @javax.persistence.Column(name = "containingProjectType"), fetch = FetchType.LAZY) @JoinColumn(name = "containingProjectId", table = "MofObject") public Project getContainingProject() { @@ -54,7 +52,7 @@ public Project getContainingProject() { } @JsonSetter - @JsonDeserialize(using = MofObjectDeserializer.class, as = ProjectImpl.class) + @JsonDeserialize(using = RecordSerialization.ProjectDeserializer.class, as = ProjectImpl.class) public void setContainingProject(Project containingProject) { this.containingProject = containingProject; } diff --git a/conf/META-INF/persistence.xml b/conf/META-INF/persistence.xml index ed815af9..0f1b20b6 100644 --- a/conf/META-INF/persistence.xml +++ b/conf/META-INF/persistence.xml @@ -113,7 +113,7 @@ org.omg.sysml.lifecycle.impl org.omg.sysml.lifecycle.impl.CommitImpl org.omg.sysml.lifecycle.impl.ElementIdentityImpl - org.omg.sysml.lifecycle.impl.ElementRecordImpl + org.omg.sysml.lifecycle.impl.ElementVersionImpl org.omg.sysml.lifecycle.impl.ProjectImpl org.omg.sysml.lifecycle.impl.RecordImpl diff --git a/generated/org/omg/sysml/lifecycle/impl/CommitImpl_.java b/generated/org/omg/sysml/lifecycle/impl/CommitImpl_.java index 2be1f25c..a8e9bdcc 100644 --- a/generated/org/omg/sysml/lifecycle/impl/CommitImpl_.java +++ b/generated/org/omg/sysml/lifecycle/impl/CommitImpl_.java @@ -10,7 +10,7 @@ @StaticMetamodel(CommitImpl.class) public abstract class CommitImpl_ extends org.omg.sysml.lifecycle.impl.RecordImpl_ { - public static volatile SetAttribute changes; + public static volatile SetAttribute changes; public static volatile SingularAttribute previousCommit; public static volatile SingularAttribute containingProject; public static volatile SingularAttribute timestamp; diff --git a/generated/org/omg/sysml/lifecycle/impl/ElementRecordImpl_.java b/generated/org/omg/sysml/lifecycle/impl/ElementVersionImpl_.java similarity index 58% rename from generated/org/omg/sysml/lifecycle/impl/ElementRecordImpl_.java rename to generated/org/omg/sysml/lifecycle/impl/ElementVersionImpl_.java index 26d7c22b..35bfac2e 100644 --- a/generated/org/omg/sysml/lifecycle/impl/ElementRecordImpl_.java +++ b/generated/org/omg/sysml/lifecycle/impl/ElementVersionImpl_.java @@ -5,10 +5,10 @@ import javax.persistence.metamodel.StaticMetamodel; @Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") -@StaticMetamodel(ElementRecordImpl.class) -public abstract class ElementRecordImpl_ extends org.omg.sysml.lifecycle.impl.RecordImpl_ { +@StaticMetamodel(ElementVersionImpl.class) +public abstract class ElementVersionImpl_ extends org.omg.sysml.lifecycle.impl.RecordImpl_ { - public static volatile SingularAttribute identity; + public static volatile SingularAttribute identity; public static final String IDENTITY = "identity"; diff --git a/public/swagger/openapi.yaml b/public/swagger/openapi.yaml index e4314df2..df7c4116 100644 --- a/public/swagger/openapi.yaml +++ b/public/swagger/openapi.yaml @@ -314,10 +314,10 @@ definitions: changes: type: array items: - $ref: '#/definitions/ElementRecord' + $ref: '#/definitions/ElementVersion' containingProject: $ref: '#/definitions/Record' - ElementRecord: + ElementVersion: type: object allOf: - $ref: '#/definitions/Record' @@ -325,7 +325,7 @@ definitions: '@type': type: string enum: - - 'ElementRecord' + - 'ElementVersion' data: $ref: '#/definitions/Element' identity: From 2e6d561724323df9e413775717daaefdb6286234 Mon Sep 17 00:00:00 2001 From: Ivan Gomes Date: Tue, 4 Feb 2020 12:32:28 -0800 Subject: [PATCH 10/14] Remove MofObject#containingProject --- app/org/omg/sysml/metamodel/MofObject.java | 6 ---- .../sysml/metamodel/impl/MofObjectImpl.java | 34 +++---------------- 2 files changed, 4 insertions(+), 36 deletions(-) diff --git a/app/org/omg/sysml/metamodel/MofObject.java b/app/org/omg/sysml/metamodel/MofObject.java index 19bbee47..6120dfa4 100644 --- a/app/org/omg/sysml/metamodel/MofObject.java +++ b/app/org/omg/sysml/metamodel/MofObject.java @@ -1,11 +1,5 @@ package org.omg.sysml.metamodel; -import org.omg.sysml.lifecycle.Project; - public interface MofObject { java.util.UUID getId(); - - // TODO Remove temporary modification for prototyping Project concept - - Project getContainingProject(); } \ No newline at end of file diff --git a/app/org/omg/sysml/metamodel/impl/MofObjectImpl.java b/app/org/omg/sysml/metamodel/impl/MofObjectImpl.java index e3889b6d..68d886a1 100644 --- a/app/org/omg/sysml/metamodel/impl/MofObjectImpl.java +++ b/app/org/omg/sysml/metamodel/impl/MofObjectImpl.java @@ -1,20 +1,12 @@ package org.omg.sysml.metamodel.impl; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import jackson.RecordSerialization; -import org.hibernate.annotations.Any; -import org.omg.sysml.lifecycle.Project; -import org.omg.sysml.lifecycle.impl.ProjectImpl; -import org.omg.sysml.metamodel.MofObject; +import com.fasterxml.jackson.annotation.*; -import javax.persistence.*; +import org.omg.sysml.metamodel.MofObject; //import info.archinnov.achilles.annotations.PartitionKey; -// TODO Remove temporary modification for prototyping Project concept + +import javax.persistence.*; @Entity(name = "MofObjectImpl") @Table(name = "MofObject") @@ -39,24 +31,6 @@ public void setId(java.util.UUID id) { this.id = id; } - // TODO Remove temporary modification for prototyping Project concept - - private Project containingProject; - - @JsonGetter - @JsonSerialize(using = RecordSerialization.RecordSerializer.class) - @Any(metaDef = "ProjectMetaDef", metaColumn = @javax.persistence.Column(name = "containingProjectType"), fetch = FetchType.LAZY) - @JoinColumn(name = "containingProjectId", table = "MofObject") - public Project getContainingProject() { - return containingProject; - } - - @JsonSetter - @JsonDeserialize(using = RecordSerialization.ProjectDeserializer.class, as = ProjectImpl.class) - public void setContainingProject(Project containingProject) { - this.containingProject = containingProject; - } - // TODO Remove hardcoding for identifier // @info.archinnov.achilles.annotations.Column("identifier") From da7b6be414aa3d898141184e640c9ac966a36687 Mon Sep 17 00:00:00 2001 From: Ivan Gomes Date: Tue, 4 Feb 2020 18:19:40 -0800 Subject: [PATCH 11/14] Enable specifying attributes by lifecycle agnostic `identifier` --- app/dao/impl/jpa/JpaCommitDao.java | 111 ++++++++++++++++++++- app/dao/impl/jpa/JpaElementDao.java | 7 +- app/jackson/MofObjectDeserializer.java | 37 ++++++- app/jackson/MofObjectSerializer.java | 6 +- app/javabean/JavaBeanHelper.java | 38 +++++++ app/org/omg/sysml/metamodel/MofObject.java | 2 + 6 files changed, 188 insertions(+), 13 deletions(-) create mode 100644 app/javabean/JavaBeanHelper.java diff --git a/app/dao/impl/jpa/JpaCommitDao.java b/app/dao/impl/jpa/JpaCommitDao.java index 425681d4..127b18c8 100644 --- a/app/dao/impl/jpa/JpaCommitDao.java +++ b/app/dao/impl/jpa/JpaCommitDao.java @@ -1,6 +1,7 @@ package dao.impl.jpa; import dao.CommitDao; +import javabean.JavaBeanHelper; import jpa.manager.JPAManager; import org.omg.sysml.lifecycle.Commit; import org.omg.sysml.lifecycle.ElementVersion; @@ -19,7 +20,9 @@ import javax.persistence.criteria.CriteriaDelete; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; +import java.lang.reflect.Method; import java.util.*; +import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -34,9 +37,18 @@ protected JPAManager getJpaManager() { return jpa; } + private JpaElementDao elementDao = new JpaElementDao(); + @Override public Optional persist(Commit commit) { - UUID tombstoneUuid = UUID.randomUUID(); + MofObject tombstone = new MofObjectImpl() { + UUID id = UUID.randomUUID(); + + @Override + public UUID getId() { + return id; + } + }; Supplier> changeStream = () -> commit.getChanges().stream().filter(change -> change instanceof ElementVersionImpl).map(change -> (ElementVersionImpl) change); @@ -44,12 +56,88 @@ public Optional persist(Commit commit) { changeStream.get().peek(change -> change.setIdentity(change.getIdentity() != null ? change.getIdentity() : new ElementIdentityImpl())).map(ElementVersion::getIdentity).filter(identity -> identity instanceof ElementIdentityImpl).map(identity -> (ElementIdentityImpl) identity).forEach(identity -> identity.setId(identity.getId() != null ? identity.getId() : UUID.randomUUID())); // Copy all Commit#changes#identity#id to Commit#changes#data#identifier and give all Commit#changes#data a random id. - Map identifierToIdMap = changeStream.get().peek(change -> Optional.ofNullable(change.getData()).filter(mof -> mof instanceof MofObjectImpl).map(mof -> (MofObjectImpl) mof).ifPresent(mof -> { + Map identifierToMofMap = changeStream.get().peek(change -> Optional.ofNullable(change.getData()).filter(mof -> mof instanceof MofObjectImpl).map(mof -> (MofObjectImpl) mof).ifPresent(mof -> { mof.setIdentifier(change.getIdentity().getId()); mof.setId(UUID.randomUUID()); - })).collect(Collectors.toMap(change -> change.getIdentity().getId(), change -> Optional.ofNullable(change.getData()).map(MofObject::getId).orElse(tombstoneUuid))); + })).collect(Collectors.toMap(change -> change.getIdentity().getId(), change -> Optional.ofNullable(change.getData()).orElse(tombstone))); + + // Attempt #1 using a javassist proxy. Failed because Hibernate/JPA can't handle subclasses of Entities. +/* changeStream.get().map(ElementVersion::getData).filter(Objects::nonNull).map(JpaCommitDao::getBeanPropertyValues).flatMap(map -> map.values().stream()).flatMap(o -> o instanceof Collection ? ((Collection) o).stream() : Stream.of(o)).filter(o -> o instanceof MofObject && o instanceof ProxyObject).map(o -> (MofObject & ProxyObject) o).forEach(mofProxy -> { + MofObject mof = identifierToMofMap.computeIfAbsent(mofProxy.getIdentifier(), identifier -> { + if (commit.getPreviousCommit() == null) { + return tombstone; + } + return elementDao.findByCommitAndId(commit.getPreviousCommit(), identifier).map(element -> (MofObject) element).orElse(tombstone); + }); + if (Objects.equals(mof, tombstone)) { + throw new IllegalArgumentException("Element with ID " + mofProxy.getIdentifier() + " not found."); + } + mofProxy.setHandler(new PassthroughMethodHandler(mof)); + System.out.println("REFERENCE: " + mofProxy.getIdentifier()); + });*/ - // TODO Resolve/set all identifier -> id, reflectively. Hopefully that's enough for Hibernate to try to make the relationships and give a meaningful error when types are incompatible. + Function reattachMofFunction = mof -> { + MofObject reattachedMof = identifierToMofMap.computeIfAbsent(mof.getIdentifier(), identifier -> { + if (commit.getPreviousCommit() == null) { + return tombstone; + } + return elementDao.findByCommitAndId(commit.getPreviousCommit(), identifier).map(element -> (MofObject) element).orElse(tombstone); + }); + if (Objects.equals(reattachedMof, tombstone)) { + throw new IllegalArgumentException("Element with ID " + mof.getIdentifier() + " not found."); + } + return reattachedMof; + }; + changeStream.get().map(ElementVersion::getData).filter(Objects::nonNull).forEach(mof -> { + JavaBeanHelper.getBeanProperties(mof).values().stream().filter(property -> property.getReadMethod() != null && property.getWriteMethod() != null).forEach(property -> { + Method getter = property.getReadMethod(); + Method setter = property.getWriteMethod(); + Class type = property.getPropertyType(); + + Object originalValue; + try { + originalValue = getter.invoke(mof); + final Object newValue; + if (MofObject.class.isAssignableFrom(type)) { + if (!(originalValue instanceof MofObject)) { + return; + } + newValue = reattachMofFunction.apply((MofObject) originalValue); + } else if (Collection.class.isAssignableFrom(type)) { + Collection originalValueCollection = (Collection) originalValue; + if (originalValueCollection.isEmpty() || originalValueCollection.stream().anyMatch((o -> !(o instanceof MofObject)))) { + return; + } + final Collection newValueCollection; + if (List.class.isAssignableFrom(type)) { + newValueCollection = new ArrayList<>(); + } else if (Set.class.isAssignableFrom(type)) { + newValueCollection = new HashSet<>(); + } else if (Collection.class.isAssignableFrom(type)) { + newValueCollection = new ArrayList<>(); + } else { + throw new IllegalStateException("Unknown collection type."); + } + ((Collection) originalValue).stream().map(o -> (MofObject) o).map(reattachMofFunction).forEachOrdered(newValueCollection::add); + newValue = newValueCollection; + } else { + return; + } + setter.invoke(mof, newValue); + } catch (ReflectiveOperationException e) { + throw new RuntimeException(e); + } + }); + }); + + /* changeStream.get().map(ElementVersion::getData).filter(Objects::nonNull).filter(element -> element instanceof BlockImpl).map(element -> (BlockImpl) element).forEach(block -> { + if (block.getOwner() instanceof MofObjectImpl) { + MofObjectImpl owner = (MofObjectImpl) block.getOwner(); + if (owner.getIdentifier() != null) { + block.setOwner((Element) identifierToMofMap.get(owner.getIdentifier())); + } + } + });*/ if (!(commit instanceof CommitImpl)) { throw new IllegalStateException(); @@ -135,4 +223,19 @@ public Optional findByProjectAndId(Project project, UUID id) { } }); } + +/* private static class PassthroughMethodHandler implements MethodHandler { + + private final Object target; + + protected PassthroughMethodHandler(Object target) { + this.target = target; + } + + @Override + public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable { + //return thisMethod.invoke(target, args); + return target.getClass().getMethod(thisMethod.getName(), thisMethod.getParameterTypes()).invoke(target, args); + } + }*/ } diff --git a/app/dao/impl/jpa/JpaElementDao.java b/app/dao/impl/jpa/JpaElementDao.java index 40d86a13..0784b685 100644 --- a/app/dao/impl/jpa/JpaElementDao.java +++ b/app/dao/impl/jpa/JpaElementDao.java @@ -2,6 +2,7 @@ import config.MetamodelProvider; import dao.ElementDao; +import javabean.JavaBeanHelper; import jpa.manager.JPAManager; import org.omg.sysml.lifecycle.Commit; import org.omg.sysml.metamodel.Element; @@ -75,7 +76,8 @@ public Set findAllByCommit(Commit commit) { return jpa.transact(em -> { // TODO Commit is detached at this point. This ternary mitigates by requerying for the Commit in this transaction. A better solution would be moving transaction handling up to service layer (supported by general wisdom) and optionally migrating to using Play's @Transactional/JPAApi. Pros would include removal of repetitive transaction handling at the DAO layer and ability to interface with multiple DAOs in the same transaction (consistent view). Cons include increased temptation to keep transaction open for longer than needed, e.g. during JSON serialization due to the convenience of @Transactional (deprecated in >= 2.8.x), and the service, a higher level of abstraction, becoming aware of transactions. An alternative would be DAO-to-DAO calls (generally discouraged) and delegating to non-transactional versions of methods. Commit c = em.contains(commit) ? commit : em.find(metamodelProvider.getImplementationClass(Commit.class), commit.getId()); - return streamFlattenedElements(c).collect(Collectors.toSet()); + // TODO Explore alternative to serializing lazy entity attributes that doesn't involve resolving all proxies one level. + return streamFlattenedElements(c).peek(e -> JavaBeanHelper.getBeanPropertyValues(e).values().stream().flatMap(o -> o instanceof Collection ? ((Collection) o).stream() : Stream.of(o)).forEach(o -> {})).collect(Collectors.toSet()); }); } @@ -85,7 +87,8 @@ public Optional findByCommitAndId(Commit commit, UUID id) { return queryCommitTree(em.contains(commit) ? commit : em.find(metamodelProvider.getImplementationClass(Commit.class), commit.getId()), c -> c.getChanges().stream().filter(record -> record.getIdentity() != null && record.getIdentity().getId() != null && record.getData() instanceof Element).filter(record -> id.equals(record.getIdentity().getId())).map(record -> (Element) record.getData()).findAny(), Optional::isPresent) - .values().stream().filter(Optional::isPresent).map(Optional::get).findAny(); + // TODO Explore alternative to serializing lazy entity attributes that doesn't involve resolving all proxies one level. + .values().stream().filter(Optional::isPresent).peek(e -> JavaBeanHelper.getBeanPropertyValues(e).values().stream().flatMap(o -> o instanceof Collection ? ((Collection) o).stream() : Stream.of(o)).forEach(o -> {})).map(Optional::get).findAny(); }); } diff --git a/app/jackson/MofObjectDeserializer.java b/app/jackson/MofObjectDeserializer.java index f638138b..91f7fb6a 100644 --- a/app/jackson/MofObjectDeserializer.java +++ b/app/jackson/MofObjectDeserializer.java @@ -3,20 +3,35 @@ import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.BeanProperty; import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.deser.ContextualDeserializer; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import javax.persistence.EntityManager; +import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; import org.omg.sysml.metamodel.impl.MofObjectImpl; + +import javax.persistence.EntityManager; import java.io.IOException; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; -public class MofObjectDeserializer extends StdDeserializer { +public class MofObjectDeserializer extends StdDeserializer implements ContextualDeserializer { private EntityManager entityManager; + private JavaType type; + + //private static Map, Class> PROXY_MAP = new HashMap<>(); public MofObjectDeserializer(EntityManager entityManager) { + this(entityManager, null); + } + + public MofObjectDeserializer(EntityManager entityManager, JavaType type) { super((Class) null); this.entityManager = entityManager; + this.type = type; } public MofObjectDeserializer() { @@ -28,9 +43,16 @@ public MofObjectImpl deserialize(JsonParser p, DeserializationContext ctxt) thro if (p.currentToken() != JsonToken.START_OBJECT) { throw new JsonParseException(p, "Expected START_OBJECT. Received " + p.getCurrentName() + "."); } + MofObjectImpl mof; +/* Class proxyClass = PROXY_MAP.computeIfAbsent(type.getRawClass(), clazz -> { + ProxyFactory factory = new ProxyFactory(); + factory.setSuperclass(clazz); + return factory.createClass(); + });*/ try { - mof = (MofObjectImpl) ctxt.getContextualType().getRawClass().getConstructor().newInstance(); + //mof = (MofObjectImpl) proxyClass.getConstructor().newInstance(); + mof = (MofObjectImpl) type.getRawClass().getConstructor().newInstance(); } catch (ReflectiveOperationException e) { throw new IOException(e); } @@ -49,4 +71,11 @@ public MofObjectImpl deserialize(JsonParser p, DeserializationContext ctxt) thro public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException { return deserialize(p, ctxt); } + + @Override + public JsonDeserializer createContextual(DeserializationContext ctxt, BeanProperty property) { + //beanProperty is null when the type to deserialize is the top-level type or a generic type, not a type of a bean property + JavaType type = ctxt.getContextualType() != null ? ctxt.getContextualType() : property.getMember().getType(); + return new MofObjectDeserializer(entityManager, type); + } } \ No newline at end of file diff --git a/app/jackson/MofObjectSerializer.java b/app/jackson/MofObjectSerializer.java index 11269c5f..2179e52a 100644 --- a/app/jackson/MofObjectSerializer.java +++ b/app/jackson/MofObjectSerializer.java @@ -31,10 +31,10 @@ public void serialize(MofObject value, JsonGenerator gen, SerializerProvider pro } gen.writeStartObject(); // TODO Decide if @type and id should be exposed - gen.writeObjectField("@type", value.getClass().getSimpleName()); - gen.writeObjectField("id", value.getId()); + // gen.writeObjectField("@type", value.getClass().getSimpleName()); + // gen.writeObjectField("id", value.getId()); if (value instanceof MofObjectImpl) { - gen.writeObjectField("identifier", ((MofObjectImpl) value).getIdentifier()); + gen.writeObjectField("identifier", value.getIdentifier()); } gen.writeEndObject(); } diff --git a/app/javabean/JavaBeanHelper.java b/app/javabean/JavaBeanHelper.java new file mode 100644 index 00000000..b1a3e8f2 --- /dev/null +++ b/app/javabean/JavaBeanHelper.java @@ -0,0 +1,38 @@ +package javabean; + +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +import java.util.stream.Collectors; + +public class JavaBeanHelper { + public static Map getBeanProperties(Object bean) { + try { + return Arrays.stream(Introspector.getBeanInfo(bean.getClass(), Object.class).getPropertyDescriptors()).collect(Collectors.toMap(PropertyDescriptor::getName, Function.identity())); + } catch (IntrospectionException e) { + throw new RuntimeException(e); + } + } + + // https://stackoverflow.com/a/8524043 + public static Map getBeanPropertyValues(Object bean) { + return getBeanProperties(bean).values().stream().filter(pd -> Objects.nonNull(pd.getReadMethod())).collect(HashMap::new, (map, pd) -> { + Object value = null; + try { + value = pd.getReadMethod().invoke(bean); + } catch (Exception ignored) { + } + map.put(pd.getName(), value); + }, Map::putAll); + } + + public static Map getBeanGettersSetters(Object bean) { + return getBeanProperties(bean).values().stream().filter(pd -> Objects.nonNull(pd.getReadMethod())).collect(HashMap::new, (map, pd) -> map.put(pd.getReadMethod(), pd.getWriteMethod()), Map::putAll); + } +} diff --git a/app/org/omg/sysml/metamodel/MofObject.java b/app/org/omg/sysml/metamodel/MofObject.java index 6120dfa4..755a7b49 100644 --- a/app/org/omg/sysml/metamodel/MofObject.java +++ b/app/org/omg/sysml/metamodel/MofObject.java @@ -2,4 +2,6 @@ public interface MofObject { java.util.UUID getId(); + + java.util.UUID getIdentifier(); } \ No newline at end of file From 1dc6ef82526320b3a083e8466a2d5ae402ba71ae Mon Sep 17 00:00:00 2001 From: Ivan Gomes Date: Sun, 9 Feb 2020 17:19:50 -0800 Subject: [PATCH 12/14] Add findHeadByProject endpoint. Force loading of proxies in Commits. Default Commit#previousCommit to HEAD. --- app/controllers/CommitController.java | 5 ++ app/dao/CommitDao.java | 2 + app/dao/impl/jpa/JpaCommitDao.java | 106 ++++++++++++++++---------- app/dao/impl/jpa/JpaElementDao.java | 10 ++- app/services/CommitService.java | 8 +- conf/routes | 1 + public/swagger/openapi.yaml | 27 +++++++ 7 files changed, 114 insertions(+), 45 deletions(-) diff --git a/app/controllers/CommitController.java b/app/controllers/CommitController.java index 7f6155da..3b7fe9f6 100644 --- a/app/controllers/CommitController.java +++ b/app/controllers/CommitController.java @@ -67,4 +67,9 @@ public Result byProjectAndId(UUID projectId, UUID commitId) { Optional commit = commitService.getByProjectIdAndId(projectId, commitId); return commit.map(e -> ok(Json.toJson(e))).orElseGet(Results::notFound); } + + public Result headByProject(UUID projectId) { + Optional commit = commitService.getHeadByProjectId(projectId); + return commit.map(e -> ok(Json.toJson(e))).orElseGet(Results::notFound); + } } diff --git a/app/dao/CommitDao.java b/app/dao/CommitDao.java index fa2ceb22..edd9af0c 100644 --- a/app/dao/CommitDao.java +++ b/app/dao/CommitDao.java @@ -23,4 +23,6 @@ public interface CommitDao extends Dao { List findAllByProject(Project project); Optional findByProjectAndId(Project project, UUID id); + + Optional findHeadByProject(Project project); } diff --git a/app/dao/impl/jpa/JpaCommitDao.java b/app/dao/impl/jpa/JpaCommitDao.java index 127b18c8..c94e322f 100644 --- a/app/dao/impl/jpa/JpaCommitDao.java +++ b/app/dao/impl/jpa/JpaCommitDao.java @@ -10,6 +10,7 @@ import org.omg.sysml.lifecycle.impl.CommitImpl_; import org.omg.sysml.lifecycle.impl.ElementIdentityImpl; import org.omg.sysml.lifecycle.impl.ElementVersionImpl; +import org.omg.sysml.metamodel.Element; import org.omg.sysml.metamodel.MofObject; import org.omg.sysml.metamodel.impl.MofObjectImpl; @@ -22,6 +23,7 @@ import javax.persistence.criteria.Root; import java.lang.reflect.Method; import java.util.*; +import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Collectors; @@ -29,6 +31,9 @@ @Singleton public class JpaCommitDao extends JpaDao implements CommitDao { + // TODO Explore alternative to serializing lazy entity attributes that doesn't involve resolving all proxies one level. + static Consumer PROXY_RESOLVER = commit -> commit.getChanges().stream().filter(Objects::nonNull).map(ElementVersion::getData).filter(mof -> mof instanceof Element).map(mof -> (Element) mof).forEach(JpaElementDao.PROXY_RESOLVER); + @Inject private JPAManager jpa; @@ -88,47 +93,45 @@ public UUID getId() { } return reattachedMof; }; - changeStream.get().map(ElementVersion::getData).filter(Objects::nonNull).forEach(mof -> { - JavaBeanHelper.getBeanProperties(mof).values().stream().filter(property -> property.getReadMethod() != null && property.getWriteMethod() != null).forEach(property -> { - Method getter = property.getReadMethod(); - Method setter = property.getWriteMethod(); - Class type = property.getPropertyType(); + changeStream.get().map(ElementVersion::getData).filter(Objects::nonNull).forEach(mof -> JavaBeanHelper.getBeanProperties(mof).values().stream().filter(property -> property.getReadMethod() != null && property.getWriteMethod() != null).forEach(property -> { + Method getter = property.getReadMethod(); + Method setter = property.getWriteMethod(); + Class type = property.getPropertyType(); - Object originalValue; - try { - originalValue = getter.invoke(mof); - final Object newValue; - if (MofObject.class.isAssignableFrom(type)) { - if (!(originalValue instanceof MofObject)) { - return; - } - newValue = reattachMofFunction.apply((MofObject) originalValue); + Object originalValue; + try { + originalValue = getter.invoke(mof); + final Object newValue; + if (MofObject.class.isAssignableFrom(type)) { + if (!(originalValue instanceof MofObject)) { + return; + } + newValue = reattachMofFunction.apply((MofObject) originalValue); + } else if (Collection.class.isAssignableFrom(type)) { + Collection originalValueCollection = (Collection) originalValue; + if (originalValueCollection.isEmpty() || originalValueCollection.stream().anyMatch((o -> !(o instanceof MofObject)))) { + return; + } + final Collection newValueCollection; + if (List.class.isAssignableFrom(type)) { + newValueCollection = new ArrayList<>(); + } else if (Set.class.isAssignableFrom(type)) { + newValueCollection = new HashSet<>(); } else if (Collection.class.isAssignableFrom(type)) { - Collection originalValueCollection = (Collection) originalValue; - if (originalValueCollection.isEmpty() || originalValueCollection.stream().anyMatch((o -> !(o instanceof MofObject)))) { - return; - } - final Collection newValueCollection; - if (List.class.isAssignableFrom(type)) { - newValueCollection = new ArrayList<>(); - } else if (Set.class.isAssignableFrom(type)) { - newValueCollection = new HashSet<>(); - } else if (Collection.class.isAssignableFrom(type)) { - newValueCollection = new ArrayList<>(); - } else { - throw new IllegalStateException("Unknown collection type."); - } - ((Collection) originalValue).stream().map(o -> (MofObject) o).map(reattachMofFunction).forEachOrdered(newValueCollection::add); - newValue = newValueCollection; + newValueCollection = new ArrayList<>(); } else { - return; + throw new IllegalStateException("Unknown collection type."); } - setter.invoke(mof, newValue); - } catch (ReflectiveOperationException e) { - throw new RuntimeException(e); + ((Collection) originalValue).stream().map(o -> (MofObject) o).map(reattachMofFunction).forEachOrdered(newValueCollection::add); + newValue = newValueCollection; + } else { + return; } - }); - }); + setter.invoke(mof, newValue); + } catch (ReflectiveOperationException e) { + throw new RuntimeException(e); + } + })); /* changeStream.get().map(ElementVersion::getData).filter(Objects::nonNull).filter(element -> element instanceof BlockImpl).map(element -> (BlockImpl) element).forEach(block -> { if (block.getOwner() instanceof MofObjectImpl) { @@ -139,9 +142,11 @@ public UUID getId() { } });*/ - if (!(commit instanceof CommitImpl)) { - throw new IllegalStateException(); + // If previousCommit is not specified, default to head commit. + if (commit.getPreviousCommit() == null && commit.getContainingProject() != null) { + findHeadByProject(commit.getContainingProject()).ifPresent(commit::setPreviousCommit); } + return jpa.transact(em -> { commit.getChanges().stream().map(ElementVersion::getData).filter(mof -> mof instanceof MofObjectImpl).map(mof -> (MofObjectImpl) mof).map(mof -> { try { @@ -216,11 +221,34 @@ public Optional findByProjectAndId(Project project, UUID id) { builder.equal(root.get(CommitImpl_.containingProject), project), builder.equal(root.get(CommitImpl_.id), id) )); + Optional commit; try { - return Optional.of(em.createQuery(query).getSingleResult()); + commit = Optional.of(em.createQuery(query).getSingleResult()); + } catch (NoResultException e) { + return Optional.empty(); + } + commit.ifPresent(PROXY_RESOLVER); + return commit; + }); + } + + @Override + public Optional findHeadByProject(Project project) { + return jpa.transact(em -> { + CriteriaBuilder builder = em.getCriteriaBuilder(); + CriteriaQuery query = builder.createQuery(CommitImpl.class); + Root root = query.from(CommitImpl.class); + query.select(root) + .where(builder.equal(root.get(CommitImpl_.containingProject), project)) + .orderBy(builder.desc(root.get(CommitImpl_.timestamp))); + Optional commit; + try { + commit = Optional.of(em.createQuery(query).setMaxResults(1).getSingleResult()); } catch (NoResultException e) { return Optional.empty(); } + commit.ifPresent(PROXY_RESOLVER); + return commit; }); } diff --git a/app/dao/impl/jpa/JpaElementDao.java b/app/dao/impl/jpa/JpaElementDao.java index 0784b685..ad79b6c0 100644 --- a/app/dao/impl/jpa/JpaElementDao.java +++ b/app/dao/impl/jpa/JpaElementDao.java @@ -14,12 +14,16 @@ import javax.persistence.NoResultException; import javax.persistence.criteria.*; import java.util.*; +import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @Singleton public class JpaElementDao extends JpaDao implements ElementDao { + // TODO Explore alternative to serializing lazy entity attributes that doesn't involve resolving all proxies one level. + static Consumer PROXY_RESOLVER = element -> JavaBeanHelper.getBeanPropertyValues(element).values().stream().flatMap(o -> o instanceof Collection ? ((Collection) o).stream() : Stream.of(o)).forEach(o -> {}); + @Inject private MetamodelProvider metamodelProvider; @@ -76,8 +80,7 @@ public Set findAllByCommit(Commit commit) { return jpa.transact(em -> { // TODO Commit is detached at this point. This ternary mitigates by requerying for the Commit in this transaction. A better solution would be moving transaction handling up to service layer (supported by general wisdom) and optionally migrating to using Play's @Transactional/JPAApi. Pros would include removal of repetitive transaction handling at the DAO layer and ability to interface with multiple DAOs in the same transaction (consistent view). Cons include increased temptation to keep transaction open for longer than needed, e.g. during JSON serialization due to the convenience of @Transactional (deprecated in >= 2.8.x), and the service, a higher level of abstraction, becoming aware of transactions. An alternative would be DAO-to-DAO calls (generally discouraged) and delegating to non-transactional versions of methods. Commit c = em.contains(commit) ? commit : em.find(metamodelProvider.getImplementationClass(Commit.class), commit.getId()); - // TODO Explore alternative to serializing lazy entity attributes that doesn't involve resolving all proxies one level. - return streamFlattenedElements(c).peek(e -> JavaBeanHelper.getBeanPropertyValues(e).values().stream().flatMap(o -> o instanceof Collection ? ((Collection) o).stream() : Stream.of(o)).forEach(o -> {})).collect(Collectors.toSet()); + return streamFlattenedElements(c).peek(PROXY_RESOLVER).collect(Collectors.toSet()); }); } @@ -87,8 +90,7 @@ public Optional findByCommitAndId(Commit commit, UUID id) { return queryCommitTree(em.contains(commit) ? commit : em.find(metamodelProvider.getImplementationClass(Commit.class), commit.getId()), c -> c.getChanges().stream().filter(record -> record.getIdentity() != null && record.getIdentity().getId() != null && record.getData() instanceof Element).filter(record -> id.equals(record.getIdentity().getId())).map(record -> (Element) record.getData()).findAny(), Optional::isPresent) - // TODO Explore alternative to serializing lazy entity attributes that doesn't involve resolving all proxies one level. - .values().stream().filter(Optional::isPresent).peek(e -> JavaBeanHelper.getBeanPropertyValues(e).values().stream().flatMap(o -> o instanceof Collection ? ((Collection) o).stream() : Stream.of(o)).forEach(o -> {})).map(Optional::get).findAny(); + .values().stream().filter(Optional::isPresent).map(Optional::get).peek(PROXY_RESOLVER).findAny(); }); } diff --git a/app/services/CommitService.java b/app/services/CommitService.java index 07df9048..15241d9a 100644 --- a/app/services/CommitService.java +++ b/app/services/CommitService.java @@ -28,11 +28,15 @@ public Optional getById(UUID id) { } public List getByProjectId(UUID projectId) { - return projectDao.findById(projectId).map(m -> commitDao.findAllByProject(m)).orElse(Collections.emptyList()); + return projectDao.findById(projectId).map(commitDao::findAllByProject).orElse(Collections.emptyList()); } public Optional getByProjectIdAndId(UUID projectId, UUID commitId) { - return projectDao.findById(projectId).flatMap(m -> commitDao.findByProjectAndId(m, commitId)); + return projectDao.findById(projectId).flatMap(project -> commitDao.findByProjectAndId(project, commitId)); + } + + public Optional getHeadByProjectId(UUID projectId) { + return projectDao.findById(projectId).flatMap(commitDao::findHeadByProject); } public Optional create(Commit commit) { diff --git a/conf/routes b/conf/routes index 167b6c39..195a31d9 100644 --- a/conf/routes +++ b/conf/routes @@ -14,6 +14,7 @@ GET /projects/:projectId GET /projects/:projectId/commits controllers.CommitController.byProject(projectId : java.util.UUID) POST /projects/:projectId/commits controllers.CommitController.createWithProjectId(projectId : java.util.UUID, request : Request) GET /projects/:projectId/commits/:commitId controllers.CommitController.byProjectAndId(projectId : java.util.UUID, commitId : java.util.UUID) +GET /projects/:projectId/head controllers.CommitController.headByProject(projectId : java.util.UUID) # Element endpoints GET /projects/:projectId/commits/:commitId/elements controllers.ElementController.getElementsByProjectIdCommitId(projectId : java.util.UUID, commitId : java.util.UUID) diff --git a/public/swagger/openapi.yaml b/public/swagger/openapi.yaml index df7c4116..f525573d 100644 --- a/public/swagger/openapi.yaml +++ b/public/swagger/openapi.yaml @@ -170,6 +170,33 @@ paths: $ref: '#/responses/InternalServerError' default: $ref: '#/responses/Default' + /projects/{projectId}/head: + parameters: + - name: projectId + in: path + description: ID of the project + type: string + required: true + get: + tags: + - Commit + operationId: getHeadCommitByProject + summary: Get head commit by project + produces: + - application/json + responses: + 200: + description: Ok + schema: + $ref: '#/definitions/Commit' + 404: + $ref: '#/responses/NotFound' + 415: + $ref: '#/responses/BadContentType' + 500: + $ref: '#/responses/InternalServerError' + default: + $ref: '#/responses/Default' /projects/{projectId}/commits/{commitId}/elements: parameters: - name: projectId From 86afaf8726abb1a7778ccd780d3b3bb46b9d118b Mon Sep 17 00:00:00 2001 From: Manas Bajaj Date: Tue, 3 Mar 2020 20:51:23 +0530 Subject: [PATCH 13/14] Updates to the gitignore. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e93ce03c..93ecf3be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ logs target +/.bloop /.idea /.idea_modules /.classpath From 5c35907b966bcc65196e25738ffed1eaf7ef5f5b Mon Sep 17 00:00:00 2001 From: Ivan Gomes Date: Wed, 11 Mar 2020 09:53:50 -0700 Subject: [PATCH 14/14] Update version number to 2020-03-rc1 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 2b85202b..0c84c593 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ name := """SysML-v2-API-Services""" organization := "org.omg" -version := "2020-02" +version := "2020-03-rc1" javacOptions ++= Seq("-source", "11", "-target", "11", "-Xlint")