Refs #10238: Refactor Context Port Type
Task-Url: https://support.d4science.org/issues/10238 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@158787 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
bdf17da9aa
commit
d9fe526386
|
@ -3,6 +3,7 @@ package org.gcube.informationsystem.resourceregistry.context;
|
|||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.codehaus.jettison.json.JSONArray;
|
||||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.gcube.informationsystem.model.AccessType;
|
||||
|
@ -38,10 +39,12 @@ public class ContextManagement extends EntityManagement<Context> {
|
|||
protected String name;
|
||||
|
||||
private void init() {
|
||||
forceAdmin = true;
|
||||
this.forceAdmin = true;
|
||||
|
||||
this.ignoreStartWithKeys.add(Context.PARENT_PROPERTY);
|
||||
this.ignoreStartWithKeys.add(Context.CHILDREN_PROPERTY);
|
||||
|
||||
this.erType = Context.NAME;
|
||||
}
|
||||
|
||||
public ContextManagement() {
|
||||
|
@ -337,5 +340,23 @@ public class ContextManagement extends EntityManagement<Context> {
|
|||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String reallyGetAll(boolean polymorphic) throws ResourceRegistryException {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
Iterable<Vertex> iterable = orientGraph.getVerticesOfClass(erType, polymorphic);
|
||||
for(Vertex vertex : iterable){
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setElement(vertex);
|
||||
try {
|
||||
JSONObject jsonObject = contextManagement.serializeAsJson();
|
||||
jsonArray.put(jsonObject);
|
||||
}catch (ResourceRegistryException e) {
|
||||
logger.error("Unable to correctly serialize {}. It will be excluded from results. {}",
|
||||
vertex.toString(), Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
return jsonArray.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -378,6 +378,17 @@ public class ContextManagementTest {
|
|||
delete(contextA1);
|
||||
logger.debug("The DB should be now clean");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAll() throws Exception {
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
String all = contextManagement.all(false);
|
||||
logger.debug(all);
|
||||
List<Context> contexts = ISMapper.unmarshalList(Context.class, all);
|
||||
for(Context context : contexts){
|
||||
logger.debug(ISMapper.marshal(context));
|
||||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void createDevContext() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue