2014-10-13 18:55:53 +02:00
|
|
|
package org.gcube.datatransfer.resolver.applicationprofile;
|
|
|
|
|
2016-12-20 15:27:08 +01:00
|
|
|
|
2016-01-14 17:40:47 +01:00
|
|
|
/**
|
|
|
|
* The Class GcubeQuery.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
2016-12-20 15:27:08 +01:00
|
|
|
* Dec 20, 2016
|
2016-01-14 17:40:47 +01:00
|
|
|
*/
|
2014-10-13 18:55:53 +02:00
|
|
|
public class GcubeQuery {
|
2016-01-14 17:40:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-12-20 15:27:08 +01:00
|
|
|
* The Enum FIELD_TYPE.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
|
|
* Dec 20, 2016
|
|
|
|
*/
|
|
|
|
public static enum FIELD_TYPE {RESOURCE_NAME, APP_ID}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the gcube generic resource.
|
2016-01-14 17:40:47 +01:00
|
|
|
*
|
|
|
|
* @param secondaryType the secondary type
|
2016-12-20 15:27:08 +01:00
|
|
|
* @param type the type
|
|
|
|
* @param fieldValue the field value
|
|
|
|
* @return the gcube generic resource
|
2016-01-14 17:40:47 +01:00
|
|
|
*/
|
2016-12-20 15:27:08 +01:00
|
|
|
public static String getGcubeGenericResource(String secondaryType, FIELD_TYPE type, String fieldValue){
|
|
|
|
|
|
|
|
String query = "for $profile in collection('/db/Profiles/GenericResource')//Resource " +
|
|
|
|
"where $profile/Profile/SecondaryType/string() eq '"+secondaryType+"'";
|
|
|
|
switch (type) {
|
|
|
|
case APP_ID:
|
|
|
|
query+= " and $profile/Profile/Body/AppId/string() eq '" + fieldValue + "'";
|
|
|
|
|
|
|
|
break;
|
|
|
|
case RESOURCE_NAME:
|
|
|
|
query+= " and $profile/Profile/Name/string() eq '" + fieldValue + "'";
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-01-14 17:40:47 +01:00
|
|
|
|
2016-12-20 15:27:08 +01:00
|
|
|
return query+=" return $profile";
|
2014-10-13 18:55:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|