report model added
This commit is contained in:
parent
81db29fdf9
commit
bb0d641c12
|
@ -21,7 +21,7 @@
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="owner.project.facets" value="java"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
|
|
@ -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);
|
|
||||||
|
|
||||||
}
|
|
|
@ -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);
|
||||||
|
|
||||||
|
}
|
|
@ -1,11 +1,15 @@
|
||||||
package org.gcube.vremanagement.contextmanager.model.operators.context;
|
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();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
package org.gcube.vremanagement.contextmanager.model.operators.context;
|
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 {
|
public interface MandatoryContextOperator extends ContextOperator {
|
||||||
|
|
||||||
|
OperationResult onCreate(Context context);
|
||||||
|
|
||||||
|
OperationResult onDispose(Context context);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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<>();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package org.gcube.vremanagement.contextmanager.model.report;
|
||||||
|
|
||||||
|
public interface ReportOperation {
|
||||||
|
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ public class Context {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String name;
|
private String name;
|
||||||
|
private Context parent;
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
INFRASTRUCTURE(null),
|
INFRASTRUCTURE(null),
|
||||||
|
@ -23,11 +24,12 @@ public class Context {
|
||||||
|
|
||||||
private Type type;
|
private Type type;
|
||||||
|
|
||||||
public Context(String id, String name, Type type) {
|
public Context(Context parent, String id, String name, Type type) {
|
||||||
super();
|
super();
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -41,6 +43,10 @@ public class Context {
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Context getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
Loading…
Reference in New Issue