Skip to content

Commit 6461883

Browse files
committed
Merge branch 'develop'
2 parents 2e2381a + de8b91e commit 6461883

6 files changed

Lines changed: 23 additions & 12 deletions

File tree

app/controllers/CommitController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ public Result byProjectAndId(UUID projectId, UUID commitId) {
7070

7171
public Result headByProject(UUID projectId) {
7272
Optional<Commit> commit = commitService.getHeadByProjectId(projectId);
73-
return commit.map(e -> ok(Json.toJson(e))).orElseGet(Results::notFound);
73+
return commit.map(e -> ok(JacksonHelper.valueToTree(commit, writer -> writer.withView(CommitImpl.Views.Compact.class)))).orElseGet(Results::notFound);
7474
}
7575
}

app/dao/impl/jpa/JpaCommitDao.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ protected JPAManager getJpaManager() {
4747

4848
@Override
4949
public Optional<Commit> persist(Commit commit) {
50+
// If previousCommit is not specified, default to head commit.
51+
if (commit.getPreviousCommit() == null && commit.getContainingProject() != null) {
52+
findHeadByProject(commit.getContainingProject()).ifPresent(commit::setPreviousCommit);
53+
}
54+
5055
MofObject tombstone = new MofObjectImpl() {
5156
UUID id = UUID.randomUUID();
5257

@@ -143,11 +148,6 @@ public UUID getId() {
143148
}
144149
});*/
145150

146-
// If previousCommit is not specified, default to head commit.
147-
if (commit.getPreviousCommit() == null && commit.getContainingProject() != null) {
148-
findHeadByProject(commit.getContainingProject()).ifPresent(commit::setPreviousCommit);
149-
}
150-
151151
return jpa.transact(em -> {
152152
commit.getChanges().stream().map(ElementVersion::getData).filter(mof -> mof instanceof MofObjectImpl).map(mof -> (MofObjectImpl) mof).map(mof -> {
153153
try {

app/jackson/JacksonHelper.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,12 @@ public static JsonNode collectionValueToTree(@SuppressWarnings("rawtypes") Class
2323
throw new RuntimeException(e);
2424
}
2525
}
26+
27+
public static JsonNode valueToTree(Object value, Function<ObjectWriter, ObjectWriter> objectWriterFunction) {
28+
try {
29+
return Json.mapper().readTree(objectWriterFunction.apply(Json.mapper().writer()).writeValueAsBytes(value));
30+
} catch (IOException e) {
31+
throw new RuntimeException(e);
32+
}
33+
}
2634
}

app/jackson/MofObjectDeserializer.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.fasterxml.jackson.databind.deser.ContextualDeserializer;
1111
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
1212
import com.fasterxml.jackson.databind.jsontype.TypeDeserializer;
13+
import javassist.util.proxy.ProxyFactory;
1314
import org.omg.sysml.metamodel.impl.MofObjectImpl;
1415

1516
import javax.persistence.EntityManager;
@@ -22,7 +23,7 @@ public class MofObjectDeserializer extends StdDeserializer<MofObjectImpl> implem
2223
private EntityManager entityManager;
2324
private JavaType type;
2425

25-
//private static Map<Class<?>, Class<?>> PROXY_MAP = new HashMap<>();
26+
private static Map<Class<?>, Class<?>> PROXY_MAP = new HashMap<>();
2627

2728
public MofObjectDeserializer(EntityManager entityManager) {
2829
this(entityManager, null);
@@ -45,14 +46,15 @@ public MofObjectImpl deserialize(JsonParser p, DeserializationContext ctxt) thro
4546
}
4647

4748
MofObjectImpl mof;
48-
/* Class<?> proxyClass = PROXY_MAP.computeIfAbsent(type.getRawClass(), clazz -> {
49+
// Proxy class to handle abstract classes
50+
Class<?> proxyClass = PROXY_MAP.computeIfAbsent(type.getRawClass(), clazz -> {
4951
ProxyFactory factory = new ProxyFactory();
5052
factory.setSuperclass(clazz);
5153
return factory.createClass();
52-
});*/
54+
});
5355
try {
54-
//mof = (MofObjectImpl) proxyClass.getConstructor().newInstance();
55-
mof = (MofObjectImpl) type.getRawClass().getConstructor().newInstance();
56+
mof = (MofObjectImpl) proxyClass.getConstructor().newInstance();
57+
//mof = (MofObjectImpl) type.getRawClass().getConstructor().newInstance();
5658
} catch (ReflectiveOperationException e) {
5759
throw new IOException(e);
5860
}

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name := """SysML-v2-API-Services"""
22
organization := "org.omg"
33

4-
version := "2020-03-rc2"
4+
version := "2020-03-rc3"
55

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

conf/application.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ play.modules.enabled += "play.modules.swagger.SwaggerModule"
66
play.filters.headers.contentSecurityPolicy = null
77
play.filters.disabled+=play.filters.csrf.CSRFFilter
88
play.http.errorHandler = play.api.http.HtmlOrJsonHttpErrorHandler
9+
play.http.parser.maxMemoryBuffer=1G
910

1011
# https://www.playframework.com/documentation/2.7.x/JavaJPA
1112
db.default.jndiName=DefaultDS

0 commit comments

Comments
 (0)