fixing query templates details
This commit is contained in:
parent
f9e474d4cd
commit
c79b579925
|
@ -457,7 +457,11 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
case ModelElement.SUPERTYPES_PROPERTY:
|
||||
Collection<String> supertypes = getCachedType().getSuperTypes();
|
||||
ArrayNode arrayNode = objectMapper.valueToTree(supertypes);
|
||||
objectNode.replace(ModelElement.SUPERTYPES_PROPERTY, arrayNode);
|
||||
if(arrayNode==null || arrayNode.size()==0) {
|
||||
objectNode.remove(ModelElement.SUPERTYPES_PROPERTY);
|
||||
}else {
|
||||
objectNode.replace(ModelElement.SUPERTYPES_PROPERTY, arrayNode);
|
||||
}
|
||||
break;
|
||||
|
||||
case IdentifiableElement.METADATA_PROPERTY:
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.HEAD;
|
||||
|
@ -14,6 +15,7 @@ import javax.ws.rs.PathParam;
|
|||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
@ -21,6 +23,7 @@ import javax.ws.rs.core.UriInfo;
|
|||
|
||||
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.queries.templates.reference.entities.QueryTemplate;
|
||||
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
|
@ -40,6 +43,7 @@ import org.gcube.informationsystem.resourceregistry.instances.model.entities.Res
|
|||
import org.gcube.informationsystem.resourceregistry.queries.Query;
|
||||
import org.gcube.informationsystem.resourceregistry.queries.QueryImpl;
|
||||
import org.gcube.informationsystem.resourceregistry.queries.json.JsonQuery;
|
||||
import org.gcube.informationsystem.resourceregistry.queries.templates.QueryTemplateManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.ServerRequestInfo;
|
||||
import org.gcube.informationsystem.resourceregistry.types.TypeManagement;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
|
@ -130,6 +134,48 @@ public class Access extends BaseRest {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GET /access/query-templates
|
||||
*/
|
||||
@GET
|
||||
@Path(AccessPath.QUERY_TEMPLATES_PATH_PART)
|
||||
@Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8})
|
||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||
public String allQueryTemplates() throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested to read all {}s", QueryTemplate.NAME);
|
||||
CalledMethodProvider.instance.set("listQueryTemplates");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.setAllMeta(true);
|
||||
serverRequestInfo.checkQueryParameter(ContextPath.INCLUDE_META_QUERY_PARAMETER);
|
||||
|
||||
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
|
||||
return queryTemplateManagement.all(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* GET /access/query-templates/{QUERY_TEMPLATE_NAME}
|
||||
* e.g. GET /access/query-templates/GetAllEServiceWithState
|
||||
*/
|
||||
@GET
|
||||
@Path(AccessPath.QUERY_TEMPLATES_PATH_PART + "{" + QueryTemplateManager.QUERY_TEMPLATE_NAME_PATH_PARAMETER + "}")
|
||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||
public String read(@PathParam(QueryTemplateManager.QUERY_TEMPLATE_NAME_PATH_PARAMETER) String queryTemplateName)
|
||||
throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested {} with name", QueryTemplate.NAME, queryTemplateName);
|
||||
CalledMethodProvider.instance.set("readQueryTemplate");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.setAllMeta(true);
|
||||
serverRequestInfo.checkQueryParameter(ContextPath.INCLUDE_META_QUERY_PARAMETER);
|
||||
|
||||
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
|
||||
queryTemplateManagement.setName(queryTemplateName);
|
||||
return queryTemplateManagement.read();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GET /access/instances/{TYPE_NAME}[?polymorphic=true]
|
||||
* e.g. GET /access/instances/ContactFacet?polymorphic=true
|
||||
|
|
|
@ -142,8 +142,7 @@ public class QueryTemplateManager extends BaseRest {
|
|||
CalledMethodProvider.instance.set("readQueryTemplate");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.setAllMeta(true);
|
||||
serverRequestInfo.checkQueryParameter(ContextPath.INCLUDE_META_QUERY_PARAMETER);
|
||||
serverRequestInfo.checkAllQueryParameters();
|
||||
|
||||
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
|
||||
queryTemplateManagement.setName(queryTemplateName);
|
||||
|
|
Loading…
Reference in New Issue