-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
56 changed files
with
1,411 additions
and
596 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
logs | ||
target | ||
/.bloop | ||
/.idea | ||
/.idea_modules | ||
/.classpath | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package controllers; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
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; | ||
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> commit = commitService.getById(uuid); | ||
return commit.map(e -> ok(Json.toJson(e))).orElseGet(Results::notFound); | ||
} | ||
|
||
public Result all() { | ||
List<Commit> 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<Commit> responseCommit = commitService.create(requestedObject); | ||
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<Commit> responseCommit = commitService.create(projectId, requestedObject); | ||
return responseCommit.map(e -> created(Json.toJson(e))).orElseGet(Results::internalServerError); | ||
} | ||
|
||
public Result byProject(UUID projectId) { | ||
List<Commit> commits = commitService.getByProjectId(projectId); | ||
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) { | ||
Optional<Commit> commit = commitService.getByProjectIdAndId(projectId, commitId); | ||
return commit.map(e -> ok(Json.toJson(e))).orElseGet(Results::notFound); | ||
} | ||
|
||
public Result headByProject(UUID projectId) { | ||
Optional<Commit> commit = commitService.getHeadByProjectId(projectId); | ||
return commit.map(e -> ok(Json.toJson(e))).orElseGet(Results::notFound); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dao; | ||
|
||
import org.omg.sysml.lifecycle.Project; | ||
import org.omg.sysml.lifecycle.Commit; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
public interface CommitDao extends Dao<Commit> { | ||
Optional<Commit> persist(Commit commit); | ||
|
||
Optional<Commit> update(Commit commit); | ||
|
||
Optional<Commit> findById(UUID id); | ||
|
||
List<Commit> findAll(); | ||
|
||
void delete(Commit commit); | ||
|
||
void deleteAll(); | ||
|
||
List<Commit> findAllByProject(Project project); | ||
|
||
Optional<Commit> findByProjectAndId(Project project, UUID id); | ||
|
||
Optional<Commit> findHeadByProject(Project project); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
package dao; | ||
|
||
import org.omg.sysml.extension.Project; | ||
import org.omg.sysml.lifecycle.Commit; | ||
import org.omg.sysml.metamodel.Element; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
|
||
public interface ElementDao extends Dao<Element> { | ||
Optional<Element> persist(Element Element); | ||
Optional<Element> persist(Element element); | ||
|
||
Optional<Element> update(Element entity); | ||
Optional<Element> update(Element element); | ||
|
||
Optional<Element> findById(UUID id); | ||
|
||
List<Element> findAll(); | ||
|
||
void delete(Element Element); | ||
void delete(Element element); | ||
|
||
void deleteAll(); | ||
|
||
List<Element> findAllByProject(Project project); | ||
Set<Element> findAllByCommit(Commit commit); | ||
|
||
Optional<Element> findByProjectAndId(Project project, UUID id); | ||
Optional<Element> findByCommitAndId(Commit commit, UUID id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
package dao; | ||
|
||
import org.omg.sysml.extension.Project; | ||
import org.omg.sysml.lifecycle.Project; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
public interface ProjectDao extends Dao<Project> { | ||
Optional<Project> persist(Project Project); | ||
Optional<Project> persist(Project project); | ||
|
||
Optional<Project> update(Project entity); | ||
Optional<Project> update(Project project); | ||
|
||
Optional<Project> findById(UUID id); | ||
|
||
List<Project> findAll(); | ||
|
||
void delete(Project Project); | ||
void delete(Project project); | ||
|
||
void deleteAll(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,27 @@ | ||
package dao; | ||
|
||
import org.omg.sysml.lifecycle.Commit; | ||
import org.omg.sysml.lifecycle.Project; | ||
import org.omg.sysml.metamodel.Element; | ||
import org.omg.sysml.extension.Project; | ||
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<Relationship> { | ||
Optional<Relationship> persist(Relationship Relationship); | ||
Optional<Relationship> persist(Relationship relationship); | ||
|
||
Optional<Relationship> update(Relationship entity); | ||
Optional<Relationship> update(Relationship relationship); | ||
|
||
Optional<Relationship> findById(UUID id); | ||
|
||
List<Relationship> findAll(); | ||
|
||
void delete(Relationship Relationship); | ||
void delete(Relationship relationship); | ||
|
||
void deleteAll(); | ||
|
||
List<Relationship> findAllByRelatedElement(Element element); | ||
|
||
List<Relationship> findAllBySourceElement(Element element); | ||
|
||
List<Relationship> findAllByTargetElement(Element element); | ||
|
||
List<Relationship> findAllByProject(Project project); | ||
Set<Relationship> findAllByCommitRelatedElement(Commit commit, Element relatedElement); | ||
} |
Oops, something went wrong.