diff --git a/gCat-Controller/pom.xml b/gCat-Controller/pom.xml index b2f1b24..5504273 100644 --- a/gCat-Controller/pom.xml +++ b/gCat-Controller/pom.xml @@ -9,6 +9,18 @@ gCat Controller Controller implementation for GCat Service + + + + org.gcube.distribution + gcube-bom + LATEST + pom + import + + + + @@ -32,6 +44,20 @@ test + + + com.fasterxml.jackson.core + jackson-databind + provided + + + + + org.slf4j + slf4j-api + provided + + diff --git a/gCat-Controller/src/main/java/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatController.java b/gCat-Controller/src/main/java/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatController.java index bfa7030..36d55ae 100644 --- a/gCat-Controller/src/main/java/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatController.java +++ b/gCat-Controller/src/main/java/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatController.java @@ -63,7 +63,7 @@ public class GCatController implements CatalogueController{ try { builder= factory.newDocumentBuilder(); - expr= xpath.compile("string(/bookstore/book/title/@lang)"); + expr= xpath.compile("string(//metadataformat/@type)"); } catch (ParserConfigurationException | XPathExpressionException e) { throw new RuntimeException("Unable to initialize Controller"); } @@ -141,7 +141,7 @@ public class GCatController implements CatalogueController{ } log.debug("Publishing Item.."); - String itemResp=createItem(itemNode.asText()); + String itemResp=createItem(itemNode.toString(),itemNode.path("name").textValue()); String itemId = getId(itemResp); 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; try{ if(isForcedUrl()) item = new Item(getForcedUrl()); 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) { handleWebException(e); 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) { try { return mapper.readTree(publishResponse).path("result").path("id").asText(); diff --git a/gCat-Controller/src/test/resources/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/full-algorithm.json b/gCat-Controller/src/test/resources/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/full-algorithm.json index 7a052b2..5e5f9d4 100644 --- a/gCat-Controller/src/test/resources/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/full-algorithm.json +++ b/gCat-Controller/src/test/resources/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/full-algorithm.json @@ -1,21 +1,39 @@ { - "profile": "\n \n Input Parameter\n String\n false\n Input parameter expected for the execution of the algorithm\n \n", + "profileID": "DataMiner Process", + "profile": "\n\t\n\t\tInput Parameter\n\t\tfalse\n\t\tString\n\t\tInput parameter expected for the execution of the process\n\t\n\t\n\t\tOutput Parameter\n\t\tfalse\n\t\tString\n\t\tOutput parameter expected from the execution of the process\n\t\t\n\t\n\t\n\t\tProcess Author\n\t\tfalse\n\t\tString\n\t\t*\n\t\t\n\t\tThe 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\n\t\t\n\t\t\t^[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])?$\n\t\t\n\t\n", "item": { - "name": "step_4_vpa_iccat_bft_e_report_in_nextnext", - "title": "Step 4 Vpa Iccat Bft E Report in NextNext", - "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", + "name": "grid_cwp_to_coordinates_in_prevre", + "title": "Grid Cwp To Coordinates in preVRE", + "description": "An algorithm that adds longitude, latitude and resolution columns analysing a column containing FAO Ocean Area codes (CWP format).", "version": null, - "visibility": null, - "license": "CC-BY-NC-SA-4.0", - "author": "gianpaolo.coro", - "maintainer": "gianpaolo.coro", - "tags": ["Iccat Eastern Bft Stock Assessment"], + "license_id": "CC-BY-NC-SA-4.0", + "author": null, + "maintainer": null, + "tags": [ + { + "name": "Geo Processing" + }, + { + "name": "preVRE" + }, + { + "name": "WPS" + }, + { + "name": "Analytics" + }], "extras": [ { - "key": "system", - "value": "Algorithm" - }] + "key": "system:type", + "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" + }] } \ No newline at end of file diff --git a/gCat-Controller/src/test/resources/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/onlyItem.json b/gCat-Controller/src/test/resources/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/onlyItem.json index e69de29..7ed5ddb 100644 --- a/gCat-Controller/src/test/resources/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/onlyItem.json +++ b/gCat-Controller/src/test/resources/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/onlyItem.json @@ -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 +} \ No newline at end of file diff --git a/gCat-Controller/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/gCat-Controller/pom.properties b/gCat-Controller/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/gCat-Controller/pom.properties index f53060c..28dc669 100644 --- a/gCat-Controller/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/gCat-Controller/pom.properties +++ b/gCat-Controller/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/gCat-Controller/pom.properties @@ -1,5 +1,5 @@ #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 groupId=org.gcube.data-publishing.gCat-Feeder m2e.projectName=gCat-Controller diff --git a/gCat-Controller/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/gCat-Controller/pom.xml b/gCat-Controller/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/gCat-Controller/pom.xml index b2f1b24..5504273 100644 --- a/gCat-Controller/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/gCat-Controller/pom.xml +++ b/gCat-Controller/target/classes/META-INF/maven/org.gcube.data-publishing.gCat-Feeder/gCat-Controller/pom.xml @@ -9,6 +9,18 @@ gCat Controller Controller implementation for GCat Service + + + + org.gcube.distribution + gcube-bom + LATEST + pom + import + + + + @@ -32,6 +44,20 @@ test + + + com.fasterxml.jackson.core + jackson-databind + provided + + + + + org.slf4j + slf4j-api + provided + + diff --git a/gCat-Controller/target/classes/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatController.class b/gCat-Controller/target/classes/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatController.class index 4ac5c26..03e516e 100644 Binary files a/gCat-Controller/target/classes/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatController.class and b/gCat-Controller/target/classes/org/gcube/data/publishing/gCataFeeder/catalogues/gCat/GCatController.class differ diff --git a/gCat-Controller/target/test-classes/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/full-algorithm.json b/gCat-Controller/target/test-classes/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/full-algorithm.json index 7a052b2..5e5f9d4 100644 --- a/gCat-Controller/target/test-classes/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/full-algorithm.json +++ b/gCat-Controller/target/test-classes/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/full-algorithm.json @@ -1,21 +1,39 @@ { - "profile": "\n \n Input Parameter\n String\n false\n Input parameter expected for the execution of the algorithm\n \n", + "profileID": "DataMiner Process", + "profile": "\n\t\n\t\tInput Parameter\n\t\tfalse\n\t\tString\n\t\tInput parameter expected for the execution of the process\n\t\n\t\n\t\tOutput Parameter\n\t\tfalse\n\t\tString\n\t\tOutput parameter expected from the execution of the process\n\t\t\n\t\n\t\n\t\tProcess Author\n\t\tfalse\n\t\tString\n\t\t*\n\t\t\n\t\tThe 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\n\t\t\n\t\t\t^[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])?$\n\t\t\n\t\n", "item": { - "name": "step_4_vpa_iccat_bft_e_report_in_nextnext", - "title": "Step 4 Vpa Iccat Bft E Report in NextNext", - "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", + "name": "grid_cwp_to_coordinates_in_prevre", + "title": "Grid Cwp To Coordinates in preVRE", + "description": "An algorithm that adds longitude, latitude and resolution columns analysing a column containing FAO Ocean Area codes (CWP format).", "version": null, - "visibility": null, - "license": "CC-BY-NC-SA-4.0", - "author": "gianpaolo.coro", - "maintainer": "gianpaolo.coro", - "tags": ["Iccat Eastern Bft Stock Assessment"], + "license_id": "CC-BY-NC-SA-4.0", + "author": null, + "maintainer": null, + "tags": [ + { + "name": "Geo Processing" + }, + { + "name": "preVRE" + }, + { + "name": "WPS" + }, + { + "name": "Analytics" + }], "extras": [ { - "key": "system", - "value": "Algorithm" - }] + "key": "system:type", + "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" + }] } \ No newline at end of file diff --git a/gCat-Controller/target/test-classes/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/onlyItem.json b/gCat-Controller/target/test-classes/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/onlyItem.json index e69de29..7ed5ddb 100644 --- a/gCat-Controller/target/test-classes/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/onlyItem.json +++ b/gCat-Controller/target/test-classes/org/gcube/data/publishing/gCatFeeder/catalogues/gCat/onlyItem.json @@ -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 +} \ No newline at end of file diff --git a/gCat-Feeder/.settings/org.eclipse.wst.common.component b/gCat-Feeder/.settings/org.eclipse.wst.common.component index b3da5df..6d37f66 100644 --- a/gCat-Feeder/.settings/org.eclipse.wst.common.component +++ b/gCat-Feeder/.settings/org.eclipse.wst.common.component @@ -4,15 +4,6 @@ - - uses - - - uses - - - uses - diff --git a/gCat-Feeder/src/main/java/org/gcube/data/publishing/gCatFeeder/service/engine/LocalConfiguration.java b/gCat-Feeder/src/main/java/org/gcube/data/publishing/gCatFeeder/service/engine/LocalConfiguration.java index 50bdf38..9afed7e 100644 --- a/gCat-Feeder/src/main/java/org/gcube/data/publishing/gCatFeeder/service/engine/LocalConfiguration.java +++ b/gCat-Feeder/src/main/java/org/gcube/data/publishing/gCatFeeder/service/engine/LocalConfiguration.java @@ -7,8 +7,8 @@ public interface LocalConfiguration { 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 MAPPING_DB_ENDPOINT_CATEGORY="db.ep.category"; + public static final String DB_ENDPOINT_NAME="db.ep.name"; + public static final String DB_ENDPOINT_CATEGORY="db.ep.category"; diff --git a/gCat-Feeder/src/main/java/org/gcube/data/publishing/gCatFeeder/service/engine/impl/persistence/ConnectionManagerImpl.java b/gCat-Feeder/src/main/java/org/gcube/data/publishing/gCatFeeder/service/engine/impl/persistence/ConnectionManagerImpl.java index 667131e..f21814d 100644 --- a/gCat-Feeder/src/main/java/org/gcube/data/publishing/gCatFeeder/service/engine/impl/persistence/ConnectionManagerImpl.java +++ b/gCat-Feeder/src/main/java/org/gcube/data/publishing/gCatFeeder/service/engine/impl/persistence/ConnectionManagerImpl.java @@ -59,16 +59,17 @@ public class ConnectionManagerImpl implements ConnectionManager { @Inject private LocalConfiguration configuration; - private synchronized DatabaseConnectionDescriptor getDB() throws InternalError { + private synchronized DatabaseConnectionDescriptor getDB() throws InternalError { if(!databases.containsKey(infrastructure.getCurrentContext())) databases.put(infrastructure.getCurrentContext(), infrastructure.queryForDatabase( - configuration.getProperty(LocalConfiguration.MAPPING_DB_ENDPOINT_CATEGORY), - configuration.getProperty(LocalConfiguration.MAPPING_DB_ENDPOINT_NAME))); + configuration.getProperty(LocalConfiguration.DB_ENDPOINT_CATEGORY), + configuration.getProperty(LocalConfiguration.DB_ENDPOINT_NAME))); return databases.get(infrastructure.getCurrentContext()); } @Override public Connection getConnection() throws SQLException, InternalError { + log.debug("Getting DB connection in {} ",infrastructure.getCurrentContext()); DataSource ds=getDataSource(); Connection conn=ds.getConnection(); conn.setAutoCommit(false); @@ -119,8 +120,8 @@ public class ConnectionManagerImpl implements ConnectionManager { Connection conn=null; try{ conn=dataSource.getConnection(); - conn.createStatement().executeUpdate(Queries.getInitDB(db.getFlavor())); - conn.commit(); + conn.setAutoCommit(true); + conn.createStatement().executeUpdate(Queries.getInitDB(db.getFlavor())); }catch(SQLException e) { throw new InternalError("Unable to Init database "+db,e); }finally { diff --git a/gCat-Feeder/src/main/java/org/gcube/data/publishing/gCatFeeder/service/engine/impl/persistence/PersistenceManagerImpl.java b/gCat-Feeder/src/main/java/org/gcube/data/publishing/gCatFeeder/service/engine/impl/persistence/PersistenceManagerImpl.java index 18de7ad..3aa586b 100644 --- a/gCat-Feeder/src/main/java/org/gcube/data/publishing/gCatFeeder/service/engine/impl/persistence/PersistenceManagerImpl.java +++ b/gCat-Feeder/src/main/java/org/gcube/data/publishing/gCatFeeder/service/engine/impl/persistence/PersistenceManagerImpl.java @@ -106,7 +106,7 @@ public class PersistenceManagerImpl implements PersistenceManager { throws PersistenceError, InvalidRequest { Connection conn=null; try { - log.debug("Looking for execution according to filter {} ",filter); + log.debug("Looking for execution according to filter {}",filter); conn=connections.getConnection(); ArrayList toReturn=new ArrayList<>(); PreparedStatement psGet=Queries.GET_ALL.get(conn, filter); diff --git a/gCat-Feeder/src/main/resources/gcat-feeder-config.properties b/gCat-Feeder/src/main/resources/gcat-feeder-config.properties index b92b613..87c721f 100644 --- a/gCat-Feeder/src/main/resources/gcat-feeder-config.properties +++ b/gCat-Feeder/src/main/resources/gcat-feeder-config.properties @@ -2,5 +2,5 @@ db.pools.max_idle=5 db.pools.max_total=50 db.pools.min_total=3 -mapping-db.ep.name=Feeder_DB -mapping-db.ep.category=Database \ No newline at end of file +db.ep.name=Feeder_DB +db.ep.category=Database \ No newline at end of file