Improving code
This commit is contained in:
parent
d58dcc20cf
commit
151ad9add4
|
@ -173,7 +173,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
||||||
checkJsonNode();
|
checkJsonNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setoDatabaseDocument(ODatabaseDocument oDatabaseDocument) {
|
public void setODatabaseDocument(ODatabaseDocument oDatabaseDocument) {
|
||||||
this.oDatabaseDocument = oDatabaseDocument;
|
this.oDatabaseDocument = oDatabaseDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ public class ElementManagementUtility {
|
||||||
Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
|
Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
|
||||||
throw new ResourceRegistryException(error);
|
throw new ResourceRegistryException(error);
|
||||||
}
|
}
|
||||||
entityManagement.setoDatabaseDocument(oDatabaseDocument);
|
entityManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
entityManagement.setWorkingContext(workingContext);
|
entityManagement.setWorkingContext(workingContext);
|
||||||
entityManagement.setElement(vertex);
|
entityManagement.setElement(vertex);
|
||||||
return entityManagement;
|
return entityManagement;
|
||||||
|
@ -185,7 +185,7 @@ public class ElementManagementUtility {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
relationManagement.setoDatabaseDocument(oDatabaseDocument);
|
relationManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
relationManagement.setWorkingContext(workingContext);
|
relationManagement.setWorkingContext(workingContext);
|
||||||
|
|
||||||
relationManagement.setElement(edge);
|
relationManagement.setElement(edge);
|
||||||
|
|
|
@ -193,7 +193,7 @@ public abstract class RelationElementManagement<SEM extends EntityElementManagem
|
||||||
if(target != null) {
|
if(target != null) {
|
||||||
FacetManagement fm = new FacetManagement();
|
FacetManagement fm = new FacetManagement();
|
||||||
fm.setWorkingContext(getWorkingContext());
|
fm.setWorkingContext(getWorkingContext());
|
||||||
fm.setoDatabaseDocument(oDatabaseDocument);
|
fm.setODatabaseDocument(oDatabaseDocument);
|
||||||
fm.setJsonNode(target);
|
fm.setJsonNode(target);
|
||||||
fm.internalUpdate();
|
fm.internalUpdate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,8 @@ public interface ERManagement {
|
||||||
throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException;
|
throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException;
|
||||||
|
|
||||||
public void sanityCheck() throws SchemaViolationException, ResourceRegistryException;
|
public void sanityCheck() throws SchemaViolationException, ResourceRegistryException;
|
||||||
//public void sanityCheck(Map<UUID, JsonNode> expectedInstances) throws SchemaViolationException, ResourceRegistryException;
|
|
||||||
|
// public void contextSanityCheck(SecurityContext target, Map<UUID, JsonNode> expectedInstances) throws SchemaViolationException, ResourceRegistryException;
|
||||||
|
|
||||||
public AvailableInAnotherContextException getSpecificERAvailableInAnotherContextException(String message);
|
public AvailableInAnotherContextException getSpecificERAvailableInAnotherContextException(String message);
|
||||||
|
|
||||||
|
|
|
@ -38,35 +38,39 @@ public class ERManagementUtility {
|
||||||
|
|
||||||
SecurityContext targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
SecurityContext targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
||||||
|
|
||||||
|
// Map<UUID, JsonNode> enforcedInstances = new HashMap<>();
|
||||||
|
|
||||||
Map<UUID, ElementManagement<?,?>> instancesManagement = new HashMap<>();
|
Map<UUID, ElementManagement<?,?>> instancesManagement = new HashMap<>();
|
||||||
for(UUID uuid : expectedInstances.keySet()) {
|
Set<UUID> uuids = expectedInstances.keySet();
|
||||||
|
for(UUID uuid : uuids) {
|
||||||
String type = expectedInstances.get(uuid).get(Element.CLASS_PROPERTY).asText();
|
String type = expectedInstances.get(uuid).get(Element.CLASS_PROPERTY).asText();
|
||||||
ElementManagement<?,?> elementManagement = ElementManagementUtility.getERManagement(type);
|
ElementManagement<?,?> elementManagement = ElementManagementUtility.getERManagement(type);
|
||||||
elementManagement.setWorkingContext(adminSecurityContext);
|
elementManagement.setWorkingContext(adminSecurityContext);
|
||||||
elementManagement.setoDatabaseDocument(oDatabaseDocument);
|
elementManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
elementManagement.setUUID(uuid);
|
elementManagement.setUUID(uuid);
|
||||||
elementManagement.setElementType(type);
|
elementManagement.setElementType(type);
|
||||||
((ERManagement) elementManagement).setHonourPropagationConstraintsInContextSharing(false);
|
((ERManagement) elementManagement).setHonourPropagationConstraintsInContextSharing(false);
|
||||||
((ERManagement) elementManagement).setDryRunContextSharing(dryRun);
|
((ERManagement) elementManagement).setDryRunContextSharing(dryRun);
|
||||||
|
// enforcedInstances.putAll(((ERManagement) elementManagement).internalAddToContext(targetSecurityContext));
|
||||||
((ERManagement) elementManagement).internalAddToContext(targetSecurityContext);
|
((ERManagement) elementManagement).internalAddToContext(targetSecurityContext);
|
||||||
instancesManagement.put(uuid, elementManagement);
|
instancesManagement.put(uuid, elementManagement);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(UUID uuid : expectedInstances.keySet()) {
|
/*
|
||||||
|
for(UUID uuid : uuids) {
|
||||||
ElementManagement<?,?> elementManagement = instancesManagement.get(uuid);
|
ElementManagement<?,?> elementManagement = instancesManagement.get(uuid);
|
||||||
// TODO
|
((ERManagement) elementManagement).contextSanityCheck(targetSecurityContext, expectedInstances);
|
||||||
elementManagement.sanityCheck();
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Map<UUID,JsonNode> expectedAdditionaInstances = new HashMap<>();
|
|
||||||
SharingOperationValidator operationValidator = new SharingOperationValidator(expectedInstances, SharingOperation.ADD);
|
SharingOperationValidator operationValidator = new SharingOperationValidator(expectedInstances, SharingOperation.ADD);
|
||||||
|
if(operationValidator.isValidOperation(enforcedInstances)) {
|
||||||
if(operationValidator.isValidOperation(affectedInstances)) {
|
|
||||||
oDatabaseDocument.commit();
|
oDatabaseDocument.commit();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
oDatabaseDocument.activateOnCurrentThread();
|
||||||
oDatabaseDocument.commit();
|
oDatabaseDocument.commit();
|
||||||
staticLogger.info("{} successfully added to Context with UUID {} not following Propagation Constraints", instances, contextUUID);
|
staticLogger.info("{} successfully added to Context with UUID {} not following Propagation Constraints", instances, contextUUID);
|
||||||
|
|
||||||
|
@ -113,15 +117,18 @@ public class ERManagementUtility {
|
||||||
|
|
||||||
SecurityContext targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
SecurityContext targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
||||||
|
|
||||||
|
//Map<UUID, JsonNode> enforcedInstances = new HashMap<>();
|
||||||
|
|
||||||
Map<UUID, ElementManagement<?,?>> instancesManagement = new HashMap<>();
|
Map<UUID, ElementManagement<?,?>> instancesManagement = new HashMap<>();
|
||||||
for(UUID uuid : expectedInstances.keySet()) {
|
for(UUID uuid : expectedInstances.keySet()) {
|
||||||
String type = expectedInstances.get(uuid).get(Element.CLASS_PROPERTY).asText();
|
String type = expectedInstances.get(uuid).get(Element.CLASS_PROPERTY).asText();
|
||||||
ElementManagement<?,?> elementManagement = ElementManagementUtility.getERManagement(type);
|
ElementManagement<?,?> elementManagement = ElementManagementUtility.getERManagement(type);
|
||||||
elementManagement.setWorkingContext(adminSecurityContext);
|
elementManagement.setWorkingContext(adminSecurityContext);
|
||||||
elementManagement.setoDatabaseDocument(oDatabaseDocument);
|
elementManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
elementManagement.setUUID(uuid);
|
elementManagement.setUUID(uuid);
|
||||||
((ERManagement) elementManagement).setHonourPropagationConstraintsInContextSharing(false);
|
((ERManagement) elementManagement).setHonourPropagationConstraintsInContextSharing(false);
|
||||||
((ERManagement) elementManagement).setDryRunContextSharing(dryRun);
|
((ERManagement) elementManagement).setDryRunContextSharing(dryRun);
|
||||||
|
//enforcedInstances.putAll(((ERManagement) elementManagement).internalRemoveFromContext(targetSecurityContext));
|
||||||
((ERManagement) elementManagement).internalRemoveFromContext(targetSecurityContext);
|
((ERManagement) elementManagement).internalRemoveFromContext(targetSecurityContext);
|
||||||
instancesManagement.put(uuid, elementManagement);
|
instancesManagement.put(uuid, elementManagement);
|
||||||
}
|
}
|
||||||
|
@ -135,11 +142,12 @@ public class ERManagementUtility {
|
||||||
/*
|
/*
|
||||||
SharingOperationValidator operationValidator = new SharingOperationValidator(expectedInstances, SharingOperation.REMOVE);
|
SharingOperationValidator operationValidator = new SharingOperationValidator(expectedInstances, SharingOperation.REMOVE);
|
||||||
|
|
||||||
if(operationValidator.isValidOperation(affectedInstances)) {
|
if(operationValidator.isValidOperation(enforcedInstances)) {
|
||||||
oDatabaseDocument.commit();
|
oDatabaseDocument.commit();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
oDatabaseDocument.commit();
|
||||||
staticLogger.info("{} successfully removed from Context with UUID {} not following Propagation Constraints", instances, contextUUID);
|
staticLogger.info("{} successfully removed from Context with UUID {} not following Propagation Constraints", instances, contextUUID);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -438,6 +438,8 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
|
|
||||||
Map<UUID,JsonNode> affectedInstances = internalRemoveFromContext(targetSecurityContext);
|
Map<UUID,JsonNode> affectedInstances = internalRemoveFromContext(targetSecurityContext);
|
||||||
|
|
||||||
|
// check here
|
||||||
|
|
||||||
oDatabaseDocument.commit();
|
oDatabaseDocument.commit();
|
||||||
logger.info("{} with UUID {} successfully removed from Context with UUID {}", typeName, uuid, contextUUID);
|
logger.info("{} with UUID {} successfully removed from Context with UUID {}", typeName, uuid, contextUUID);
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
for(JsonNode consistOfJsonNode : jsonNodeArray) {
|
for(JsonNode consistOfJsonNode : jsonNodeArray) {
|
||||||
ConsistsOfManagement com = new ConsistsOfManagement();
|
ConsistsOfManagement com = new ConsistsOfManagement();
|
||||||
com.setWorkingContext(getWorkingContext());
|
com.setWorkingContext(getWorkingContext());
|
||||||
com.setoDatabaseDocument(oDatabaseDocument);
|
com.setODatabaseDocument(oDatabaseDocument);
|
||||||
com.setJsonNode(consistOfJsonNode);
|
com.setJsonNode(consistOfJsonNode);
|
||||||
com.setSourceEntityManagement(this);
|
com.setSourceEntityManagement(this);
|
||||||
com.internalCreate();
|
com.internalCreate();
|
||||||
|
@ -160,7 +160,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
for(JsonNode relationJsonNode : jsonNodeArray) {
|
for(JsonNode relationJsonNode : jsonNodeArray) {
|
||||||
IsRelatedToManagement irtm = new IsRelatedToManagement();
|
IsRelatedToManagement irtm = new IsRelatedToManagement();
|
||||||
irtm.setWorkingContext(getWorkingContext());
|
irtm.setWorkingContext(getWorkingContext());
|
||||||
irtm.setoDatabaseDocument(oDatabaseDocument);
|
irtm.setODatabaseDocument(oDatabaseDocument);
|
||||||
irtm.setJsonNode(relationJsonNode);
|
irtm.setJsonNode(relationJsonNode);
|
||||||
irtm.setSourceEntityManagement(this);
|
irtm.setSourceEntityManagement(this);
|
||||||
irtm.internalCreate();
|
irtm.internalCreate();
|
||||||
|
@ -182,7 +182,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
for(JsonNode relationJsonNode : jsonNodeArray) {
|
for(JsonNode relationJsonNode : jsonNodeArray) {
|
||||||
ConsistsOfManagement com = new ConsistsOfManagement();
|
ConsistsOfManagement com = new ConsistsOfManagement();
|
||||||
com.setWorkingContext(getWorkingContext());
|
com.setWorkingContext(getWorkingContext());
|
||||||
com.setoDatabaseDocument(oDatabaseDocument);
|
com.setODatabaseDocument(oDatabaseDocument);
|
||||||
com.setJsonNode(relationJsonNode);
|
com.setJsonNode(relationJsonNode);
|
||||||
com.internalCreateOrUdate();
|
com.internalCreateOrUdate();
|
||||||
addToRelationManagement(com);
|
addToRelationManagement(com);
|
||||||
|
@ -195,7 +195,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
for(JsonNode relationJsonNode : jsonNodeArray) {
|
for(JsonNode relationJsonNode : jsonNodeArray) {
|
||||||
IsRelatedToManagement irtm = new IsRelatedToManagement();
|
IsRelatedToManagement irtm = new IsRelatedToManagement();
|
||||||
irtm.setWorkingContext(getWorkingContext());
|
irtm.setWorkingContext(getWorkingContext());
|
||||||
irtm.setoDatabaseDocument(oDatabaseDocument);
|
irtm.setODatabaseDocument(oDatabaseDocument);
|
||||||
irtm.setJsonNode(relationJsonNode);
|
irtm.setJsonNode(relationJsonNode);
|
||||||
irtm.internalUpdate();
|
irtm.internalUpdate();
|
||||||
addToRelationManagement(irtm);
|
addToRelationManagement(irtm);
|
||||||
|
@ -231,7 +231,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
}
|
}
|
||||||
if(relationManagement != null) {
|
if(relationManagement != null) {
|
||||||
relationManagement.setWorkingContext(getWorkingContext());
|
relationManagement.setWorkingContext(getWorkingContext());
|
||||||
relationManagement.setoDatabaseDocument(oDatabaseDocument);
|
relationManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
relationManagement.setElement(edge);
|
relationManagement.setElement(edge);
|
||||||
relationManagement.internalDelete();
|
relationManagement.internalDelete();
|
||||||
}
|
}
|
||||||
|
@ -474,8 +474,16 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
stringBuffer.append(").");
|
stringBuffer.append(").");
|
||||||
return stringBuffer.toString();
|
return stringBuffer.toString();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
@Override
|
@Override
|
||||||
|
public void contextSanityCheck(SecurityContext targetSecurityContext, Map<UUID, JsonNode> expectedInstances) throws SchemaViolationException, ResourceRegistryException {
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
public void sanityCheck(Map<UUID, JsonNode> expectedInstances) throws SchemaViolationException, ResourceRegistryException {
|
public void sanityCheck(Map<UUID, JsonNode> expectedInstances) throws SchemaViolationException, ResourceRegistryException {
|
||||||
JsonNode resourceInstance = createCompleteJsonNode();
|
JsonNode resourceInstance = createCompleteJsonNode();
|
||||||
|
|
||||||
|
@ -575,5 +583,4 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class ConsistsOfManagement extends RelationManagement<FacetManagement, Fa
|
||||||
@Override
|
@Override
|
||||||
protected FacetManagement newTargetEntityManagement() throws ResourceRegistryException {
|
protected FacetManagement newTargetEntityManagement() throws ResourceRegistryException {
|
||||||
FacetManagement facetManagement = new FacetManagement();
|
FacetManagement facetManagement = new FacetManagement();
|
||||||
facetManagement.setoDatabaseDocument(oDatabaseDocument);
|
facetManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
facetManagement.setWorkingContext(getWorkingContext());
|
facetManagement.setWorkingContext(getWorkingContext());
|
||||||
return facetManagement;
|
return facetManagement;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class IsRelatedToManagement extends RelationManagement<ResourceManagement
|
||||||
protected ResourceManagement newTargetEntityManagement() throws ResourceRegistryException {
|
protected ResourceManagement newTargetEntityManagement() throws ResourceRegistryException {
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setWorkingContext(getWorkingContext());
|
resourceManagement.setWorkingContext(getWorkingContext());
|
||||||
resourceManagement.setoDatabaseDocument(oDatabaseDocument);
|
resourceManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
return resourceManagement;
|
return resourceManagement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -335,7 +335,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
protected ResourceManagement newSourceEntityManagement() throws ResourceRegistryException {
|
protected ResourceManagement newSourceEntityManagement() throws ResourceRegistryException {
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setWorkingContext(getWorkingContext());
|
resourceManagement.setWorkingContext(getWorkingContext());
|
||||||
resourceManagement.setoDatabaseDocument(oDatabaseDocument);
|
resourceManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
return resourceManagement;
|
return resourceManagement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
if(target != null) {
|
if(target != null) {
|
||||||
FacetManagement facetManagement = new FacetManagement();
|
FacetManagement facetManagement = new FacetManagement();
|
||||||
facetManagement.setWorkingContext(getWorkingContext());
|
facetManagement.setWorkingContext(getWorkingContext());
|
||||||
facetManagement.setoDatabaseDocument(oDatabaseDocument);
|
facetManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
facetManagement.setJsonNode(target);
|
facetManagement.setJsonNode(target);
|
||||||
facetManagement.internalUpdate();
|
facetManagement.internalUpdate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class ConsistsOfTypeDefinitionManagement
|
||||||
protected FacetTypeDefinitionManagement newTargetEntityManagement() throws ResourceRegistryException {
|
protected FacetTypeDefinitionManagement newTargetEntityManagement() throws ResourceRegistryException {
|
||||||
FacetTypeDefinitionManagement ftdm = new FacetTypeDefinitionManagement();
|
FacetTypeDefinitionManagement ftdm = new FacetTypeDefinitionManagement();
|
||||||
ftdm.setWorkingContext(getWorkingContext());
|
ftdm.setWorkingContext(getWorkingContext());
|
||||||
ftdm.setoDatabaseDocument(oDatabaseDocument);
|
ftdm.setODatabaseDocument(oDatabaseDocument);
|
||||||
return ftdm;
|
return ftdm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class IsRelatedToTypeDefinitionManagement
|
||||||
protected ResourceTypeDefinitionManagement newTargetEntityManagement() throws ResourceRegistryException {
|
protected ResourceTypeDefinitionManagement newTargetEntityManagement() throws ResourceRegistryException {
|
||||||
ResourceTypeDefinitionManagement rtdm = new ResourceTypeDefinitionManagement();
|
ResourceTypeDefinitionManagement rtdm = new ResourceTypeDefinitionManagement();
|
||||||
rtdm.setWorkingContext(getWorkingContext());
|
rtdm.setWorkingContext(getWorkingContext());
|
||||||
rtdm.setoDatabaseDocument(oDatabaseDocument);
|
rtdm.setODatabaseDocument(oDatabaseDocument);
|
||||||
return rtdm;
|
return rtdm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ public abstract class RelationTypeDefinitionManagement<T extends EntityTypeDefin
|
||||||
protected ResourceTypeDefinitionManagement newSourceEntityManagement() throws ResourceRegistryException {
|
protected ResourceTypeDefinitionManagement newSourceEntityManagement() throws ResourceRegistryException {
|
||||||
ResourceTypeDefinitionManagement rtdm = new ResourceTypeDefinitionManagement();
|
ResourceTypeDefinitionManagement rtdm = new ResourceTypeDefinitionManagement();
|
||||||
rtdm.setWorkingContext(getWorkingContext());
|
rtdm.setWorkingContext(getWorkingContext());
|
||||||
rtdm.setoDatabaseDocument(oDatabaseDocument);
|
rtdm.setODatabaseDocument(oDatabaseDocument);
|
||||||
return rtdm;
|
return rtdm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue