report model added

This commit is contained in:
lucio.lelii 2020-12-23 10:42:50 +01:00
parent 81db29fdf9
commit bb0d641c12
11 changed files with 185 additions and 27 deletions

View File

@ -21,7 +21,7 @@
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="owner.project.facets" value="java"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>

View File

@ -1,21 +0,0 @@
package org.gcube.vremanagement.contextmanager.model.collectors;
import java.util.List;
import org.gcube.common.resources.gcore.Resource;
public interface BackendConnector {
Resource find(String resourceId);
String createContext(String contextName, String parentContextId, List<String> resourceIds);
boolean removeContext(String contextId);
boolean addResourceToContext(String contextId, Resource resource);
boolean removeResourceFromContext(String contextId, Resource resource);
boolean updateResource(Resource resource);
}

View File

@ -0,0 +1,22 @@
package org.gcube.vremanagement.contextmanager.model.collectors;
import java.util.List;
import org.gcube.common.resources.gcore.Resource;
import org.gcube.vremanagement.contextmanager.model.types.Context;
public interface CollectorsBackend {
Resource find(String resourceId);
void createContext(Context context, String parentContextId, List<String> resourceIds);
boolean removeContext(Context context);
boolean addResourceToContext(Context context, Resource resource) throws Exception;
boolean removeResourceFromContext(Context context, Resource resource);
boolean updateResource(Resource resource);
}

View File

@ -1,11 +1,15 @@
package org.gcube.vremanagement.contextmanager.model.operators.context;
import org.gcube.vremanagement.contextmanager.model.operators.OperationParameters;
import org.gcube.vremanagement.contextmanager.model.types.Context;
public abstract interface ContextOperator {
public interface ContextOperator {
public void onCreateContext(String token, String context, OperationParameters parameters);
Context.Type getApplicationContextType();
public void onDisposeContext(String token, String context, OperationParameters parameters);
String getOperationId();
String getName();
String getDescription();
}

View File

@ -1,5 +1,12 @@
package org.gcube.vremanagement.contextmanager.model.operators.context;
import org.gcube.vremanagement.contextmanager.model.report.OperationResult;
import org.gcube.vremanagement.contextmanager.model.types.Context;
public interface MandatoryContextOperator extends ContextOperator {
OperationResult onCreate(Context context);
OperationResult onDispose(Context context);
}

View File

@ -0,0 +1,42 @@
package org.gcube.vremanagement.contextmanager.model.report;
import java.util.Arrays;
import java.util.List;
public class OperationResult {
public static OperationResult failure(String... errors ){
return new OperationResult(Arrays.asList(errors));
}
public static OperationResult success(){
return new OperationResult();
}
public enum Status {
SUCCESS,
FAILURE
}
private Status status;
private List<String> errors;
private OperationResult() {
this.status = Status.SUCCESS;
}
private OperationResult(List<String> errors) {
super();
this.status = Status.FAILURE;
}
public boolean isSuccess() {
return status==Status.SUCCESS;
}
public List<String> getErrors() {
return errors;
}
}

View File

@ -0,0 +1,14 @@
package org.gcube.vremanagement.contextmanager.model.report;
import java.util.LinkedList;
import java.util.List;
public class Report {
String contextName;
String contextType;
private List<ReportOperation> entries = new LinkedList<>();
}

View File

@ -0,0 +1,48 @@
package org.gcube.vremanagement.contextmanager.model.report;
import org.gcube.vremanagement.contextmanager.model.operators.OperationParameters;
public class ReportEntry implements ReportOperation{
private String operationId;
private String name;
private String description;
private OperationParameters parameters;
private OperationResult result;
protected ReportEntry() {}
public ReportEntry(String operationId, String name, String description, OperationResult result) {
super();
this.operationId = operationId;
this.name = name;
this.description = description;
this.result = result;
}
public ReportEntry(String operationId, String name, String description, OperationResult result, OperationParameters parameters) {
this(operationId, name, description, result);
this.parameters = parameters;
}
public String getOperationId() {
return operationId;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public OperationParameters getParameters() {
return parameters;
}
public OperationResult getResult() {
return result;
}
}

View File

@ -0,0 +1,31 @@
package org.gcube.vremanagement.contextmanager.model.report;
import java.util.LinkedList;
import java.util.List;
public class ReportGroup implements ReportOperation{
private String name;
private String description;
protected ReportGroup() {}
private List<ReportEntry> entries = new LinkedList<>();
public ReportGroup(String name, String description) {
this.name = name;
this.description = description;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public void addEntry(ReportEntry entry) {
entries.add(entry);
}
}

View File

@ -0,0 +1,5 @@
package org.gcube.vremanagement.contextmanager.model.report;
public interface ReportOperation {
}

View File

@ -4,6 +4,7 @@ public class Context {
private String id;
private String name;
private Context parent;
public enum Type {
INFRASTRUCTURE(null),
@ -23,11 +24,12 @@ public class Context {
private Type type;
public Context(String id, String name, Type type) {
public Context(Context parent, String id, String name, Type type) {
super();
this.id = id;
this.name = name;
this.type = type;
this.parent = parent;
}
public String getId() {
@ -41,6 +43,10 @@ public class Context {
public Type getType() {
return type;
}
public Context getParent() {
return parent;
}
@Override
public String toString() {