Skip to content

Commit

Permalink
Return SEI instead of only uuid when posting neu SEI - task #1174
Browse files Browse the repository at this point in the history
  • Loading branch information
franzTobiasDLR committed Jan 24, 2024
1 parent 8027909 commit a452c0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import de.dlr.sc.virsat.model.concept.types.factory.BeanStructuralElementInstanceFactory;
import de.dlr.sc.virsat.model.concept.types.roles.BeanDiscipline;
import de.dlr.sc.virsat.model.concept.types.structural.ABeanStructuralElementInstance;
import de.dlr.sc.virsat.model.concept.types.structural.BeanStructuralElementInstance;
import de.dlr.sc.virsat.model.dvlm.Repository;
import de.dlr.sc.virsat.model.dvlm.concepts.Concept;
import de.dlr.sc.virsat.model.dvlm.concepts.registry.ActiveConceptConfigurationElement;
Expand Down Expand Up @@ -363,10 +364,10 @@ public Response createRootSei(@QueryParam(value = ModelAccessResource.QP_FULL_QU
try {
serverRepository.syncRepository();

String newSeiUuid = createSeiFromFqn(fullQualifiedName, repository, ed, userContext);
BeanStructuralElementInstance newSeiBean = createSeiFromFqn(fullQualifiedName, repository, ed, userContext);

serverRepository.syncRepository();
return Response.ok(newSeiUuid).build();
return Response.ok(newSeiBean).build();
} catch (Exception e) {
return ApiErrorHelper.createInternalErrorResponse(e.getMessage());
}
Expand Down Expand Up @@ -551,7 +552,7 @@ public Response getRepositpryDiscipline() {
* @param iUserContext the user context
* @return uuid of the created sei
*/
public static String createSeiFromFqn(String fullQualifiedName, EObject owner, VirSatTransactionalEditingDomain editingDomain, IUserContext iUserContext) {
public static BeanStructuralElementInstance createSeiFromFqn(String fullQualifiedName, EObject owner, VirSatTransactionalEditingDomain editingDomain, IUserContext iUserContext) {
ActiveConceptHelper helper = new ActiveConceptHelper(editingDomain.getResourceSet().getRepository());
StructuralElement se = helper.getStructuralElement(fullQualifiedName);
StructuralElementInstance newSei = new StructuralInstantiator().generateInstance(se, null);
Expand All @@ -564,6 +565,6 @@ public static String createSeiFromFqn(String fullQualifiedName, EObject owner, V
Command createCommand = CreateAddSeiWithFileStructureCommand.create(editingDomain, owner, newSei);
ApiErrorHelper.executeCommandIffCanExecute(createCommand, editingDomain, iUserContext);

return newSei.getUuid().toString();
return new BeanStructuralElementInstance(newSei);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import de.dlr.sc.virsat.model.concept.types.factory.BeanStructuralElementInstanceFactory;
import de.dlr.sc.virsat.model.concept.types.structural.ABeanStructuralElementInstance;
import de.dlr.sc.virsat.model.concept.types.structural.BeanStructuralElementInstance;
import de.dlr.sc.virsat.model.concept.types.structural.IBeanStructuralElementInstance;
import de.dlr.sc.virsat.model.dvlm.structural.StructuralElementInstance;
import de.dlr.sc.virsat.project.structure.command.CreateRemoveSeiWithFileStructureCommand;
Expand Down Expand Up @@ -146,10 +147,10 @@ public Response createSei(@PathParam("seiUuid") @ApiParam(value = "parent uuid",
if (parentSei == null) {
return ApiErrorHelper.createNotFoundErrorResponse();
}
String newSeiUuid = ModelAccessResource.createSeiFromFqn(fullQualifiedName, parentSei, parentResource.getEd(), parentResource.getUser());
BeanStructuralElementInstance newSeiBean = ModelAccessResource.createSeiFromFqn(fullQualifiedName, parentSei, parentResource.getEd(), parentResource.getUser());

parentResource.synchronize();
return Response.ok(newSeiUuid).build();
return Response.ok(newSeiBean).build();
} catch (Exception e) {
return ApiErrorHelper.createInternalErrorResponse(e.getMessage());
}
Expand Down

0 comments on commit a452c0b

Please sign in to comment.