This commit is contained in:
Fabio Sinibaldi 2019-05-20 16:58:42 +00:00
parent c89eb7d5bd
commit b304a9b78a
14 changed files with 346 additions and 51 deletions

View File

@ -9,6 +9,18 @@
<name>gCat Controller</name> <name>gCat Controller</name>
<description>Controller implementation for GCat Service</description> <description>Controller implementation for GCat Service</description>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId>
<version>LATEST</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
@ -32,6 +44,20 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -63,7 +63,7 @@ public class GCatController implements CatalogueController{
try { try {
builder= factory.newDocumentBuilder(); builder= factory.newDocumentBuilder();
expr= xpath.compile("string(/bookstore/book/title/@lang)"); expr= xpath.compile("string(//metadataformat/@type)");
} catch (ParserConfigurationException | XPathExpressionException e) { } catch (ParserConfigurationException | XPathExpressionException e) {
throw new RuntimeException("Unable to initialize Controller"); throw new RuntimeException("Unable to initialize Controller");
} }
@ -141,7 +141,7 @@ public class GCatController implements CatalogueController{
} }
log.debug("Publishing Item.."); log.debug("Publishing Item..");
String itemResp=createItem(itemNode.asText()); String itemResp=createItem(itemNode.toString(),itemNode.path("name").textValue());
String itemId = getId(itemResp); String itemId = getId(itemResp);
log.debug("Pubilshed Item with ID {} ",itemId); log.debug("Pubilshed Item with ID {} ",itemId);
@ -263,13 +263,17 @@ public class GCatController implements CatalogueController{
} }
private String createItem(String toCreate) throws WrongObjectFormatException, PublicationException{ private String createItem(String toCreate,String name) throws WrongObjectFormatException, PublicationException{
Item item=null; Item item=null;
try{ try{
if(isForcedUrl()) if(isForcedUrl())
item = new Item(getForcedUrl()); item = new Item(getForcedUrl());
else item=new Item(); else item=new Item();
return item.create(toCreate);
if(existsItem(item,name))
return item.update(name, toCreate);
else return item.create(toCreate);
}catch(WebApplicationException e) { }catch(WebApplicationException e) {
handleWebException(e); handleWebException(e);
return null; return null;
@ -280,7 +284,15 @@ public class GCatController implements CatalogueController{
} }
private boolean existsItem(Item item,String name) {
try {
item.read(name);
return true;
}catch(WebApplicationException e) {
log.debug("Read Item returned error. Assuming it's missing ",e);
return false;
}
}
@ -339,6 +351,7 @@ public class GCatController implements CatalogueController{
} }
private static String getId(String publishResponse) { private static String getId(String publishResponse) {
try { try {
return mapper.readTree(publishResponse).path("result").path("id").asText(); return mapper.readTree(publishResponse).path("result").path("id").asText();

View File

@ -1,21 +1,39 @@
{ {
"profile": "<metadataformat type=\"Algorithm\">\n <metadatafield>\n <fieldName>Input Parameter</fieldName>\n <dataType>String</dataType>\n <mandatory>false</mandatory>\n <note>Input parameter expected for the execution of the algorithm</note>\n </metadatafield> \n</metadataformat>", "profileID": "DataMiner Process",
"profile": "<metadataformat type=\"DataMiner Process\">\n\t<metadatafield>\n\t\t<fieldName>Input Parameter</fieldName>\n\t\t<mandatory>false</mandatory>\n\t\t<dataType>String</dataType>\n\t\t<note>Input parameter expected for the execution of the process</note>\n\t</metadatafield>\n\t<metadatafield>\n\t\t<fieldName>Output Parameter</fieldName>\n\t\t<mandatory>false</mandatory>\n\t\t<dataType>String</dataType>\n\t\t<note>Output parameter expected from the execution of the process\n\t\t</note>\n\t</metadatafield>\n\t<metadatafield>\n\t\t<fieldName>Process Author</fieldName>\n\t\t<mandatory>false</mandatory>\n\t\t<dataType>String</dataType>\n\t\t<maxOccurs>*</maxOccurs>\n\t\t<defaultValue />\n\t\t<note>The name of the author, with email and ORCID. The format should\n\t\t\tbe: family, given[, email][, ORCID]. Example: Smith, John,\n\t\t\tjs@acme.org, orcid.org/0000-0002-1825-0097</note>\n\t\t<validator>\n\t\t\t<regularExpression>^[a-zA-ZÀ-ÿ .'-]+, [a-zA-ZÀ-ÿ .'-]+[,\n\t\t\t\t]*([a-zA-Z0-9_!#$%*+=?`{|}~^.-]+@[a-zA-Z0-9À-ÿ.-]+)?[,\n\t\t\t\t]*(orcid.org\\/0000-000(1-[5-9]|2-[0-9]|3-[0-4])\\d\\d\\d-\\d\\d\\d[\\dX])?$</regularExpression>\n\t\t</validator>\n\t</metadatafield>\n</metadataformat>",
"item": "item":
{ {
"name": "step_4_vpa_iccat_bft_e_report_in_nextnext", "name": "grid_cwp_to_coordinates_in_prevre",
"title": "Step 4 Vpa Iccat Bft E Report in NextNext", "title": "Grid Cwp To Coordinates in preVRE",
"description": "ICCAT (Eastern) Bluefin Tuna Stock Assessment. This set of R and Fortran code have been provided by ICCAT and IFremer to execute the whole Stock assessment workflow online integration has been done with the help (mediation) of CNR and IRD", "description": "An algorithm that adds longitude, latitude and resolution columns analysing a column containing FAO Ocean Area codes (CWP format).",
"version": null, "version": null,
"visibility": null, "license_id": "CC-BY-NC-SA-4.0",
"license": "CC-BY-NC-SA-4.0", "author": null,
"author": "gianpaolo.coro", "maintainer": null,
"maintainer": "gianpaolo.coro", "tags": [
"tags": ["Iccat Eastern Bft Stock Assessment"], {
"name": "Geo Processing"
},
{
"name": "preVRE"
},
{
"name": "WPS"
},
{
"name": "Analytics"
}],
"extras": [ "extras": [
{ {
"key": "system", "key": "system:type",
"value": "Algorithm" "value": "DataMiner Process"
}] }],
"private": true
}, },
"resources": [] "resources": [
{
"name": "Gateway Link",
"url": "https://pre.d4science.org/group/prevre/dataminer-manager?OperatorId=org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers.GRID_CWP_TO_COORDINATES",
"description": "Link to the GUI designed to operate with DataMiner"
}]
} }

View File

@ -0,0 +1,101 @@
{
"profile": null,
"item": {
"license_title": "Creative Commons Attribution Share-Alike 4.0",
"maintainer": null,
"searchable": "true",
"relationships_as_object": [],
"private": true,
"maintainer_email": null,
"num_tags": 2,
"metadata_created": "2019-03-19T15:03:28.482434",
"metadata_modified": "2019-03-19T15:03:30.676258",
"author": "luca_frosini",
"author_email": "luca.frosini@gcube.ckan.org",
"state": "active",
"version": null,
"creator_user_id": "287b2eec-4cd7-4e50-817f-e6dce19995c7",
"type": "dataset",
"tags": [
{
"vocabulary_id": null,
"state": "active",
"display_name": "Other",
"id": "8ca635e2-4f72-48ed-8460-6734e9070a00",
"name": "Other"
},
{
"vocabulary_id": null,
"state": "active",
"display_name": "REST",
"id": "3d481290-b3cd-466f-8142-51608c616e60",
"name": "REST"
}
],
"groups": [],
"license_id": "CC-BY-SA-4.0",
"extras": [
{
"key": "FSKX_model_parameters:Input Parameter",
"value": "standard desviation of Temperatures( sdTemp): 2.9 °c( Double)"
},
{
"key": "FSKX_model_parameters:Output Parameter",
"value": ""
},
{
"key": "FSKX_model_scope:Hazard",
"value": ""
},
{
"key": "FSKX_model_scope:Population",
"value": ""
},
{
"key": "FSKX_model_scope:Product",
"value": ""
},
{
"key": "Item URL",
"value": "http://data.d4science.org/ctlg/AGINFRAplusDev/my_first_restful_transaction_model"
},
{
"key": "Model Author",
"value": ""
},
{
"key": "Model Creator",
"value": ""
},
{
"key": "Model ID",
"value": ""
},
{
"key": "Model Language",
"value": "Other"
},
{
"key": "Population",
"value": "Italian"
},
{
"key": "ReadMe",
"value": ""
},
{
"key": "Reference Description",
"value": ""
},
{
"key": "Related Identifier",
"value": ""
},
{
"key": "system:type",
"value": "My Profile"
}
]
},
"resources": null
}

View File

@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse #Generated by Maven Integration for Eclipse
#Wed May 08 18:18:34 CEST 2019 #Mon May 20 17:18:44 CEST 2019
version=1.0.0-SNAPSHOT version=1.0.0-SNAPSHOT
groupId=org.gcube.data-publishing.gCat-Feeder groupId=org.gcube.data-publishing.gCat-Feeder
m2e.projectName=gCat-Controller m2e.projectName=gCat-Controller

View File

@ -9,6 +9,18 @@
<name>gCat Controller</name> <name>gCat Controller</name>
<description>Controller implementation for GCat Service</description> <description>Controller implementation for GCat Service</description>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId>
<version>LATEST</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
@ -32,6 +44,20 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -1,21 +1,39 @@
{ {
"profile": "<metadataformat type=\"Algorithm\">\n <metadatafield>\n <fieldName>Input Parameter</fieldName>\n <dataType>String</dataType>\n <mandatory>false</mandatory>\n <note>Input parameter expected for the execution of the algorithm</note>\n </metadatafield> \n</metadataformat>", "profileID": "DataMiner Process",
"profile": "<metadataformat type=\"DataMiner Process\">\n\t<metadatafield>\n\t\t<fieldName>Input Parameter</fieldName>\n\t\t<mandatory>false</mandatory>\n\t\t<dataType>String</dataType>\n\t\t<note>Input parameter expected for the execution of the process</note>\n\t</metadatafield>\n\t<metadatafield>\n\t\t<fieldName>Output Parameter</fieldName>\n\t\t<mandatory>false</mandatory>\n\t\t<dataType>String</dataType>\n\t\t<note>Output parameter expected from the execution of the process\n\t\t</note>\n\t</metadatafield>\n\t<metadatafield>\n\t\t<fieldName>Process Author</fieldName>\n\t\t<mandatory>false</mandatory>\n\t\t<dataType>String</dataType>\n\t\t<maxOccurs>*</maxOccurs>\n\t\t<defaultValue />\n\t\t<note>The name of the author, with email and ORCID. The format should\n\t\t\tbe: family, given[, email][, ORCID]. Example: Smith, John,\n\t\t\tjs@acme.org, orcid.org/0000-0002-1825-0097</note>\n\t\t<validator>\n\t\t\t<regularExpression>^[a-zA-ZÀ-ÿ .'-]+, [a-zA-ZÀ-ÿ .'-]+[,\n\t\t\t\t]*([a-zA-Z0-9_!#$%*+=?`{|}~^.-]+@[a-zA-Z0-9À-ÿ.-]+)?[,\n\t\t\t\t]*(orcid.org\\/0000-000(1-[5-9]|2-[0-9]|3-[0-4])\\d\\d\\d-\\d\\d\\d[\\dX])?$</regularExpression>\n\t\t</validator>\n\t</metadatafield>\n</metadataformat>",
"item": "item":
{ {
"name": "step_4_vpa_iccat_bft_e_report_in_nextnext", "name": "grid_cwp_to_coordinates_in_prevre",
"title": "Step 4 Vpa Iccat Bft E Report in NextNext", "title": "Grid Cwp To Coordinates in preVRE",
"description": "ICCAT (Eastern) Bluefin Tuna Stock Assessment. This set of R and Fortran code have been provided by ICCAT and IFremer to execute the whole Stock assessment workflow online integration has been done with the help (mediation) of CNR and IRD", "description": "An algorithm that adds longitude, latitude and resolution columns analysing a column containing FAO Ocean Area codes (CWP format).",
"version": null, "version": null,
"visibility": null, "license_id": "CC-BY-NC-SA-4.0",
"license": "CC-BY-NC-SA-4.0", "author": null,
"author": "gianpaolo.coro", "maintainer": null,
"maintainer": "gianpaolo.coro", "tags": [
"tags": ["Iccat Eastern Bft Stock Assessment"], {
"name": "Geo Processing"
},
{
"name": "preVRE"
},
{
"name": "WPS"
},
{
"name": "Analytics"
}],
"extras": [ "extras": [
{ {
"key": "system", "key": "system:type",
"value": "Algorithm" "value": "DataMiner Process"
}] }],
"private": true
}, },
"resources": [] "resources": [
{
"name": "Gateway Link",
"url": "https://pre.d4science.org/group/prevre/dataminer-manager?OperatorId=org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers.GRID_CWP_TO_COORDINATES",
"description": "Link to the GUI designed to operate with DataMiner"
}]
} }

View File

@ -0,0 +1,101 @@
{
"profile": null,
"item": {
"license_title": "Creative Commons Attribution Share-Alike 4.0",
"maintainer": null,
"searchable": "true",
"relationships_as_object": [],
"private": true,
"maintainer_email": null,
"num_tags": 2,
"metadata_created": "2019-03-19T15:03:28.482434",
"metadata_modified": "2019-03-19T15:03:30.676258",
"author": "luca_frosini",
"author_email": "luca.frosini@gcube.ckan.org",
"state": "active",
"version": null,
"creator_user_id": "287b2eec-4cd7-4e50-817f-e6dce19995c7",
"type": "dataset",
"tags": [
{
"vocabulary_id": null,
"state": "active",
"display_name": "Other",
"id": "8ca635e2-4f72-48ed-8460-6734e9070a00",
"name": "Other"
},
{
"vocabulary_id": null,
"state": "active",
"display_name": "REST",
"id": "3d481290-b3cd-466f-8142-51608c616e60",
"name": "REST"
}
],
"groups": [],
"license_id": "CC-BY-SA-4.0",
"extras": [
{
"key": "FSKX_model_parameters:Input Parameter",
"value": "standard desviation of Temperatures( sdTemp): 2.9 °c( Double)"
},
{
"key": "FSKX_model_parameters:Output Parameter",
"value": ""
},
{
"key": "FSKX_model_scope:Hazard",
"value": ""
},
{
"key": "FSKX_model_scope:Population",
"value": ""
},
{
"key": "FSKX_model_scope:Product",
"value": ""
},
{
"key": "Item URL",
"value": "http://data.d4science.org/ctlg/AGINFRAplusDev/my_first_restful_transaction_model"
},
{
"key": "Model Author",
"value": ""
},
{
"key": "Model Creator",
"value": ""
},
{
"key": "Model ID",
"value": ""
},
{
"key": "Model Language",
"value": "Other"
},
{
"key": "Population",
"value": "Italian"
},
{
"key": "ReadMe",
"value": ""
},
{
"key": "Reference Description",
"value": ""
},
{
"key": "Related Identifier",
"value": ""
},
{
"key": "system:type",
"value": "My Profile"
}
]
},
"resources": null
}

View File

@ -4,15 +4,6 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="collectors-plugin-framework-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/collectors-plugin-framework/collectors-plugin-framework">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="commons-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/commons/commons">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="catalogue-plugin-framework-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/catalogue-plugin-framework/catalogue-plugin-framework">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="gCat-Feeder"/> <property name="context-root" value="gCat-Feeder"/>
<property name="java-output-path" value="/gCat-Feeder/target/classes"/> <property name="java-output-path" value="/gCat-Feeder/target/classes"/>
</wb-module> </wb-module>

View File

@ -7,8 +7,8 @@ public interface LocalConfiguration {
public static final String POOL_MIN_IDLE="db.pools.min_total"; public static final String POOL_MIN_IDLE="db.pools.min_total";
public static final String MAPPING_DB_ENDPOINT_NAME="db.ep.name"; public static final String DB_ENDPOINT_NAME="db.ep.name";
public static final String MAPPING_DB_ENDPOINT_CATEGORY="db.ep.category"; public static final String DB_ENDPOINT_CATEGORY="db.ep.category";

View File

@ -59,16 +59,17 @@ public class ConnectionManagerImpl implements ConnectionManager {
@Inject @Inject
private LocalConfiguration configuration; private LocalConfiguration configuration;
private synchronized DatabaseConnectionDescriptor getDB() throws InternalError { private synchronized DatabaseConnectionDescriptor getDB() throws InternalError {
if(!databases.containsKey(infrastructure.getCurrentContext())) if(!databases.containsKey(infrastructure.getCurrentContext()))
databases.put(infrastructure.getCurrentContext(), infrastructure.queryForDatabase( databases.put(infrastructure.getCurrentContext(), infrastructure.queryForDatabase(
configuration.getProperty(LocalConfiguration.MAPPING_DB_ENDPOINT_CATEGORY), configuration.getProperty(LocalConfiguration.DB_ENDPOINT_CATEGORY),
configuration.getProperty(LocalConfiguration.MAPPING_DB_ENDPOINT_NAME))); configuration.getProperty(LocalConfiguration.DB_ENDPOINT_NAME)));
return databases.get(infrastructure.getCurrentContext()); return databases.get(infrastructure.getCurrentContext());
} }
@Override @Override
public Connection getConnection() throws SQLException, InternalError { public Connection getConnection() throws SQLException, InternalError {
log.debug("Getting DB connection in {} ",infrastructure.getCurrentContext());
DataSource ds=getDataSource(); DataSource ds=getDataSource();
Connection conn=ds.getConnection(); Connection conn=ds.getConnection();
conn.setAutoCommit(false); conn.setAutoCommit(false);
@ -119,8 +120,8 @@ public class ConnectionManagerImpl implements ConnectionManager {
Connection conn=null; Connection conn=null;
try{ try{
conn=dataSource.getConnection(); conn=dataSource.getConnection();
conn.createStatement().executeUpdate(Queries.getInitDB(db.getFlavor())); conn.setAutoCommit(true);
conn.commit(); conn.createStatement().executeUpdate(Queries.getInitDB(db.getFlavor()));
}catch(SQLException e) { }catch(SQLException e) {
throw new InternalError("Unable to Init database "+db,e); throw new InternalError("Unable to Init database "+db,e);
}finally { }finally {

View File

@ -106,7 +106,7 @@ public class PersistenceManagerImpl implements PersistenceManager {
throws PersistenceError, InvalidRequest { throws PersistenceError, InvalidRequest {
Connection conn=null; Connection conn=null;
try { try {
log.debug("Looking for execution according to filter {} ",filter); log.debug("Looking for execution according to filter {}",filter);
conn=connections.getConnection(); conn=connections.getConnection();
ArrayList<ExecutionDescriptor> toReturn=new ArrayList<>(); ArrayList<ExecutionDescriptor> toReturn=new ArrayList<>();
PreparedStatement psGet=Queries.GET_ALL.get(conn, filter); PreparedStatement psGet=Queries.GET_ALL.get(conn, filter);

View File

@ -2,5 +2,5 @@ db.pools.max_idle=5
db.pools.max_total=50 db.pools.max_total=50
db.pools.min_total=3 db.pools.min_total=3
mapping-db.ep.name=Feeder_DB db.ep.name=Feeder_DB
mapping-db.ep.category=Database db.ep.category=Database