Skip to content

Commit

Permalink
Merge branch 'release/2022-11-rc1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-gomes committed Dec 4, 2022
2 parents f93ff1e + d6af615 commit 32a24c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions app/dao/impl/jpa/JpaRelationshipDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import config.MetamodelProvider;
import dao.RelationshipDao;
import jpa.manager.JPAManager;
import org.omg.sysml.internal.WorkingDataVersion;
import org.omg.sysml.lifecycle.Commit;
import org.omg.sysml.lifecycle.DataVersion;
import org.omg.sysml.lifecycle.impl.CommitImpl;
Expand Down Expand Up @@ -127,8 +128,10 @@ public List<Relationship> findAllByCommitRelatedElement(Commit commit, Element r
// Reverting to non-relational streaming
// 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(CommitImpl.class, commit.getId());
return dataDao.findChangesByCommit(c, after, before, maxResults, excludeUsed, em)
.stream()
Stream<Relationship> stream = dataDao.getCommitIndex(c, em).getWorkingDataVersion().stream()
.filter(working -> !excludeUsed || working.getSource() == null)
.map(WorkingDataVersion::getDataVersion)
// return dataDao.findChangesByCommit(c, after, before, maxResults, excludeUsed, em).stream()
.map(DataVersion::getPayload)
.filter(data -> data instanceof Relationship)
.map(data -> (Relationship) data)
Expand All @@ -152,8 +155,16 @@ public List<Relationship> findAllByCommitRelatedElement(Commit commit, Element r
.anyMatch(id -> id.equals(relatedElement.getElementId()));
}
)
.map(relationship -> JpaDataDao.resolve(relationship, Relationship.class));
// .collect(Collectors.toList());
Paginated<Stream<Relationship>> paginatedStream = paginateStream(after, before, maxResults, stream, Relationship::getElementId);
List<Relationship> result = paginatedStream.get()
.map(relationship -> JpaDataDao.resolve(relationship, Relationship.class))
.collect(Collectors.toList());
if (paginatedStream.isReversed()) {
Collections.reverse(result);
}
return result;
});
}

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name := """SysML-v2-API-Services"""
organization := "org.omg"

version := "2022-10"
version := "2022-11-rc1"

javacOptions ++= Seq("-source", "11", "-target", "11", "-Xlint")

Expand Down

0 comments on commit 32a24c1

Please sign in to comment.