46 lines
1.5 KiB
Java
46 lines
1.5 KiB
Java
|
package org.gcube.data.publishing.ckan2zenodo.commons;
|
||
|
|
||
|
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||
|
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||
|
|
||
|
import java.util.List;
|
||
|
|
||
|
import org.gcube.common.resources.gcore.GenericResource;
|
||
|
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||
|
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||
|
|
||
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
||
|
@Slf4j
|
||
|
public class IS {
|
||
|
|
||
|
|
||
|
public static List<GenericResource> queryForGenericResources(String secondaryType){
|
||
|
log.debug("Querying for Service Endpoints [secondary type : {} ]",secondaryType);
|
||
|
|
||
|
SimpleQuery query = queryFor(GenericResource.class);
|
||
|
|
||
|
query.addCondition("$resource/Profile/SecondaryType/text() eq '"+secondaryType+"'");
|
||
|
|
||
|
DiscoveryClient<GenericResource> client = clientFor(GenericResource.class);
|
||
|
|
||
|
return client.submit(query);
|
||
|
}
|
||
|
|
||
|
public static List<ServiceEndpoint> queryForServiceEndpoints(String category, String platformName){
|
||
|
log.debug("Querying for Service Endpoints [category : {} , platformName : {}]",category,platformName);
|
||
|
|
||
|
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||
|
|
||
|
query.addCondition("$resource/Profile/Category/text() eq '"+category+"'")
|
||
|
.addCondition("$resource/Profile/Platform/Name/text() eq '"+platformName+"'");
|
||
|
|
||
|
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||
|
|
||
|
return client.submit(query);
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|