Compare commits
211 Commits
task_20595
...
master
|
@ -1,11 +1,11 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="java" version="1.7"/>
|
||||
<installed facet="jst.utility" version="1.0"/>
|
||||
<installed facet="java" version="1.8"/>
|
||||
</faceted-project>
|
||||
|
|
76
CHANGELOG.md
76
CHANGELOG.md
|
@ -4,6 +4,80 @@
|
|||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v2.3.0]
|
||||
|
||||
- Read countByPhase from configuration [#25598]
|
||||
- Reduced/Optimized some LOGs [#25539]
|
||||
|
||||
## [v2.2.0]
|
||||
|
||||
- Integrated the cross-filtering configuration [#25074]
|
||||
- Integrated the overlay layers configuration [#25110]
|
||||
|
||||
## [v2.1.0] - 2023-05-11
|
||||
|
||||
- Integrated the deleteFileset method [#24977]
|
||||
- Integrated with the Geoportal_Resolver service [#25031]
|
||||
|
||||
## [v2.0.3] - 2023-02-09
|
||||
|
||||
#### Enhancements
|
||||
|
||||
- [#24569] Added the phase DRAFT in the enum (also required for #24571)
|
||||
|
||||
## [v2.0.2] - 2022-02-03
|
||||
|
||||
#### Enhancements
|
||||
|
||||
- [#24432] Reverted serialization from Sting to Object values returning the Document as Map
|
||||
- [#24475] Propagated the Access Policy in the fileset
|
||||
|
||||
## [v2.0.1] - 2022-01-19
|
||||
|
||||
#### Bug fixes
|
||||
|
||||
- [#24263] Fixing JSON library v20090211
|
||||
- [#24432] Fixing serialization issue using LinkedHashMap<String, String> instead of LinkedHashMap<String, Object>.
|
||||
- [#24432] Added a trim for returning value to solve a space as suffix into returned date (fixing the data displayed in the Timeline Widget)
|
||||
|
||||
## [v2.0.0] - 2022-11-17
|
||||
|
||||
#### Enhancements
|
||||
|
||||
- [#22883] Integrated the configurations exposed by (the new) geoportal-client (>= 1.1.0-SNAPSHOT)
|
||||
- Passed to UCD/Projects geoportal client/service
|
||||
- [#23835] Integrated with WORKFLOW_ACTION_LIST_GUI configuration
|
||||
- [#23909] Declared lombok required for JDK_11
|
||||
- [#23913] Integrated with GUI presentation configurations read from IS
|
||||
- [#23927] Integrated with Relationship definition in UCD
|
||||
- [#23834] Integrated with the create/view/delete Relationship facility
|
||||
- [#24136] Integrated the temporal dimension on the front-end side
|
||||
- [#24458] Published projects cannot be edited/updated
|
||||
|
||||
## [v1.4.0] - 2022-06-08
|
||||
|
||||
#### Enhancements
|
||||
|
||||
- [#23392] Implemented the "Clone Project" facility
|
||||
- [#23457] Implemented the "Publish/UnPublish Project" facility
|
||||
|
||||
## [v1.3.0] - 2021-12-03
|
||||
|
||||
#### Enhancements
|
||||
|
||||
- [#22506] Added classes to read configurations and common classes from the GNA components: DataEntry and DataViewer
|
||||
|
||||
## [v1.2.0] - 2021-09-29
|
||||
|
||||
#### Enhancements
|
||||
|
||||
- [#20595] Porting common model
|
||||
- [#21890] Passed to mongoID
|
||||
- [#22002] Integrated with ValidationReport bean
|
||||
- [#22040] Revisited the "Abstract Relazione di Scavo"
|
||||
- Passed to gcube-bom 2.0.1
|
||||
|
||||
|
||||
## [v1.0.0] - 2020-12-01
|
||||
|
||||
First release
|
||||
- First release
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# GeoPortal Data Common
|
||||
|
||||
GeoPortal Data Common is a common library used by GUI components developed for GeoNA
|
||||
GeoPortal Data Common is a common library used by GUI components developed for the Geoportal
|
||||
|
||||
## Built With
|
||||
|
||||
|
|
51
pom.xml
51
pom.xml
|
@ -5,12 +5,12 @@
|
|||
<parent>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<version>1.1.0</version>
|
||||
<version>1.2.0</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-data-common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>2.3.0</version>
|
||||
<description>GeoPortal Data Common is common library used by GUI components developed for GeoNA</description>
|
||||
|
||||
<scm>
|
||||
|
@ -32,7 +32,7 @@
|
|||
</developers>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-bom</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.3.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -65,17 +65,51 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-client</artifactId>
|
||||
<version>[1.1.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>gcube-url-shortener</artifactId>
|
||||
<artifactId>uri-resolver-manager</artifactId>
|
||||
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20090211</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- REQUIRED FOR JDK_11 -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- LOGGER -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.6.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- JUNIT -->
|
||||
|
@ -86,6 +120,13 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>9.4.1212</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package org.gcube.application.geoportalcommon;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.document.access.Access;
|
||||
import org.gcube.application.geoportal.common.model.document.access.AccessPolicy;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider;
|
||||
|
||||
/**
|
||||
* The Class ConvertToDataServiceModel.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Feb 3, 2023
|
||||
*/
|
||||
public class ConvertToDataServiceModel {
|
||||
|
||||
private static Logger LOG = LoggerFactory.getLogger(ConvertToDataServiceModel.class);
|
||||
|
||||
/**
|
||||
* Gets the access from document section.
|
||||
*
|
||||
* @param theJSONDocument the the JSON document
|
||||
* @param sectionJSONPath the section JSON path
|
||||
* @return the access from document section
|
||||
*/
|
||||
public static Access getAccessFromDocumentSection(String theJSONDocument, String sectionJSONPath) {
|
||||
String accessPolicyPath = String.format("%s.%s", sectionJSONPath, ConvertToDataValueObjectModel.POLICY);
|
||||
|
||||
AccessPolicy accessPolicy = null;
|
||||
com.jayway.jsonpath.Configuration config = com.jayway.jsonpath.Configuration.builder()
|
||||
.jsonProvider(new JsonOrgJsonProvider()).build();
|
||||
|
||||
// Reading policy fields
|
||||
try {
|
||||
JsonPath theSectionPolycJsonPath = JsonPath.compile(accessPolicyPath);
|
||||
String policy = theSectionPolycJsonPath.read(theJSONDocument, config).toString();
|
||||
LOG.debug("Read " + ConvertToDataValueObjectModel.POLICY + ": " + policy + ", from section: "
|
||||
+ accessPolicyPath);
|
||||
if (policy != null) {
|
||||
accessPolicy = AccessPolicy.valueOf(policy.toUpperCase());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.info("No " + ConvertToDataValueObjectModel.POLICY + " found in the path: " + accessPolicyPath);
|
||||
}
|
||||
|
||||
// Reading policy fields
|
||||
String licenseIDPath = String.format("%s.%s", sectionJSONPath, ConvertToDataValueObjectModel.LICENSE_ID);
|
||||
String licenseID = null;
|
||||
try {
|
||||
JsonPath theSectionLicenseJsonPath = JsonPath.compile(licenseIDPath);
|
||||
licenseID = theSectionLicenseJsonPath.read(theJSONDocument, config).toString();
|
||||
LOG.debug("Read " + ConvertToDataValueObjectModel.LICENSE_ID + ": " + licenseID + ", from section: "
|
||||
+ licenseIDPath);
|
||||
} catch (Exception e) {
|
||||
LOG.info("No " + ConvertToDataValueObjectModel.LICENSE_ID + " found in the path: " + licenseIDPath);
|
||||
}
|
||||
|
||||
Access access = new Access();
|
||||
if (accessPolicy != null)
|
||||
access.setPolicy(accessPolicy);
|
||||
if (licenseID != null)
|
||||
access.setLicense(licenseID);
|
||||
|
||||
LOG.info("Access is: " + access.getPolicy() + " / " + access.getLicense());
|
||||
return access;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,149 @@
|
|||
package org.gcube.application.geoportalcommon;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.legacy.AccessPolicy;
|
||||
import org.gcube.application.geoportal.common.model.legacy.BBOX;
|
||||
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The Class ConvertToGUIModel.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Nov 2, 2020
|
||||
*/
|
||||
public class ConvertToDataViewModel {
|
||||
|
||||
private static final String NO_TIME = "T00:00";
|
||||
|
||||
/** The Constant LOG. */
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ConvertToDataViewModel.class);
|
||||
|
||||
public static final String DATE_FORMAT = "yyyy-MM-dd";
|
||||
|
||||
public static final String HOURS_MINUTES_SEPARATOR = ":";
|
||||
|
||||
public static final String TIME_FORMAT = "HH" + HOURS_MINUTES_SEPARATOR + "mm";
|
||||
|
||||
/**
|
||||
* To user.
|
||||
*
|
||||
* @param username the username
|
||||
* @return the string
|
||||
*/
|
||||
public static String toUser(String username) {
|
||||
|
||||
if (username == null)
|
||||
return null;
|
||||
|
||||
return username;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* To policy.
|
||||
*
|
||||
* @param policy the policy
|
||||
* @return the string
|
||||
*/
|
||||
public static String toPolicy(AccessPolicy policy) {
|
||||
|
||||
if (policy == null)
|
||||
return null;
|
||||
|
||||
return policy.name();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* To bound map.
|
||||
*
|
||||
* @param bbox the bbox
|
||||
* @return the bounds map
|
||||
*/
|
||||
public static BoundsMap toBoundMap(BBOX bbox) {
|
||||
|
||||
if (bbox == null)
|
||||
return null;
|
||||
|
||||
return new BoundsMap(bbox.getMinLong(), bbox.getMinLat(), bbox.getMaxLong(), bbox.getMaxLat(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* To bound map.
|
||||
*
|
||||
* @param wmsVersion the wms version
|
||||
* @param bbox the bbox
|
||||
* @param separator the separator
|
||||
* @return the bounds map
|
||||
*/
|
||||
public static BoundsMap toBoundMap(String wmsVersion, String bbox, String separator) {
|
||||
|
||||
if (bbox == null)
|
||||
return null;
|
||||
|
||||
if (wmsVersion == null)
|
||||
return null;
|
||||
|
||||
if (separator == null)
|
||||
separator = ",";
|
||||
|
||||
try {
|
||||
|
||||
String[] bboxArr = bbox.split(separator);
|
||||
|
||||
if (wmsVersion.startsWith("1.3")) {
|
||||
// is 1.3.x
|
||||
return new BoundsMap(toDouble(bboxArr[1]), toDouble(bboxArr[0]), toDouble(bboxArr[3]),
|
||||
toDouble(bboxArr[2]), wmsVersion);
|
||||
} else {
|
||||
// should be 1.1.X
|
||||
return new BoundsMap(toDouble(bboxArr[0]), toDouble(bboxArr[1]), toDouble(bboxArr[2]),
|
||||
toDouble(bboxArr[3]), wmsVersion);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Error on creating Bounds for wmsVersion " + wmsVersion + " and bbox " + bbox + " : ", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To double.
|
||||
*
|
||||
* @param value the value
|
||||
* @return the double
|
||||
*/
|
||||
public static Double toDouble(String value) {
|
||||
try {
|
||||
return Double.parseDouble(value);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Error on parsing " + value + " as double: ", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To JSON.
|
||||
*
|
||||
* @param theObj the the obj
|
||||
* @return the string
|
||||
*/
|
||||
public static String toJSON(Object theObj) {
|
||||
LOG.debug("toJSON called");
|
||||
try {
|
||||
|
||||
if (theObj instanceof Serializable) {
|
||||
return org.gcube.application.geoportal.client.utils.Serialization.write(theObj);
|
||||
}
|
||||
throw new Exception("The input object is not serializable");
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Error on deserializing: ", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
package org.gcube.application.geoportalcommon;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.gcube.application.geoportalcommon.config.CSVFile;
|
||||
import org.gcube.application.geoportalcommon.config.CSVReader;
|
||||
import org.gcube.application.geoportalcommon.config.CSVRow;
|
||||
import org.gcube.application.geoportalcommon.config.FileUtil;
|
||||
import org.gcube.application.geoportalcommon.shared.exception.GNAConfigException;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The Class GNAConfigsConverter.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 21, 2021
|
||||
*/
|
||||
public class GNAConfigsConverter {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GNAConfigsConverter.class);
|
||||
|
||||
|
||||
public GNAConfigsConverter() {
|
||||
}
|
||||
/**
|
||||
* Read list items config.
|
||||
*
|
||||
* @param contentValue the content value
|
||||
* @return the list
|
||||
* @throws GNAConfigException the GNA user rights config exception
|
||||
*/
|
||||
public List<ItemFieldDV> readListItemsConfig(String contentValue) throws GNAConfigException {
|
||||
LOG.debug("readListItemsConfig called");
|
||||
|
||||
File configurationFile = null;
|
||||
List<ItemFieldDV> listItemFields = new ArrayList<ItemFieldDV>();
|
||||
try {
|
||||
|
||||
configurationFile = FileUtil.inputStreamToTempFile(contentValue, "GNA_ListItems_Configs"+new Random().nextInt());
|
||||
|
||||
CSVReader reader = new CSVReader(configurationFile);
|
||||
CSVFile csvFile = reader.getCsvFile();
|
||||
|
||||
if(LOG.isTraceEnabled()) {
|
||||
LOG.trace("CSV Header Row: "+csvFile.getHeaderRow());
|
||||
}
|
||||
|
||||
List<CSVRow> rows = csvFile.getValueRows();
|
||||
LOG.debug("CSV Value Row are: "+rows);
|
||||
|
||||
// Starting from index 1 (means the second row in the CSV)
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
LOG.trace(i + " row");
|
||||
ItemFieldDV itemField = new ItemFieldDV();
|
||||
CSVRow row = rows.get(i);
|
||||
|
||||
// mapping to ItemFiel
|
||||
List<String> rowValues = row.getListValues();
|
||||
LOG.debug("rowValues: " + rowValues);
|
||||
|
||||
itemField.setDisplayName(rowValues.get(0));
|
||||
|
||||
// Reading JSON Fields
|
||||
String[] jsonFields = rowValues.get(1).split(";");
|
||||
List<String> theJsonFields = new ArrayList<String>(jsonFields.length);
|
||||
for (String jsonField : jsonFields) {
|
||||
theJsonFields.add(jsonField.trim());
|
||||
}
|
||||
|
||||
itemField.setJsonFields(theJsonFields);
|
||||
|
||||
// Display as result
|
||||
if (checkYesNoValue(rowValues.get(2))) {
|
||||
itemField.setDisplayAsResult(true);
|
||||
}
|
||||
|
||||
// Sortable
|
||||
if (checkYesNoValue(rowValues.get(3))) {
|
||||
itemField.setSortable(true);
|
||||
}
|
||||
|
||||
// Searchable
|
||||
if (checkYesNoValue(rowValues.get(4))) {
|
||||
itemField.setSearchable(true);
|
||||
}
|
||||
|
||||
listItemFields.add(itemField);
|
||||
}
|
||||
LOG.info("Returning item fields config: " + listItemFields);
|
||||
return listItemFields;
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("An error occurred on reading the GNA config from: " + contentValue, e);
|
||||
throw new GNAConfigException("Error on reading the GNA config from: " + contentValue);
|
||||
} finally {
|
||||
|
||||
if (configurationFile != null) {
|
||||
try {
|
||||
configurationFile.delete();
|
||||
} catch (Exception e) {
|
||||
// silent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check yes no value.
|
||||
*
|
||||
* @param value the value
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean checkYesNoValue(String value) {
|
||||
|
||||
if (value == null || value.isEmpty())
|
||||
return false;
|
||||
|
||||
String lowerValue = value.toLowerCase();
|
||||
|
||||
if (lowerValue.equals("yes") || lowerValue.equals("true")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,326 @@
|
|||
package org.gcube.application.geoportalcommon;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.gcube.application.geoportalcommon.config.CSVFile;
|
||||
import org.gcube.application.geoportalcommon.config.CSVReader;
|
||||
import org.gcube.application.geoportalcommon.config.CSVRow;
|
||||
import org.gcube.application.geoportalcommon.config.FileUtil;
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataEntryConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.config.GcubeUserRole;
|
||||
import org.gcube.application.geoportalcommon.shared.config.OPERATION_ON_ITEM;
|
||||
import org.gcube.application.geoportalcommon.shared.config.RoleRights;
|
||||
import org.gcube.application.geoportalcommon.shared.config.RoleRights.OPERATION_TYPE;
|
||||
import org.gcube.application.geoportalcommon.shared.exception.ApplicationProfileNotFoundException;
|
||||
import org.gcube.application.geoportalcommon.shared.exception.GNAConfigException;
|
||||
import org.gcube.application.geoportalcommon.shared.guipresentation.BodyWelcome;
|
||||
import org.gcube.application.geoportalcommon.shared.guipresentation.DataEntryGUIPresentationConfig;
|
||||
import org.gcube.application.geoportalcommon.shared.guipresentation.Header;
|
||||
import org.gcube.common.resources.gcore.utils.XPathHelper;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.Query;
|
||||
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
/**
|
||||
* The Class GNADataEntryConfigProfileReader.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 21, 2021
|
||||
*/
|
||||
public class GNADataEntryConfigProfileReader {
|
||||
|
||||
private static final String RESOURCE_PROFILE_BODY = "/Resource/Profile/Body";
|
||||
public static final String SECONDARY_TYPE = "ApplicationProfile";
|
||||
public static final String GENERIC_RESOURCE_NAME = "Geoportal-DataEntry-Configs";
|
||||
|
||||
private static final String PATH_TO_PERMISSIONS_PATH = RESOURCE_PROFILE_BODY + "/permssions_for_role";
|
||||
// private static final String PATH_TO_ITEM_FIELDS_CONFIG = RESOURCE_PROFILE_BODY + "/item_fields_config";
|
||||
|
||||
private static final String PATH_TO_HEADER_GUI_PRESENTATION = RESOURCE_PROFILE_BODY + "/gui_presentation/data_entry_facility/header";
|
||||
private static final String PATH_TO_BODY_WELCOME_GUI_PRESENTATION = RESOURCE_PROFILE_BODY + "/gui_presentation/data_entry_facility/body_welcome";
|
||||
|
||||
private String scope;
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GNADataEntryConfigProfileReader.class);
|
||||
|
||||
/**
|
||||
* Instantiates a new application profile reader.
|
||||
*/
|
||||
public GNADataEntryConfigProfileReader() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Read profile from infrastrucure.
|
||||
*
|
||||
* @return the map
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public GNADataEntryConfigProfile readProfileFromInfrastrucure() throws Exception {
|
||||
LOG.info("called readProfileFromInfrastrucure");
|
||||
String queryString = getGcubeGenericQueryString(SECONDARY_TYPE, GENERIC_RESOURCE_NAME);
|
||||
this.scope = ScopeProvider.instance.get();
|
||||
LOG.info("Scope " + scope + ", trying to perform query: " + queryString);
|
||||
|
||||
if (scope == null)
|
||||
throw new Exception("Scope is null, set scope into ScopeProvider");
|
||||
|
||||
GNADataEntryConfigProfile gnDEC = new GNADataEntryConfigProfile();
|
||||
String permissions_for_role = "";
|
||||
String item_fields = "";
|
||||
try {
|
||||
|
||||
LOG.info("Trying to fetch GR named: " + GENERIC_RESOURCE_NAME + ", in the scope: " + scope
|
||||
+ ", SecondaryType: " + SECONDARY_TYPE);
|
||||
Query q = new QueryBox(queryString);
|
||||
DiscoveryClient<String> client = client();
|
||||
List<String> appProfile = client.submit(q);
|
||||
|
||||
if (appProfile == null || appProfile.size() == 0)
|
||||
throw new ApplicationProfileNotFoundException("GR with SecondaryType: " + SECONDARY_TYPE
|
||||
+ ", and name: " + GENERIC_RESOURCE_NAME + " is not registered in the scope: " + scope);
|
||||
else {
|
||||
String elem = appProfile.get(0);
|
||||
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
Document doc = docBuilder.parse(new InputSource(new StringReader(elem)));
|
||||
|
||||
XPathHelper helper = new XPathHelper(doc.getDocumentElement());
|
||||
|
||||
List<String> currValue = null;
|
||||
|
||||
String xPathExp = PATH_TO_PERMISSIONS_PATH + "/text()";
|
||||
currValue = helper.evaluate(xPathExp);
|
||||
|
||||
if (currValue != null && currValue.size() > 0) {
|
||||
permissions_for_role = currValue.get(0);
|
||||
} else
|
||||
throw new Exception("I'm not able to read the path: " + xPathExp);
|
||||
|
||||
// replacing \n with new_line string
|
||||
LOG.debug("read " + PATH_TO_PERMISSIONS_PATH + ": " + permissions_for_role);
|
||||
String value_with_new_lines = permissions_for_role.replaceAll("\\\\n", System.lineSeparator());
|
||||
LOG.debug(PATH_TO_PERMISSIONS_PATH + " with new lines: " + value_with_new_lines);
|
||||
|
||||
List<RoleRights> listRoleRights = readRoleRightsConfig(value_with_new_lines);
|
||||
gnDEC.setPermissionsForRole(listRoleRights);
|
||||
|
||||
//GUI PRESENTATION CONFIGS
|
||||
DataEntryGUIPresentationConfig deGUIP = new DataEntryGUIPresentationConfig();
|
||||
|
||||
xPathExp = PATH_TO_HEADER_GUI_PRESENTATION;
|
||||
currValue = helper.evaluate(xPathExp);
|
||||
LOG.debug("read " + PATH_TO_HEADER_GUI_PRESENTATION + ": " + currValue);
|
||||
if (currValue != null && currValue.size() > 0) {
|
||||
String headerGUI = currValue.get(0);
|
||||
Header headerClass = SerializerUtil.unmarshalXML(headerGUI, Header.class);
|
||||
LOG.debug("serialized " + Header.class + ": " + headerClass);
|
||||
deGUIP.setHeader(headerClass);
|
||||
} else
|
||||
throw new Exception("I'm not able to read the path: " + xPathExp);
|
||||
|
||||
xPathExp = PATH_TO_BODY_WELCOME_GUI_PRESENTATION;
|
||||
currValue = helper.evaluate(xPathExp);
|
||||
LOG.debug("read " + PATH_TO_BODY_WELCOME_GUI_PRESENTATION + ": " + currValue);
|
||||
if (currValue != null && currValue.size() > 0) {
|
||||
String bodyWelcome = currValue.get(0);
|
||||
BodyWelcome bodyWelcomeClass = SerializerUtil.unmarshalXML(bodyWelcome, BodyWelcome.class);
|
||||
LOG.debug("serialized " + BodyWelcome.class + ": " + bodyWelcomeClass);
|
||||
deGUIP.setBodyWelcome(bodyWelcomeClass);
|
||||
} else
|
||||
throw new Exception("I'm not able to read the path: " + xPathExp);
|
||||
|
||||
gnDEC.setDataEntryGUIPresentation(deGUIP);
|
||||
LOG.info("returning: " + gnDEC);
|
||||
return gnDEC;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error while trying to read the " + SECONDARY_TYPE + " with SecondaryType "
|
||||
+ GENERIC_RESOURCE_NAME + " from scope " + scope, e);
|
||||
return null;
|
||||
} finally {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To gcube user role.
|
||||
*
|
||||
* @param name the name
|
||||
* @return the gcube user role
|
||||
*/
|
||||
protected static GcubeUserRole toGcubeUserRole(String name) {
|
||||
|
||||
for (GcubeUserRole gCubeUserRole : GcubeUserRole.values()) {
|
||||
if (gCubeUserRole.getName().equalsIgnoreCase(name))
|
||||
return gCubeUserRole;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read user rights config.
|
||||
*
|
||||
* @param permissions_for_role the permissions for role
|
||||
* @return the list
|
||||
* @throws GNAConfigException the GNA user rights config not found
|
||||
* exception
|
||||
*/
|
||||
public List<RoleRights> readRoleRightsConfig(String permissions_for_role) throws GNAConfigException {
|
||||
LOG.debug("readRoleRightsConfig called");
|
||||
|
||||
File configurationFile = null;
|
||||
List<RoleRights> listUserRights = new ArrayList<RoleRights>();
|
||||
try {
|
||||
configurationFile = FileUtil.inputStreamToTempFile(permissions_for_role, "GNA_RoleRights_Configurations"+new Random().nextInt());
|
||||
|
||||
CSVReader reader = new CSVReader(configurationFile);
|
||||
CSVFile csvFile = reader.getCsvFile();
|
||||
|
||||
List<String> headerKeys = csvFile.getHeaderRow().getListValues();
|
||||
List<CSVRow> rows = csvFile.getValueRows();
|
||||
|
||||
// MAPPING OPERATION TYPE AS READ, WRITE, etc.
|
||||
Map<String, OPERATION_TYPE> mapOperationTypes = new HashMap<String, RoleRights.OPERATION_TYPE>();
|
||||
CSVRow operationTypeRow = rows.get(0);
|
||||
List<String> rowValues = operationTypeRow.getListValues();
|
||||
for (int j = 1; j < rowValues.size(); j++) {
|
||||
String operationType = rowValues.get(j);
|
||||
RoleRights.OPERATION_TYPE ot = RoleRights.OPERATION_TYPE.UNKNOWN;
|
||||
if (operationType.equalsIgnoreCase("R")) {
|
||||
ot = RoleRights.OPERATION_TYPE.READ;
|
||||
} else if (operationType.equalsIgnoreCase("RW")) {
|
||||
ot = RoleRights.OPERATION_TYPE.READ_WRITE;
|
||||
} else if (operationType.equalsIgnoreCase("W")) {
|
||||
ot = RoleRights.OPERATION_TYPE.WRITE;
|
||||
}
|
||||
|
||||
mapOperationTypes.put(headerKeys.get(j), ot);
|
||||
}
|
||||
|
||||
LOG.debug("Map of operation types: " + mapOperationTypes);
|
||||
|
||||
// Starting from index 1 (means the second row in the CSV)
|
||||
for (int i = 1; i < rows.size(); i++) {
|
||||
LOG.trace(i + " row");
|
||||
RoleRights useRights = new RoleRights();
|
||||
CSVRow row = rows.get(i);
|
||||
|
||||
// to map properties
|
||||
rowValues = row.getListValues();
|
||||
|
||||
LOG.debug("rowValues: " + rowValues);
|
||||
Map<String, String> mapUserRolePermissions = new HashMap<String, String>();
|
||||
|
||||
GcubeUserRole gCubeUserRole = toGcubeUserRole(rowValues.get(0));
|
||||
|
||||
if (gCubeUserRole == null) {
|
||||
LOG.warn("The Role " + rowValues.get(0) + " not found into roleName of: " + GcubeUserRole.values());
|
||||
continue;
|
||||
}
|
||||
|
||||
useRights.setUserRole(gCubeUserRole);
|
||||
|
||||
for (int j = 1; j < rowValues.size(); j++) {
|
||||
mapUserRolePermissions.put(headerKeys.get(j), rowValues.get(j));
|
||||
}
|
||||
LOG.debug("Role: " + useRights.getUserRole());
|
||||
LOG.debug("Permissions read: " + mapUserRolePermissions);
|
||||
|
||||
Map<OPERATION_ON_ITEM, OPERATION_TYPE> listPermessions = new HashMap<OPERATION_ON_ITEM, OPERATION_TYPE>();
|
||||
|
||||
for (OPERATION_ON_ITEM value : OPERATION_ON_ITEM.values()) {
|
||||
String yesno = mapUserRolePermissions.get(value.name());
|
||||
|
||||
if (GNAConfigsConverter.checkYesNoValue(yesno)) {
|
||||
listPermessions.put(value, mapOperationTypes.get(value.name()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
useRights.setListPermessions(listPermessions);
|
||||
|
||||
// String writeOwn = mapUserRolePermissions.get(WRITE_OWN_CONFIG);
|
||||
// if (writeOwn != null && writeOwn.equalsIgnoreCase("yes")) {
|
||||
// useRights.setWriteOwn(true);
|
||||
// }
|
||||
//
|
||||
// String writeAny = mapUserRolePermissions.get(WRITE_ANY_CONFIG);
|
||||
// if (writeAny != null && writeAny.equalsIgnoreCase("yes")) {
|
||||
// useRights.setWriteAny(true);
|
||||
// }
|
||||
|
||||
listUserRights.add(useRights);
|
||||
|
||||
}
|
||||
LOG.info("Returning user rights config: " + listUserRights);
|
||||
return listUserRights;
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("An error occurred on reading the GNA DataEntry config from: " + permissions_for_role, e);
|
||||
throw new GNAConfigException("Error on reading the GNA DataEntry from: " + permissions_for_role);
|
||||
} finally {
|
||||
|
||||
if (configurationFile != null) {
|
||||
try {
|
||||
configurationFile.delete();
|
||||
} catch (Exception e) {
|
||||
// silent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the gcube generic query string.
|
||||
*
|
||||
* @param secondaryType the secondary type
|
||||
* @param genericResourceName the generic resource name
|
||||
* @return the gcube generic query string
|
||||
*/
|
||||
public static String getGcubeGenericQueryString(String secondaryType, String genericResourceName) {
|
||||
|
||||
return "for $profile in collection('/db/Profiles/GenericResource')//Resource "
|
||||
+ "where $profile/Profile/SecondaryType/string() eq '" + secondaryType
|
||||
+ "' and $profile/Profile/Name/string() " + " eq '" + genericResourceName + "'" + "return $profile";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the secondary type.
|
||||
*
|
||||
* @return the secondary type
|
||||
*/
|
||||
public String getSecondaryType() {
|
||||
return SECONDARY_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the scope.
|
||||
*
|
||||
* @return the scope
|
||||
*/
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
}
|
|
@ -3,19 +3,12 @@ package org.gcube.application.geoportalcommon;
|
|||
import static org.gcube.resources.discovery.icclient.ICFactory.client;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.LayerItem;
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.exception.ApplicationProfileNotFoundException;
|
||||
import org.gcube.common.resources.gcore.utils.XPathHelper;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
@ -25,30 +18,25 @@ import org.gcube.resources.discovery.client.queries.impl.QueryBox;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Class GeoNaViewerProfileReader.
|
||||
* The Class GNADataViewerConfigProfileReader.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 12, 2020
|
||||
* Dec 21, 2021
|
||||
*/
|
||||
public class GeoNaDataViewerProfileReader {
|
||||
public class GNADataViewerConfigProfileReader {
|
||||
|
||||
private static final String RESOURCE_PROFILE_BODY = "/Resource/Profile/Body";
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final String SECONDARY_TYPE = "ApplicationProfile";
|
||||
public static final String WORKSPACE_EXPLORER_APP_NAME = "GeoNa-Viewer-Profile";
|
||||
public static final String GENERIC_RESOURCE_NAME = "Geoportal-DataViewer-Configs";
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(GeoNaDataViewerProfileReader.class);
|
||||
private static Logger LOG = LoggerFactory.getLogger(GNADataViewerConfigProfileReader.class);
|
||||
private String secondaryType;
|
||||
private String scope;
|
||||
private String appID;
|
||||
|
@ -56,9 +44,9 @@ public class GeoNaDataViewerProfileReader {
|
|||
/**
|
||||
* Instantiates a new application profile reader.
|
||||
*
|
||||
* @param appID the app id
|
||||
* @param appID the app id
|
||||
*/
|
||||
public GeoNaDataViewerProfileReader(String appID) {
|
||||
public GNADataViewerConfigProfileReader(String appID) {
|
||||
|
||||
this.appID = appID;
|
||||
this.secondaryType = SECONDARY_TYPE;
|
||||
|
@ -69,25 +57,27 @@ public class GeoNaDataViewerProfileReader {
|
|||
* Read profile from infrastrucure.
|
||||
*
|
||||
* @return the map
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public GeoNaDataViewerProfile readProfileFromInfrastrucure() throws Exception {
|
||||
protected GNADataViewerConfigProfile readProfileFromInfrastructure() throws Exception {
|
||||
|
||||
String queryString = getGcubeGenericQueryString(secondaryType, appID);
|
||||
logger.info("Scope "+scope+", trying to perform query: "+queryString);
|
||||
LOG.info("Scope " + scope + ", trying to perform query: " + queryString);
|
||||
|
||||
try {
|
||||
|
||||
if (scope == null)
|
||||
throw new Exception("Scope is null, set scope into ScopeProvider");
|
||||
|
||||
GeoNaDataViewerProfile profile = new GeoNaDataViewerProfile();
|
||||
|
||||
logger.info("Trying to fetch ApplicationProfile in the scope: " + scope + ", SecondaryType: "
|
||||
GNADataViewerConfigProfile profile = new GNADataViewerConfigProfile();
|
||||
|
||||
LOG.info("Trying to fetch ApplicationProfile in the scope: " + scope + ", SecondaryType: "
|
||||
+ secondaryType + ", AppId: " + appID);
|
||||
Query q = new QueryBox(queryString);
|
||||
DiscoveryClient<String> client = client();
|
||||
List<String> appProfile = client.submit(q);
|
||||
|
||||
// String item_fields = "";
|
||||
|
||||
if (appProfile == null || appProfile.size() == 0)
|
||||
throw new ApplicationProfileNotFoundException("ApplicationProfile with SecondaryType: " + secondaryType
|
||||
+ ", AppId: " + appID + " is not registered in the scope: " + scope);
|
||||
|
@ -95,52 +85,31 @@ public class GeoNaDataViewerProfileReader {
|
|||
String elem = appProfile.get(0);
|
||||
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
Document doc = docBuilder.parse(new InputSource(new StringReader(elem)));
|
||||
|
||||
|
||||
XPathHelper helper = new XPathHelper(doc.getDocumentElement());
|
||||
|
||||
List<String> currValue = null;
|
||||
String xPathExp = RESOURCE_PROFILE_BODY+"/RestrictedPortletURL/text()";
|
||||
String xPathExp = RESOURCE_PROFILE_BODY + "/RestrictedPortletURL/text()";
|
||||
currValue = helper.evaluate(xPathExp);
|
||||
if (currValue != null && currValue.size() > 0) {
|
||||
profile.setRestrictedPortletURL(currValue.get(0));
|
||||
}else
|
||||
throw new Exception("I'm not able to read the path: "+xPathExp);
|
||||
|
||||
xPathExp = RESOURCE_PROFILE_BODY+"/OpenPortletURL/text()";
|
||||
} else
|
||||
throw new Exception("I'm not able to read the path: " + xPathExp);
|
||||
|
||||
xPathExp = RESOURCE_PROFILE_BODY + "/OpenPortletURL/text()";
|
||||
currValue = helper.evaluate(xPathExp);
|
||||
if (currValue != null && currValue.size() > 0) {
|
||||
profile.setOpenPortletURL(currValue.get(0));
|
||||
}else
|
||||
throw new Exception("I'm not able to read the path: "+xPathExp);
|
||||
|
||||
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
NodeList nodeList = (NodeList) xPath.compile("/Resource/Profile/Body/AvailableLayers/Layer")
|
||||
.evaluate(doc, XPathConstants.NODESET);
|
||||
} else
|
||||
throw new Exception("I'm not able to read the path: " + xPathExp);
|
||||
|
||||
Map<String, LayerItem> mapLayers = new HashMap<String, LayerItem>(nodeList.getLength());
|
||||
|
||||
for (int i = 0; i < nodeList.getLength(); i++) {
|
||||
Node layerNode = nodeList.item(i);
|
||||
if (layerNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element eElement = (Element) layerNode;
|
||||
String layerType = eElement.getElementsByTagName("Type").item(0).getTextContent();
|
||||
String wmsLink = eElement.getElementsByTagName("WMSLink").item(0).getTextContent();
|
||||
String decodedURL = URLDecoder.decode(wmsLink, "UTF-8");
|
||||
LayerItem layer = new LayerItem();
|
||||
layer.setWmsLink(decodedURL);
|
||||
mapLayers.put(layerType.toLowerCase(), layer);
|
||||
}
|
||||
}
|
||||
|
||||
profile.setMapLayers(mapLayers);
|
||||
logger.info("returning: "+profile);
|
||||
LOG.info("returning: " + profile);
|
||||
return profile;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error while trying to read the " + SECONDARY_TYPE + " with SecondaryType "
|
||||
+ WORKSPACE_EXPLORER_APP_NAME + " from scope " + scope, e);
|
||||
LOG.error("Error while trying to read the " + SECONDARY_TYPE + " with SecondaryType "
|
||||
+ GENERIC_RESOURCE_NAME + " from scope " + scope, e);
|
||||
return null;
|
||||
} finally {
|
||||
|
||||
|
@ -182,22 +151,17 @@ public class GeoNaDataViewerProfileReader {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GeoNaViewerProfileReader [secondaryType=" + secondaryType + ", scope=" + scope + ", appID=" + appID
|
||||
+ "]";
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GNADataViewerConfigProfileReader [LOG=");
|
||||
builder.append(LOG);
|
||||
builder.append(", secondaryType=");
|
||||
builder.append(secondaryType);
|
||||
builder.append(", scope=");
|
||||
builder.append(scope);
|
||||
builder.append(", appID=");
|
||||
builder.append(appID);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
public static void main(String[] args) throws Exception {
|
||||
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||
GeoNaDataViewerProfileReader gdvp = new GeoNaDataViewerProfileReader("geoportal-data-viewer-app");
|
||||
GeoNaDataViewerProfile profile = gdvp.readProfileFromInfrastrucure();
|
||||
System.out.println(profile.getRestrictedPortletURL());
|
||||
System.out.println(profile.getOpenPortletURL());
|
||||
|
||||
if(profile.getMapLayers()!=null) {
|
||||
for (String type : profile.getMapLayers().keySet()) {
|
||||
System.out.println("key: "+type+", value: "+profile.getMapLayers().get(type));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
|
@ -3,36 +3,48 @@ package org.gcube.application.geoportalcommon;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataEntryConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
|
||||
import org.gcube.application.geoportalcommon.shared.PublicLink;
|
||||
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
|
||||
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder;
|
||||
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder.RESOLVE_AS;
|
||||
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* The Class GeoportalCommon.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 1, 2020
|
||||
* May 2, 2023
|
||||
*/
|
||||
public class GeoportalCommon {
|
||||
|
||||
|
||||
/** The Constant LOG. */
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GeoportalCommon.class);
|
||||
|
||||
/**
|
||||
* Instantiates a new geoportal common.
|
||||
*/
|
||||
public GeoportalCommon() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the public links for.
|
||||
*
|
||||
* @param item the item
|
||||
* @param gcubeScope the gcube scope
|
||||
* @param item the item
|
||||
* @param createShortURL creates and returns the short URL also.
|
||||
* @return the public links for
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception {
|
||||
public GeoportalItemReferences getPublicLinksFor(String gcubeScope, GeoportalItemReferences item,
|
||||
boolean createShortURL) throws Exception {
|
||||
LOG.info("getPublicLinksFor called for: " + item);
|
||||
|
||||
try {
|
||||
|
@ -40,37 +52,41 @@ public class GeoportalCommon {
|
|||
if (item == null)
|
||||
throw new Exception("Bad request, the item is null");
|
||||
|
||||
if (item.getItemId() == null)
|
||||
throw new Exception("Bad request, the item id is null");
|
||||
if (item.getProjectID() == null)
|
||||
throw new Exception("Bad request, the ProjectID is null");
|
||||
|
||||
if (item.getItemType() == null)
|
||||
throw new Exception("Bad request, the item type is null");
|
||||
if (item.getProfileID() == null)
|
||||
throw new Exception("Bad request, the ProfileID is null");
|
||||
|
||||
GeoNaDataViewerProfile geonaDataProfile = getGeoNaDataViewProfile(GeoportalCommonConstants.GEOPORTAL_DATA_VIEWER_APP);
|
||||
|
||||
// Restricted Link
|
||||
String link = String.format("%s?%s=%s&%s=%s", geonaDataProfile.getRestrictedPortletURL(),
|
||||
GeoportalCommonConstants.GET_GEONA_ITEM_ID, item.getItemId(),
|
||||
GeoportalCommonConstants.GET_GEONA_ITEM_TYPE, item.getItemType());
|
||||
UriResolverManager resolver = new UriResolverManager("GEO");
|
||||
|
||||
// PRIVATE LINK
|
||||
GeoportalResolverQueryStringBuilder builder = new GeoportalResolverQueryStringBuilder(item.getProfileID(),
|
||||
item.getProjectID());
|
||||
builder.scope(gcubeScope);
|
||||
builder.resolverAs(RESOLVE_AS.PRIVATE);
|
||||
// builder.resolverAs(RESOLVE_AS.PRIVATE);
|
||||
Map<String, String> params = builder.buildQueryParameters();
|
||||
String link = resolver.getLink(params, false);
|
||||
String shortUrl = link;
|
||||
try {
|
||||
shortUrl = getShortUrl(link);
|
||||
}catch (Exception e) {
|
||||
LOG.warn("Error on shortening the URL: ",e);
|
||||
if (createShortURL)
|
||||
shortUrl = getShortUrl(link);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Error on shortening the URL: ", e);
|
||||
}
|
||||
item.setRestrictedLink(new PublicLink(link, shortUrl));
|
||||
|
||||
// Open Link
|
||||
link = String.format("%s?%s=%s&%s=%s", geonaDataProfile.getOpenPortletURL(),
|
||||
GeoportalCommonConstants.GET_GEONA_ITEM_ID, item.getItemId(),
|
||||
GeoportalCommonConstants.GET_GEONA_ITEM_TYPE, item.getItemType());
|
||||
|
||||
// PUBLIC LINK
|
||||
builder.resolverAs(RESOLVE_AS.PUBLIC);
|
||||
params = builder.buildQueryParameters();
|
||||
link = resolver.getLink(params, false);
|
||||
shortUrl = link;
|
||||
try {
|
||||
shortUrl = getShortUrl(link);
|
||||
}catch (Exception e) {
|
||||
LOG.warn("Error on shortening the URL: ",e);
|
||||
if (createShortURL)
|
||||
shortUrl = getShortUrl(link);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Error on shortening the URL: ", e);
|
||||
}
|
||||
item.setOpenLink(new PublicLink(link, shortUrl));
|
||||
|
||||
|
@ -84,27 +100,6 @@ public class GeoportalCommon {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the GeoNaData Viewer Profile
|
||||
*
|
||||
* @param appID if null or empty uses the default appID that is {@link GeoportalCommonConstants#GEOPORTAL_DATA_VIEWER_APP}
|
||||
* @return the GeoNaData Viewer Profile
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public GeoNaDataViewerProfile getGeoNaDataViewProfile(String appID) throws Exception {
|
||||
LOG.info("getGeoNaDataViewProfile called for: "+appID);
|
||||
|
||||
if(appID==null || appID.isEmpty())
|
||||
appID = GeoportalCommonConstants.GEOPORTAL_DATA_VIEWER_APP;
|
||||
|
||||
LOG.info("using AppId: "+appID);
|
||||
GeoNaDataViewerProfileReader gdvp = new GeoNaDataViewerProfileReader(appID);
|
||||
GeoNaDataViewerProfile profile = gdvp.readProfileFromInfrastrucure();
|
||||
LOG.info("Returning profile: " + profile);
|
||||
return profile;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the short url.
|
||||
*
|
||||
|
@ -119,9 +114,9 @@ public class GeoportalCommon {
|
|||
return longUrl;
|
||||
|
||||
try {
|
||||
|
||||
|
||||
UrlShortener shortener = new UrlShortener();
|
||||
|
||||
|
||||
if (shortener != null && shortener.isAvailable()) {
|
||||
String toShort = longUrl;
|
||||
String[] splitted = toShort.split("\\?");
|
||||
|
@ -148,4 +143,41 @@ public class GeoportalCommon {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read GNA data viewer config.
|
||||
*
|
||||
* @param appID the app ID. If null uses the default
|
||||
* {@link GeoportalCommonConstants#GEOPORTAL_DATA_VIEWER_APP}
|
||||
* @return the GNA data viewer config profile
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public GNADataViewerConfigProfile readGNADataViewerConfig(String appID) throws Exception {
|
||||
LOG.info("getGeoNaDataViewProfile called for AppID: " + appID);
|
||||
|
||||
if (appID == null || appID.isEmpty()) {
|
||||
appID = GeoportalCommonConstants.GEOPORTAL_DATA_VIEWER_APP;
|
||||
LOG.info("AppID is null, so using DEFAULT: " + appID);
|
||||
}
|
||||
|
||||
GNADataViewerConfigProfileReader gdvp = new GNADataViewerConfigProfileReader(appID);
|
||||
GNADataViewerConfigProfile profile = gdvp.readProfileFromInfrastructure();
|
||||
LOG.info("Returning profile: " + profile);
|
||||
return profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the GNA data config read from ApplicationProfile stored into IS.
|
||||
*
|
||||
* @return the GNA data config
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public GNADataEntryConfigProfile readGNADataEntryConfig() throws Exception {
|
||||
LOG.info("readGNADataEntryConfig called");
|
||||
|
||||
GNADataEntryConfigProfileReader gnaConfigReader = new GNADataEntryConfigProfileReader();
|
||||
GNADataEntryConfigProfile config = gnaConfigReader.readProfileFromInfrastrucure();
|
||||
return config;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,5 +14,4 @@ public class GeoportalCommonConstants {
|
|||
|
||||
public static final String GEOPORTAL_DATA_VIEWER_APP = "geoportal-data-viewer-app";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
package org.gcube.application.geoportalcommon;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The Class ProjectDVBuilder.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Mar 10, 2022
|
||||
*/
|
||||
public class ProjectDVBuilder {
|
||||
|
||||
private boolean lifecycleInformation;
|
||||
private boolean spatialReference = true; //default
|
||||
private boolean temporalReference;
|
||||
private boolean relationships;
|
||||
private List<String> listDocumentKeys;
|
||||
private boolean fullDocumentMap;
|
||||
|
||||
private ProjectDVBuilder() {
|
||||
|
||||
}
|
||||
|
||||
public static ProjectDVBuilder newBuilder() {
|
||||
return new ProjectDVBuilder();
|
||||
}
|
||||
|
||||
public boolean isIncludeLifecycleInformation() {
|
||||
return lifecycleInformation;
|
||||
}
|
||||
|
||||
public boolean isIncludeSpatialReference() {
|
||||
return spatialReference;
|
||||
}
|
||||
|
||||
public boolean isIncludeTemporalReference() {
|
||||
return temporalReference;
|
||||
}
|
||||
|
||||
public boolean isIncludeRelationships() {
|
||||
return relationships;
|
||||
}
|
||||
|
||||
public List<String> getListDocumentKeys() {
|
||||
return listDocumentKeys;
|
||||
}
|
||||
|
||||
public boolean isIncludeFullDocumentMap() {
|
||||
return fullDocumentMap;
|
||||
}
|
||||
|
||||
public ProjectDVBuilder lifecycleInformation(boolean lifecycleInformation) {
|
||||
this.lifecycleInformation = lifecycleInformation;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectDVBuilder spatialReference(boolean includeSpatialReference) {
|
||||
this.spatialReference = includeSpatialReference;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectDVBuilder temporalReference(boolean includeTemporalReference) {
|
||||
this.temporalReference = includeTemporalReference;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectDVBuilder relationships(boolean includeRelationships) {
|
||||
this.relationships = includeRelationships;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectDVBuilder listDocumentKeys(List<String> listDocumentKeys) {
|
||||
this.listDocumentKeys = listDocumentKeys;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectDVBuilder fullDocumentMap(boolean includeFullDocumentMap) {
|
||||
this.fullDocumentMap = includeFullDocumentMap;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ProjectDVBuilder [lifecycleInformation=");
|
||||
builder.append(lifecycleInformation);
|
||||
builder.append(", spatialReference=");
|
||||
builder.append(spatialReference);
|
||||
builder.append(", temporalReference=");
|
||||
builder.append(temporalReference);
|
||||
builder.append(", relationships=");
|
||||
builder.append(relationships);
|
||||
builder.append(", listDocumentKeys=");
|
||||
builder.append(listDocumentKeys);
|
||||
builder.append(", fullDocumentMap=");
|
||||
builder.append(fullDocumentMap);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package org.gcube.application.geoportalcommon;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GeoServerPlatformInfoDV;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
|
||||
/**
|
||||
* The Class SerializerUtil.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Sep 26, 2022
|
||||
*/
|
||||
public class SerializerUtil {
|
||||
|
||||
private static Logger LOG = LoggerFactory.getLogger(SerializerUtil.class);
|
||||
|
||||
private static ObjectMapper mapper;
|
||||
|
||||
private static ObjectMapper mapperXML;
|
||||
|
||||
static {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
||||
mapper.configure(com.fasterxml.jackson.core.JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
|
||||
SimpleModule s = new SimpleModule();
|
||||
mapper.registerModule(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read JSON.
|
||||
*
|
||||
* @param <T> the generic type
|
||||
* @param string the string
|
||||
* @param clazz the clazz
|
||||
* @return the t
|
||||
* @throws JsonProcessingException the json processing exception
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
public static <T> T readJSON(String string, Class<T> clazz) throws JsonProcessingException, IOException {
|
||||
return mapper.readerFor(clazz).readValue(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmarshal XML.
|
||||
*
|
||||
* @param <T> the generic type
|
||||
* @param string the string
|
||||
* @param theClass the the class
|
||||
* @return the class
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static <T> T unmarshalXML(String string, Class<T> theClass) throws Exception {
|
||||
LOG.debug("unmarshalXML: " + string.trim() + " as class: " + theClass);
|
||||
try {
|
||||
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(theClass);
|
||||
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
|
||||
|
||||
if (string == null || string.length() == 0)
|
||||
throw new Exception("Input string is null or empty");
|
||||
|
||||
InputStream stream = new ByteArrayInputStream(string.getBytes());
|
||||
T umarshalledObject = (T) jaxbUnmarshaller.unmarshal(stream);
|
||||
LOG.debug("returning: " + umarshalledObject);
|
||||
|
||||
return umarshalledObject;
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("An error occurred on unmarshalling " + string + "as " + theClass, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class GeoserverPlaformInfoJsonDeserializer extends JsonDeserializer<GeoServerPlatformInfoDV[]> {
|
||||
|
||||
@Override
|
||||
public GeoServerPlatformInfoDV[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
|
||||
LOG.info("deserialize: " +jp.getValueAsString());
|
||||
return jp.readValueAs(GeoServerPlatformInfoDV[].class);
|
||||
//return jp.readValueAs(GeoServerPlatformInfoDV[].class);
|
||||
//List<GeoServerPlatformInfoDV> listPlatform = jp.readValueAs(new TypeReference<List<GeoServerPlatformInfoDV>>() {});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.application.geoportalcommon.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The Class CSVFile.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Jan 29, 2019
|
||||
*/
|
||||
public class CSVFile implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6408321963787244600L;
|
||||
private CSVRow headerRow;
|
||||
private List<CSVRow> valueRows;
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* Instantiates a new CSV file.
|
||||
*/
|
||||
public CSVFile(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new csv file.
|
||||
*
|
||||
* @param fileName the file name
|
||||
* @param headerRow the header row
|
||||
* @param valueRows the value rows
|
||||
*/
|
||||
public CSVFile(String fileName, CSVRow headerRow, List<CSVRow> valueRows) {
|
||||
this.fileName = fileName;
|
||||
this.headerRow = headerRow;
|
||||
this.valueRows = valueRows;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the header row.
|
||||
*
|
||||
* @return the headerRow
|
||||
*/
|
||||
public CSVRow getHeaderRow() {
|
||||
|
||||
return headerRow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the value row.
|
||||
*
|
||||
* @param row the row
|
||||
*/
|
||||
public void addValueRow(CSVRow row) {
|
||||
if(valueRows==null)
|
||||
valueRows = new ArrayList<CSVRow>();
|
||||
|
||||
valueRows.add(row);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the value rows.
|
||||
*
|
||||
* @param valueRows the new value rows
|
||||
*/
|
||||
public void setValueRows(List<CSVRow> valueRows) {
|
||||
this.valueRows = valueRows;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the value rows.
|
||||
*
|
||||
* @return the valueRows
|
||||
*/
|
||||
public List<CSVRow> getValueRows() {
|
||||
|
||||
return valueRows;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the header row.
|
||||
*
|
||||
* @param headerRow the headerRow to set
|
||||
*/
|
||||
public void setHeaderRow(CSVRow headerRow) {
|
||||
|
||||
this.headerRow = headerRow;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the file name.
|
||||
*
|
||||
* @return the fileName
|
||||
*/
|
||||
public String getFileName() {
|
||||
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the file name.
|
||||
*
|
||||
* @param fileName the fileName to set
|
||||
*/
|
||||
public void setFileName(String fileName) {
|
||||
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CSVFile [headerRow=");
|
||||
builder.append(headerRow);
|
||||
builder.append(", valueRows=");
|
||||
builder.append(valueRows);
|
||||
builder.append(", fileName=");
|
||||
builder.append(fileName);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
package org.gcube.application.geoportalcommon.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* The Class CSVReader.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Jan 29, 2019
|
||||
*/
|
||||
public class CSVReader {
|
||||
|
||||
public static final char DEFAULT_SEPARATOR = ',';
|
||||
public static final char DEFAULT_QUOTE = '"';
|
||||
private File file;
|
||||
private CSVFile csvFile;
|
||||
|
||||
/**
|
||||
* Instantiates a new CSV reader.
|
||||
*
|
||||
* @param file the file
|
||||
* @throws FileNotFoundException the file not found exception
|
||||
*/
|
||||
public CSVReader(File file) throws FileNotFoundException {
|
||||
|
||||
this.file = file;
|
||||
this.csvFile = new CSVFile();
|
||||
readCSV(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read csv.
|
||||
*
|
||||
* @param file the file
|
||||
* @throws FileNotFoundException the file not found exception
|
||||
*/
|
||||
private void readCSV(File file) throws FileNotFoundException {
|
||||
|
||||
Scanner scanner = new Scanner(file);
|
||||
csvFile.setFileName(file.getName());
|
||||
int i = 0;
|
||||
while (scanner.hasNext()) {
|
||||
CSVRow csvRow = new CSVRow();
|
||||
List<String> line = parseLine(scanner.nextLine());
|
||||
csvRow.setListValues(line);
|
||||
|
||||
if(i==0){
|
||||
csvFile.setHeaderRow(csvRow);
|
||||
}else{
|
||||
csvFile.addValueRow(csvRow);
|
||||
}
|
||||
i++;
|
||||
|
||||
}
|
||||
scanner.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the line.
|
||||
*
|
||||
* @param cvsLine the cvs line
|
||||
* @return the list
|
||||
*/
|
||||
public static List<String> parseLine(String cvsLine) {
|
||||
|
||||
return parseLine(cvsLine, DEFAULT_SEPARATOR, DEFAULT_QUOTE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the line.
|
||||
*
|
||||
* @param cvsLine the cvs line
|
||||
* @param separators the separators
|
||||
* @return the list
|
||||
*/
|
||||
public static List<String> parseLine(String cvsLine, char separators) {
|
||||
|
||||
return parseLine(cvsLine, separators, DEFAULT_QUOTE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the line.
|
||||
*
|
||||
* @param cvsLine the cvs line
|
||||
* @param separators the separators
|
||||
* @param customQuote the custom quote
|
||||
* @return the list
|
||||
*/
|
||||
private static List<String> parseLine(String cvsLine, char separators, char customQuote) {
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
// if empty, return!
|
||||
if (cvsLine == null || cvsLine.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
if (customQuote == ' ') {
|
||||
customQuote = DEFAULT_QUOTE;
|
||||
}
|
||||
if (separators == ' ') {
|
||||
separators = DEFAULT_SEPARATOR;
|
||||
}
|
||||
StringBuffer curVal = new StringBuffer();
|
||||
boolean inQuotes = false;
|
||||
boolean startCollectChar = false;
|
||||
boolean doubleQuotesInColumn = false;
|
||||
char[] chars = cvsLine.toCharArray();
|
||||
for (char ch : chars) {
|
||||
if (inQuotes) {
|
||||
startCollectChar = true;
|
||||
if (ch == customQuote) {
|
||||
inQuotes = false;
|
||||
doubleQuotesInColumn = false;
|
||||
}
|
||||
else {
|
||||
// Fixed : allow "" in custom quote enclosed
|
||||
if (ch == '\"') {
|
||||
if (!doubleQuotesInColumn) {
|
||||
curVal.append(ch);
|
||||
doubleQuotesInColumn = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
curVal.append(ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ch == customQuote) {
|
||||
inQuotes = true;
|
||||
// Fixed : allow "" in empty quote enclosed
|
||||
if (chars[0] != '"' && customQuote == '\"') {
|
||||
curVal.append('"');
|
||||
}
|
||||
// double quotes in column will hit this!
|
||||
if (startCollectChar) {
|
||||
curVal.append('"');
|
||||
}
|
||||
}
|
||||
else if (ch == separators) {
|
||||
result.add(curVal.toString());
|
||||
curVal = new StringBuffer();
|
||||
startCollectChar = false;
|
||||
}
|
||||
else if (ch == '\r') {
|
||||
// ignore LF characters
|
||||
continue;
|
||||
}
|
||||
else if (ch == '\n') {
|
||||
// the end, break!
|
||||
break;
|
||||
}
|
||||
else {
|
||||
curVal.append(ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
result.add(curVal.toString());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the csv file.
|
||||
*
|
||||
* @return the csvFile
|
||||
*/
|
||||
public CSVFile getCsvFile() {
|
||||
|
||||
return csvFile;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the file.
|
||||
*
|
||||
* @return the file
|
||||
*/
|
||||
public File getFile() {
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.application.geoportalcommon.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* The Class CSVRow.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Jan 29, 2019
|
||||
*/
|
||||
public class CSVRow implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6254861811998867626L;
|
||||
|
||||
private List<String> listValues;
|
||||
|
||||
/**
|
||||
* Instantiates a new CSV row.
|
||||
*/
|
||||
public CSVRow(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list values.
|
||||
*
|
||||
* @return the listValues
|
||||
*/
|
||||
public List<String> getListValues() {
|
||||
|
||||
return listValues;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param listValues the listValues to set
|
||||
*/
|
||||
public void setListValues(List<String> listValues) {
|
||||
|
||||
this.listValues = listValues;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the value.
|
||||
*
|
||||
* @param value the value
|
||||
*/
|
||||
public void addValue(String value) {
|
||||
if(listValues==null)
|
||||
listValues = new ArrayList<String>();
|
||||
|
||||
listValues.add(value);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CSVRow [listValues=");
|
||||
builder.append(listValues);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package org.gcube.application.geoportalcommon.config;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
/**
|
||||
* The Class FileUtil.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 2, 2021
|
||||
*/
|
||||
public class FileUtil {
|
||||
|
||||
/**
|
||||
* Input stream to temp file.
|
||||
*
|
||||
* @param inputStream the input stream
|
||||
* @param fileName the file name
|
||||
* @return the file
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
// InputStream -> Temp File
|
||||
public static File inputStreamToTempFile(InputStream inputStream, String fileName) throws IOException {
|
||||
|
||||
File tempFile = File.createTempFile(fileName, ".tmp");
|
||||
// File tempFile = File.createTempFile("MyAppName-", ".tmp");
|
||||
try (FileOutputStream outputStream = new FileOutputStream(tempFile)) {
|
||||
|
||||
int read;
|
||||
byte[] bytes = new byte[1024];
|
||||
|
||||
while ((read = inputStream.read(bytes)) != -1) {
|
||||
outputStream.write(bytes, 0, read);
|
||||
}
|
||||
|
||||
return tempFile;
|
||||
|
||||
} finally {
|
||||
tempFile.deleteOnExit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Input stream to temp file.
|
||||
*
|
||||
* @param copyString the copy string
|
||||
* @return
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
public static File inputStreamToTempFile(String copyString, String prefixFile) throws IOException {
|
||||
|
||||
File targetFile = null;
|
||||
try {
|
||||
InputStream initialStream = new ByteArrayInputStream(copyString.getBytes());
|
||||
targetFile = File.createTempFile(prefixFile, ".tmp");
|
||||
|
||||
java.nio.file.Files.copy(initialStream, targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
try {
|
||||
if (initialStream != null) {
|
||||
initialStream.close();
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
// ignore
|
||||
}
|
||||
return targetFile;
|
||||
} finally {
|
||||
try {
|
||||
if (targetFile != null)
|
||||
targetFile.deleteOnExit();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy input stream to file.
|
||||
*
|
||||
* @param is the is
|
||||
* @param to the to
|
||||
* @return the file
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
public static File copyInputStreamToFile(InputStream is, String to) throws IOException {
|
||||
Path dest = Paths.get(to);
|
||||
Files.copy(is, dest);
|
||||
return new File(to);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package org.gcube.application.geoportalcommon.geoportal;
|
||||
|
||||
/**
|
||||
* The Class GeoportalClientCaller
|
||||
*
|
||||
* Wrapping the geoportal Clients
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Mar 11, 2022
|
||||
*/
|
||||
public class GeoportalClientCaller {
|
||||
|
||||
|
||||
/**
|
||||
* Use case descriptor client.
|
||||
*
|
||||
* @return the use case descriptor caller
|
||||
*/
|
||||
public static UseCaseDescriptorCaller useCaseDescriptors() {
|
||||
return new UseCaseDescriptorCaller();
|
||||
}
|
||||
|
||||
/**
|
||||
* Projects client
|
||||
*
|
||||
* @return the projects caller
|
||||
*/
|
||||
public static ProjectsCaller projects() {
|
||||
return new ProjectsCaller();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package org.gcube.application.geoportalcommon.geoportal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider;
|
||||
|
||||
/**
|
||||
* The Class GeoportalConfigUtil.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Sep 15, 2022
|
||||
*/
|
||||
public class GeoportalConfigUtil {
|
||||
private static Logger LOG = LoggerFactory.getLogger(GeoportalConfigUtil.class);
|
||||
|
||||
/**
|
||||
* Read roles for STEP id.
|
||||
*
|
||||
* @param handler the handler
|
||||
* @param stepID the step ID
|
||||
* @return the list
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static List<String> readRolesForSTEPId(HandlerDeclaration handler, String stepID) throws Exception {
|
||||
LOG.debug("readRolesForSTEPId called for stepID {}, handler {}", stepID, handler);
|
||||
|
||||
List<String> roles = new ArrayList<String>();
|
||||
try {
|
||||
|
||||
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
|
||||
.jsonProvider(new JsonOrgJsonProvider()).build();
|
||||
|
||||
String toJSON = handler.getConfiguration().toJson();
|
||||
LOG.debug("Handler to JSON: " + toJSON);
|
||||
JSONObject jObject = new JSONObject(toJSON);
|
||||
JsonPath jsonPath = JsonPath.compile("$.step_access[?(@.STEP == '" + stepID + "' )].roles");
|
||||
LOG.trace("jsonPath: " + jsonPath.getPath());
|
||||
// $..book[?(@.price <= $['expensive'])]
|
||||
JSONArray data = jsonPath.read(jObject, configuration);
|
||||
LOG.debug("jsonPath matching data lenght: " + data.length());
|
||||
HashSet<String> listdata = new HashSet<String>(data.length());
|
||||
|
||||
if(data.length()>0) {
|
||||
LOG.debug("stepID found");
|
||||
try {
|
||||
JSONArray arrayRoles = new JSONArray(data.get(0).toString());
|
||||
for (int i = 0; i < arrayRoles.length(); i++) {
|
||||
String role = arrayRoles.get(i).toString();
|
||||
LOG.debug("for STEP_ID {} read role {}", stepID, role);
|
||||
listdata.add(role);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
LOG.warn("Error on reading array roles for STEP_ID: "+stepID, e);
|
||||
}
|
||||
}
|
||||
|
||||
roles = listdata.stream().collect(Collectors.toList());
|
||||
LOG.info("for STEP_ID {} returning Roles {} ", stepID, roles);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Error occurred on reading roles into handler {} returning no role", handler);
|
||||
|
||||
}
|
||||
|
||||
return roles;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,670 @@
|
|||
package org.gcube.application.geoportalcommon.geoportal;
|
||||
|
||||
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.faults.InvalidRequestException;
|
||||
import org.gcube.application.geoportal.common.model.configuration.Archive;
|
||||
import org.gcube.application.geoportal.common.model.configuration.Configuration;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.document.relationships.RelationshipNavigationObject;
|
||||
import org.gcube.application.geoportal.common.model.rest.CreateRelationshipRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.DeleteRelationshipRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest.OrderedRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest.OrderedRequest.Direction;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest.PagedRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.StepExecutionRequest;
|
||||
import org.gcube.application.geoportal.common.rest.Projects;
|
||||
import org.gcube.application.geoportal.common.utils.FileSets;
|
||||
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
|
||||
import org.gcube.application.geoportalcommon.shared.WhereClause;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.PhaseDV;
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider;
|
||||
import com.mongodb.BasicDBList;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.BasicDBObjectBuilder;
|
||||
|
||||
/**
|
||||
* The Class ProjectsCaller.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Mar 17, 2022
|
||||
*/
|
||||
public class ProjectsCaller {
|
||||
|
||||
public static final String DOCUMENT_STORE_COLLECTION = "DOCUMENT-STORE-COLLECTION";
|
||||
private static Logger LOG = LoggerFactory.getLogger(GeoportalClientCaller.class);
|
||||
|
||||
/**
|
||||
* Gets the client.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @return the client
|
||||
*/
|
||||
public Projects<Project> getClient(String profileID) {
|
||||
LOG.info("getClient called for profileID={}", profileID);
|
||||
return projects(profileID).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the new.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param jsonDocument the json document
|
||||
* @return the project
|
||||
* @throws RemoteException the remote exception
|
||||
*/
|
||||
public Project createNew(String profileID, String jsonDocument) throws RemoteException {
|
||||
LOG.info("createNew called on profileID={}", profileID);
|
||||
Document myDocument = Document.parse(jsonDocument);
|
||||
Projects<Project> client = getClient(profileID);
|
||||
Project project = client.createNew(myDocument);
|
||||
|
||||
return project;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register file set.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param project the project
|
||||
* @param theFile the the file
|
||||
* @param parentPath the parent path
|
||||
* @param fieldName the field name
|
||||
* @param fieldDefinition the field definition
|
||||
* @return the project
|
||||
* @throws RemoteException the remote exception
|
||||
* @throws FileNotFoundException the file not found exception
|
||||
* @throws JsonProcessingException the json processing exception
|
||||
* @throws InvalidRequestException the invalid request exception
|
||||
*/
|
||||
public Project registerFileSet(String profileID, Project project, File theFile, String parentPath, String fieldName,
|
||||
String fieldDefinition)
|
||||
throws RemoteException, FileNotFoundException, JsonProcessingException, InvalidRequestException {
|
||||
LOG.info(
|
||||
"registerFileSet called with [profileID={}, projectID={}, theFile={}, parentPath={}, fieldName={}, fieldDefinition={}",
|
||||
parentPath, project.getId(), theFile, parentPath, fieldName, fieldDefinition);
|
||||
|
||||
Projects<Project> client = getClient(profileID);
|
||||
|
||||
// Prepare request
|
||||
RegisterFileSetRequest fsRequest = FileSets.prepareRequest(new StorageUtils(), parentPath, fieldName,
|
||||
fieldDefinition, theFile);
|
||||
|
||||
project = client.registerFileSet(project.getId(), fsRequest);
|
||||
LOG.trace("Resulting Project : " + project);
|
||||
return project;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list for profile ID.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @return the list for profile ID
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public List<Project> getListForProfileID(String profileID) throws Exception {
|
||||
LOG.info("getListForProfileID called for profileID: {}", profileID);
|
||||
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
||||
|
||||
List<Project> listProjects = new ArrayList<Project>();
|
||||
Iterator<Project> projects = client.query(new QueryRequest());
|
||||
for (Iterator<Project> iterator = projects; projects.hasNext();) {
|
||||
Project prg = (Project) iterator.next();
|
||||
listProjects.add(prg);
|
||||
|
||||
}
|
||||
|
||||
LOG.info("returning {} project/s", listProjects.size(), Project.class.getName());
|
||||
return listProjects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the project by ID.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param projectID the project ID
|
||||
* @return the project by ID
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public Project getProjectByID(String profileID, String projectID) throws Exception {
|
||||
LOG.info("getProjectByID called for profileID: {}, projectID: {}", profileID, projectID);
|
||||
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
||||
Project project = client.getById(projectID);
|
||||
LOG.info("returning project {}", project != null ? project.getId() : null);
|
||||
return project;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the relationship chain.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param projectID the project ID
|
||||
* @param relationID the relation ID
|
||||
* @param deep the deep
|
||||
* @return the relationship chain
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public Iterator<RelationshipNavigationObject> getRelationshipChain(String profileID, String projectID,
|
||||
String relationID, Boolean deep) throws Exception {
|
||||
LOG.info("getRelationshipChain called for projectID: {}, relationID: {}", projectID, projectID);
|
||||
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
||||
return client.getRelationshipChain(projectID, relationID, deep);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @return the configuration
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public Configuration getConfiguration(String profileID) throws Exception {
|
||||
LOG.info("getConfiguration called for profileID: {} ", profileID);
|
||||
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
||||
Configuration config = client.getConfiguration();
|
||||
LOG.debug("returning: {} ", config);
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total document.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @return the total document
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public Integer getTotalDocument(String profileID) throws Exception {
|
||||
LOG.info("getTotalDocument called for profileID: {}", profileID);
|
||||
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
||||
Configuration config = client.getConfiguration();
|
||||
List<Archive> listArchives = config.getArchives();
|
||||
|
||||
for (Archive archive : listArchives) {
|
||||
String theType = archive.getString("_type");
|
||||
if (theType.equalsIgnoreCase(DOCUMENT_STORE_COLLECTION)) {
|
||||
String totalDocumentAre = archive.get("count").toString();
|
||||
int total = Integer.parseInt(totalDocumentAre);
|
||||
LOG.info("total docs for profileID: {}, are: {}", profileID, total);
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total document.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @return the total document
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public List<String> getIDsPhases(String profileID) throws Exception {
|
||||
LOG.info("getIDsPhases called for profileID: {}", profileID);
|
||||
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
||||
Configuration config = client.getConfiguration();
|
||||
List<Archive> listArchives = config.getArchives();
|
||||
|
||||
for (Archive archive : listArchives) {
|
||||
String theType = archive.getString("_type");
|
||||
if (theType.equalsIgnoreCase(DOCUMENT_STORE_COLLECTION)) {
|
||||
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
|
||||
.jsonProvider(new JsonOrgJsonProvider()).build();
|
||||
String toJSON = archive.toJson();
|
||||
JSONObject jObject = new JSONObject(toJSON);
|
||||
JsonPath jsonPath = JsonPath.compile("$.countByPhase[*]._id.phase");
|
||||
JSONArray phases = jsonPath.read(jObject, configuration);
|
||||
HashSet<String> listdata = new HashSet<String>(phases.length());
|
||||
for (int i = 0; i < phases.length(); i++) {
|
||||
listdata.add(phases.get(i).toString());
|
||||
}
|
||||
List<String> idsPhases = listdata.stream().collect(Collectors.toList());
|
||||
LOG.info("getIDsPhases returning: {}", idsPhases);
|
||||
return idsPhases;
|
||||
}
|
||||
}
|
||||
|
||||
LOG.info("getIDsPhases returning null");
|
||||
return null;
|
||||
}
|
||||
|
||||
public Integer getCountByPhaseFor(String profileID, String phase, String status) throws Exception {
|
||||
LOG.info("getCountByPhaseFor called for profileID: {}, phase: {}, status: {}", profileID, phase, status);
|
||||
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
||||
Configuration config = client.getConfiguration();
|
||||
List<Archive> listArchives = config.getArchives();
|
||||
Integer count = null;
|
||||
for (Archive archive : listArchives) {
|
||||
String theType = archive.getString("_type");
|
||||
if (theType.equalsIgnoreCase(DOCUMENT_STORE_COLLECTION)) {
|
||||
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
|
||||
.jsonProvider(new JsonOrgJsonProvider()).build();
|
||||
String toJSON = archive.toJson();
|
||||
JSONObject jObject = new JSONObject(toJSON);
|
||||
String query = String.format("$.countByPhase[*][?(@._id.phase == '%s' && @._id.status == '%s')].count",
|
||||
phase, status);
|
||||
LOG.debug("Performing query: " + query);
|
||||
JsonPath jsonPath = JsonPath.compile(query);
|
||||
JSONArray counts = jsonPath.read(jObject, configuration);
|
||||
try {
|
||||
count = counts.getInt(0);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("getCountByPhaseFor error: " + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG.info("getCountByPhaseFor returning: " + count);
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the phases into document store collection.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @return the phases into document store collection
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public PhaseDV[] getPhasesIntoDocumentStoreCollection(String profileID) throws Exception {
|
||||
LOG.info("getPhases called for profileID: {}", profileID);
|
||||
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
||||
Configuration config = client.getConfiguration();
|
||||
List<Archive> listArchives = config.getArchives();
|
||||
|
||||
for (Archive archive : listArchives) {
|
||||
String theType = archive.getString("_type");
|
||||
if (theType.equalsIgnoreCase(DOCUMENT_STORE_COLLECTION)) {
|
||||
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
|
||||
.jsonProvider(new JsonOrgJsonProvider()).build();
|
||||
String toJSON = archive.toJson();
|
||||
JSONObject jObject = new JSONObject(toJSON);
|
||||
JsonPath jsonPath = JsonPath.compile("$.countByPhase[*]");
|
||||
JSONArray phases = jsonPath.read(jObject, configuration);
|
||||
|
||||
final ObjectMapper objectMapper = new ObjectMapper();
|
||||
PhaseDV[] phasesArr = objectMapper.readValue(phases.toString(), PhaseDV[].class);
|
||||
LOG.info("getPhases returning {} PhaseDVs", phasesArr.length);
|
||||
return phasesArr;
|
||||
}
|
||||
}
|
||||
|
||||
LOG.info("getPhases returning null");
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform step.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param projectID the project ID
|
||||
* @param stepID the step ID
|
||||
* @param options the options
|
||||
* @return the project
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public Project performStep(String profileID, String projectID, String stepID, Document options) throws Exception {
|
||||
LOG.info("performStep called for profileID: {}, projectID: {}", profileID, projectID);
|
||||
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
||||
StepExecutionRequest request = new StepExecutionRequest(stepID, options);
|
||||
Project project = client.performStep(projectID, request);
|
||||
|
||||
LOG.info("performStep returning project ID: " + project.getId());
|
||||
return project;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete project.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param projectID the project ID
|
||||
* @param force the force
|
||||
* @throws RemoteException the remote exception
|
||||
*/
|
||||
public void deleteProject(String profileID, String projectID, boolean force) throws RemoteException {
|
||||
LOG.info("deleteProject called for projectID {}", projectID);
|
||||
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
||||
|
||||
if (force)
|
||||
client.deleteById(projectID, force);
|
||||
else
|
||||
client.deleteById(projectID);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update project.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param projectID the project ID
|
||||
* @param updatedDocument the updated document
|
||||
* @return the project
|
||||
* @throws RemoteException the remote exception
|
||||
*/
|
||||
public Project updateProject(String profileID, String projectID, Document updatedDocument) throws RemoteException {
|
||||
LOG.info("updateProject called for projectID {}", projectID);
|
||||
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
||||
return client.updateDocument(projectID, updatedDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the relationship.
|
||||
*
|
||||
* @param fromProfileID the from profile ID
|
||||
* @param fromProjectID the from project ID
|
||||
* @param relationshipId the relationship id
|
||||
* @param toProfileID the to profile ID
|
||||
* @param toProjectID the to project ID
|
||||
* @throws RemoteException the remote exception
|
||||
*/
|
||||
public void createRelationship(String fromProfileID, String fromProjectID, String relationshipId,
|
||||
String toProfileID, String toProjectID) throws RemoteException {
|
||||
LOG.info("createRelationship called for fromProfileID {} and fromProjectID {}", fromProfileID, fromProjectID);
|
||||
LOG.info("create relationshipName {}", relationshipId);
|
||||
LOG.info("to toProfileID {} and toProjectID {}", toProfileID, toProjectID);
|
||||
Projects<Project> client = (Projects<Project>) getClient(fromProfileID);
|
||||
|
||||
CreateRelationshipRequest request = new CreateRelationshipRequest(fromProjectID, relationshipId, toProjectID,
|
||||
toProfileID);
|
||||
client.setRelation(request);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete relationship.
|
||||
*
|
||||
* @param fromProfileID the from profile ID
|
||||
* @param fromProjectID the from project ID
|
||||
* @param relationshipId the relationship id
|
||||
* @param toProfileID the to profile ID
|
||||
* @param toProjectID the to project ID
|
||||
* @throws RemoteException the remote exception
|
||||
*/
|
||||
public void deleteRelationship(String fromProfileID, String fromProjectID, String relationshipId,
|
||||
String toProfileID, String toProjectID) throws RemoteException {
|
||||
LOG.info("deleteRelationship called for fromProfileID {} and fromProjectID {}", fromProfileID, fromProjectID);
|
||||
LOG.info("deleteRelationship relationshipName {}", relationshipId);
|
||||
LOG.info("to toProfileID {} and toProjectID {}", toProfileID, toProjectID);
|
||||
|
||||
Projects<Project> client = (Projects<Project>) getClient(fromProfileID);
|
||||
|
||||
DeleteRelationshipRequest request = new DeleteRelationshipRequest(fromProjectID, relationshipId, toProjectID,
|
||||
toProfileID);
|
||||
client.deleteRelation(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete fileset.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param projectID the project ID
|
||||
* @param jsonPathToFileset the json path to fileset
|
||||
* @param force the force
|
||||
* @param ignoreErrors the ignore errors
|
||||
* @return the project
|
||||
* @throws RemoteException the remote exception
|
||||
*/
|
||||
public Project deleteFileset(String profileID, String projectID, String jsonPathToFileset, Boolean force,
|
||||
Boolean ignoreErrors) throws RemoteException {
|
||||
LOG.info("deleteFileset called for profileID {} and projectID {}, fileset path: {}", profileID, projectID,
|
||||
jsonPathToFileset);
|
||||
|
||||
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
||||
|
||||
ignoreErrors = ignoreErrors == null ? false : ignoreErrors;
|
||||
|
||||
Project project = client.deleteFileSet(projectID, jsonPathToFileset, force, ignoreErrors);
|
||||
LOG.info("fileset {} deleted", jsonPathToFileset);
|
||||
LOG.debug("returning new project: {} ", project.getTheDocument());
|
||||
return project;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple query.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param filter the filter
|
||||
* @return the iterator
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public Iterator<Project> simpleQuery(String profileID, Document filter) throws Exception {
|
||||
LOG.info("simpleQuery called for profileID {} and filter {}", profileID, filter);
|
||||
try {
|
||||
|
||||
Projects<Project> geoportalClient = getClient(profileID);
|
||||
QueryRequest request = new QueryRequest();
|
||||
request.setFilter(filter);
|
||||
return geoportalClient.query(request);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on performing query: " + filter, e);
|
||||
throw new Exception("Error occurred on performing query " + filter + ". Error: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Query on mongo.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param totalItems the total items
|
||||
* @param offset the offset
|
||||
* @param limit the limit
|
||||
* @param filter the filter
|
||||
* @return the iterator
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public Iterator<Project> queryOnMongo(String profileID, Integer totalItems, Integer offset, Integer limit,
|
||||
SearchingFilter filter) throws Exception {
|
||||
LOG.debug("queryOnMongo called");
|
||||
|
||||
try {
|
||||
|
||||
Projects<Project> geoportalClient = getClient(profileID);
|
||||
|
||||
if (totalItems == null || totalItems < 0) {
|
||||
// TODO MUST BE REPLACED BY COUNT
|
||||
List<Project> listOfProjects = getListForProfileID(profileID);
|
||||
int listConcessioniSize = listOfProjects.size();
|
||||
totalItems = listConcessioniSize;
|
||||
}
|
||||
|
||||
Integer offsetIndex = offset;
|
||||
Integer limitIndex = limit;
|
||||
|
||||
if (offset == null || offset < 0) {
|
||||
offsetIndex = 0;
|
||||
}
|
||||
if (limit == null || limit < 0) {
|
||||
limitIndex = totalItems;
|
||||
}
|
||||
|
||||
Direction sDirection = null;
|
||||
List<String> orderingFields = new ArrayList<String>();
|
||||
|
||||
if (filter == null) {
|
||||
LOG.info("No filter found, creating empty filter");
|
||||
filter = new SearchingFilter();
|
||||
}
|
||||
|
||||
ORDER order = filter.getOrder();
|
||||
|
||||
if (order == null) {
|
||||
order = ORDER.ASC;
|
||||
LOG.info("No direction/order found, using default: " + order);
|
||||
}
|
||||
|
||||
switch (order) {
|
||||
case ASC:
|
||||
sDirection = Direction.ASCENDING;
|
||||
break;
|
||||
case DESC:
|
||||
sDirection = Direction.DESCENDING;
|
||||
break;
|
||||
}
|
||||
|
||||
List<ItemFieldDV> orderByFields = filter.getOrderByFields();
|
||||
|
||||
if (orderByFields == null) {
|
||||
orderByFields = new ArrayList<ItemFieldDV>();
|
||||
}
|
||||
|
||||
// if (orderByFields.isEmpty()) {
|
||||
// ItemFieldDV orderD = new ItemFieldDV("", Arrays.asList("name"), null, false, false, false);
|
||||
// LOG.info("Order by is null, adding default: " + orderD);
|
||||
// orderByFields.add(orderD);
|
||||
// }
|
||||
|
||||
for (ItemFieldDV itemField : orderByFields) {
|
||||
if (itemField.getJsonFields() != null) {
|
||||
for (String jsonFieldPath : itemField.getJsonFields()) {
|
||||
// String fieldFullPath = String.format("%s.%s", itemField.getProjection(),
|
||||
// field);
|
||||
orderingFields.add(jsonFieldPath);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Map<String, Object> projection = filter.getProjection();
|
||||
|
||||
Document projectionDocument = null;
|
||||
if (projection != null && !projection.isEmpty()) {
|
||||
projectionDocument = new Document(projection);
|
||||
}
|
||||
|
||||
QueryRequest request = new QueryRequest();
|
||||
PagedRequest paging = new PagedRequest();
|
||||
paging.setOffset(offsetIndex);
|
||||
paging.setLimit(limitIndex);
|
||||
request.setPaging(paging);
|
||||
|
||||
OrderedRequest ordering = new OrderedRequest();
|
||||
ordering.setDirection(sDirection);
|
||||
ordering.setFields(orderingFields);
|
||||
|
||||
request.setOrdering(ordering);
|
||||
|
||||
Document query = new Document();
|
||||
if (filter.getConditions() != null) {
|
||||
for (WhereClause whereClause : filter.getConditions()) {
|
||||
|
||||
LOGICAL_OP searchWithOperator = whereClause.getOperator();
|
||||
if (searchWithOperator == null) {
|
||||
searchWithOperator = LOGICAL_OP.OR;
|
||||
}
|
||||
|
||||
if (whereClause.getSearchInto() != null && !whereClause.getSearchInto().isEmpty()) {
|
||||
Map<String, Object> searchFields = whereClause.getSearchInto();
|
||||
BasicDBObjectBuilder builder = BasicDBObjectBuilder.start();
|
||||
for (String key : searchFields.keySet()) {
|
||||
// using regex and case-insensitive
|
||||
BasicDBObject bs = new BasicDBObject();
|
||||
bs.append("$regex", searchFields.get(key));
|
||||
bs.append("$options", "i");
|
||||
builder.append(key, bs);
|
||||
|
||||
}
|
||||
// Building list of Document in OR clause
|
||||
BasicDBList list = new BasicDBList();
|
||||
Map map = builder.get().toMap();
|
||||
for (Object key : map.keySet()) {
|
||||
|
||||
BasicDBObject value = (BasicDBObject) map.get(key);
|
||||
Document doc = new Document((String) key, value);
|
||||
list.add(doc);
|
||||
}
|
||||
|
||||
// query = new Document();
|
||||
query.put(searchWithOperator.getOperator(), list);
|
||||
|
||||
// BasicDBObject bs = new BasicDBObject();
|
||||
// bs.append("$eq", "PASSED");
|
||||
// query.put("report.status", bs);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (projectionDocument != null) {
|
||||
request.setProjection(projectionDocument);
|
||||
|
||||
// THE first field specified in the projection must be not null
|
||||
BasicDBObject bsNotEqualEmpty = new BasicDBObject();
|
||||
bsNotEqualEmpty.append("$ne", null);
|
||||
|
||||
Optional<String> firstKey = projection.keySet().stream().findFirst();
|
||||
if (firstKey.isPresent()) {
|
||||
String firstFieldPath = firstKey.get();
|
||||
query.append(firstFieldPath, bsNotEqualEmpty);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// REMOVING DIRTY DOCUMENTS
|
||||
/*
|
||||
* BasicDBObject bsValid_Document = new BasicDBObject();
|
||||
* bsValid_Document.append("$exists", true); bsValid_Document.append("$ne",
|
||||
* null); query.append("_theDocument", bsValid_Document);
|
||||
*
|
||||
* BasicDBObject bsValidLfc = new BasicDBObject(); bsValidLfc.append("$ne",
|
||||
* null); query.append("_lifecycleInformation._phase", bsValidLfc);
|
||||
*/
|
||||
|
||||
// BasicDBObject bsDocumentExists = new BasicDBObject();
|
||||
// bsDocumentExists.append("$exists", false);
|
||||
// query.append("theDocument", bsDocumentExists);
|
||||
|
||||
// BasicDBObject bsNotEqualEmpty = new BasicDBObject();
|
||||
// bsNotEqualEmpty.append("$ne", null);
|
||||
// query.append("_theDocument.nome", bsNotEqualEmpty);
|
||||
|
||||
request.setFilter(query);
|
||||
|
||||
LOG.info("Paging offset: " + offsetIndex + ", limit: " + limitIndex);
|
||||
LOG.info("Direction: " + sDirection);
|
||||
LOG.info("Projection: " + projectionDocument);
|
||||
LOG.info("Order by Fields: " + ordering);
|
||||
LOG.info("Search for conditions: " + filter.getConditions());
|
||||
if (query != null) {
|
||||
LOG.info("Search query to JSON: " + query.toJson());
|
||||
}
|
||||
|
||||
return geoportalClient.query(request);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on loading paginated and filtered list of Project: ", e);
|
||||
throw new Exception("Error occurred on loading list of Project. Error: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,229 @@
|
|||
package org.gcube.application.geoportalcommon.geoportal;
|
||||
|
||||
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.useCaseDescriptors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.RelationshipDefinition;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
import org.gcube.application.geoportal.common.rest.UseCaseDescriptorsI;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.mongodb.BasicDBList;
|
||||
import com.mongodb.BasicDBObject;
|
||||
|
||||
/**
|
||||
* The Class UseCaseDescriptorCaller.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Sep 14, 2022
|
||||
*/
|
||||
public class UseCaseDescriptorCaller {
|
||||
|
||||
private static Logger LOG = LoggerFactory.getLogger(UseCaseDescriptorCaller.class);
|
||||
|
||||
public static final String TIMELINE_CONFIG_TJT_DOCUMENT = "tjt_document";
|
||||
|
||||
/**
|
||||
* Use case descriptors client.
|
||||
*
|
||||
* @return the use case descriptors I
|
||||
*/
|
||||
public UseCaseDescriptorsI useCaseDescriptorsClient() {
|
||||
LOG.info("useCaseDescriptorsClient called");
|
||||
return useCaseDescriptors().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list.
|
||||
*
|
||||
* @return the list
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public List<UseCaseDescriptor> getList() throws Exception {
|
||||
LOG.info("getList called");
|
||||
UseCaseDescriptorsI client = useCaseDescriptorsClient();
|
||||
List<UseCaseDescriptor> listUCD = new ArrayList<UseCaseDescriptor>();
|
||||
Iterator<UseCaseDescriptor> useCaseDescrs = client.query(new QueryRequest());
|
||||
for (Iterator<UseCaseDescriptor> iterator = useCaseDescrs; useCaseDescrs.hasNext();) {
|
||||
UseCaseDescriptor prg = (UseCaseDescriptor) iterator.next();
|
||||
listUCD.add(prg);
|
||||
|
||||
}
|
||||
|
||||
LOG.info("returning {} {}", listUCD.size(), UseCaseDescriptor.class.getName());
|
||||
return listUCD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list for handler ids.
|
||||
*
|
||||
* @param listHandlersIds the list handlers ids
|
||||
* @return the list for handler ids
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public List<UseCaseDescriptor> getListForHandlerIds(List<String> listHandlersIds) throws Exception {
|
||||
LOG.info("getListForHandlerIds called");
|
||||
return getListForJSONPath("_handlers._id", listHandlersIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list for JSON path.
|
||||
*
|
||||
* @param jsonPath the json path
|
||||
* @param listValues the list values
|
||||
* @return the list for JSON path
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public List<UseCaseDescriptor> getListForJSONPath(String jsonPath, List<String> listValues) throws Exception {
|
||||
LOG.info("getListForJSONPath called for jsonPath: {}, with listValues: {}", jsonPath, listValues);
|
||||
UseCaseDescriptorsI client = useCaseDescriptorsClient();
|
||||
List<UseCaseDescriptor> listUCD = new ArrayList<UseCaseDescriptor>();
|
||||
|
||||
// BasicDBObjectBuilder builder = BasicDBObjectBuilder.start();
|
||||
// for (String key : listHandlersIds) {
|
||||
// // using regex and case-insensitive
|
||||
// BasicDBObject bs = new BasicDBObject();
|
||||
// bs.append(jsonPath, key);
|
||||
// builder.append(key, bs);
|
||||
//
|
||||
// }
|
||||
// Building list of Document in OR clause
|
||||
BasicDBList list = new BasicDBList();
|
||||
for (String value : listValues) {
|
||||
|
||||
Document doc = new Document(jsonPath, value);
|
||||
list.add(doc);
|
||||
}
|
||||
|
||||
QueryRequest queryRequest = new QueryRequest();
|
||||
Document queryDoc = new Document();
|
||||
queryDoc.put("$and", list);
|
||||
LOG.debug("Performing query: {}", queryDoc.toJson());
|
||||
queryRequest.setFilter(queryDoc);
|
||||
|
||||
// QueryRequest queryRequest = new QueryRequest();
|
||||
// Document queryDoc = new Document();
|
||||
// BasicDBObject bs = new BasicDBObject();
|
||||
// bs.append("$eq", hasValue);
|
||||
// queryDoc.put(jsonPath, bs);
|
||||
// LOG.debug("Performing query: {}", queryDoc.toJson());
|
||||
// queryRequest.setFilter(queryDoc);
|
||||
|
||||
Iterator<UseCaseDescriptor> useCaseDescrsIt = client.query(queryRequest);
|
||||
|
||||
if (useCaseDescrsIt != null) {
|
||||
while (useCaseDescrsIt.hasNext()) {
|
||||
UseCaseDescriptor prg = (UseCaseDescriptor) useCaseDescrsIt.next();
|
||||
listUCD.add(prg);
|
||||
|
||||
}
|
||||
}
|
||||
LOG.info("getListForJSONPath returning {} {}", listUCD.size(), UseCaseDescriptor.class.getName());
|
||||
return listUCD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the UCD for id.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @return the UCD for id
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public UseCaseDescriptor getUCDForId(String profileID) throws Exception {
|
||||
LOG.info("getUCDForId called for profileID: {}", profileID);
|
||||
UseCaseDescriptorsI client = useCaseDescriptorsClient();
|
||||
|
||||
QueryRequest queryRequest = new QueryRequest();
|
||||
Document queryDoc = new Document();
|
||||
BasicDBObject bs = new BasicDBObject();
|
||||
bs.append("$eq", profileID);
|
||||
queryDoc.put("_id", bs);
|
||||
LOG.debug("Performing query: {}", queryDoc.toJson());
|
||||
queryRequest.setFilter(queryDoc);
|
||||
|
||||
Iterator<UseCaseDescriptor> useCaseDescrs = client.query(queryRequest);
|
||||
|
||||
UseCaseDescriptor ucd = null;
|
||||
|
||||
if (useCaseDescrs.hasNext()) {
|
||||
ucd = useCaseDescrs.next();
|
||||
}
|
||||
|
||||
LOG.info("for profileID: {}, returning: {}", profileID, ucd);
|
||||
return ucd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the handlers by type.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param theHandlerType the the handler type
|
||||
* @return the handlers by type
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public List<HandlerDeclaration> getHandlersByType(String profileID, String theHandlerType) throws Exception {
|
||||
LOG.info("getHandlersByType called for profileID: {}", profileID);
|
||||
UseCaseDescriptorsI client = useCaseDescriptorsClient();
|
||||
UseCaseDescriptor ucd = client.getById(profileID);
|
||||
return ucd.getHandlersByType(theHandlerType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the relationship definitions.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @return the relationship definitions
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public List<RelationshipDefinition> getRelationshipDefinitions(String profileID) throws Exception {
|
||||
LOG.info("getRelationshipNames called for profileID: {}", profileID);
|
||||
UseCaseDescriptorsI client = useCaseDescriptorsClient();
|
||||
UseCaseDescriptor ucd = client.getById(profileID);
|
||||
|
||||
return ucd.getRelationshipDefinitions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read temporal dimension template.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @return the document
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public Document readTemporalDimensionTemplate(String profileID) throws Exception {
|
||||
|
||||
UseCaseDescriptorsI client = useCaseDescriptorsClient();
|
||||
UseCaseDescriptor ucd = client.getById(profileID);
|
||||
|
||||
List<HandlerDeclaration> timelineHandlers = ucd
|
||||
.getHandlersByType(GEOPORTAL_DATA_HANDLER.geoportal_timeline_json_template.getType());
|
||||
|
||||
if (timelineHandlers != null && timelineHandlers.size() > 0) {
|
||||
HandlerDeclaration handler = timelineHandlers.get(0); // only one expected
|
||||
Document config = handler.getConfiguration();
|
||||
try {
|
||||
LinkedHashMap<String, Object> tjtDoc = (LinkedHashMap<String, Object>) config
|
||||
.get(TIMELINE_CONFIG_TJT_DOCUMENT);
|
||||
return new Document(tjtDoc);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Error on reading the handler type "
|
||||
+ GEOPORTAL_DATA_HANDLER.geoportal_timeline_json_template.getType() + " in the profileID: "
|
||||
+ profileID, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package org.gcube.application.geoportalcommon.geoportal.access;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The Class GeportalCheckAccessPolicy.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Oct 7, 2022
|
||||
*/
|
||||
public class GeportalCheckAccessPolicy {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GeportalCheckAccessPolicy.class);
|
||||
|
||||
/**
|
||||
* The Enum ACCESS_POLICY.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Sep 8, 2021
|
||||
*/
|
||||
public static enum ACCESS_POLICY {
|
||||
OPEN, RESTICTED
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is open access.
|
||||
*
|
||||
* @param policy the policy
|
||||
* @return true, if is open access
|
||||
*/
|
||||
private static boolean isOpenAccess(String policy) {
|
||||
if (policy == null || policy.equalsIgnoreCase(ACCESS_POLICY.OPEN.name())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is restricted access.
|
||||
*
|
||||
* @param policy the policy
|
||||
* @return true, if is restricted access
|
||||
*/
|
||||
private static boolean isRestrictedAccess(String policy) {
|
||||
if (policy == null || policy.equalsIgnoreCase(ACCESS_POLICY.RESTICTED.name())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is accessible according to access policies.
|
||||
*
|
||||
* @param policy the policy
|
||||
* @param myLogin the my login
|
||||
* @return true, if is accessible
|
||||
*/
|
||||
public static boolean isAccessible(String policy, String myLogin) {
|
||||
|
||||
boolean bool = isOpenAccess(policy);
|
||||
|
||||
if (bool) {
|
||||
// is open access
|
||||
return true;
|
||||
}
|
||||
|
||||
// From here managing is NOT OPEN access
|
||||
|
||||
if (myLogin == null || myLogin.isEmpty()) {
|
||||
// here is not open and the user is not authenticated
|
||||
return false;
|
||||
}
|
||||
|
||||
// Here the login is not null, so checking if the access to item is RESTICTED
|
||||
bool = isRestrictedAccess(policy);
|
||||
|
||||
if (bool) {
|
||||
// is restricted access
|
||||
return true;
|
||||
}
|
||||
|
||||
// Here the user is authenticated, but the policy is not managed, so returning
|
||||
// true
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Access policy from session login.
|
||||
*
|
||||
* @param mySessionLogin the my session login
|
||||
* @return the access policy
|
||||
*/
|
||||
public static ACCESS_POLICY accessPolicyFromSessionLogin(String mySessionLogin) {
|
||||
|
||||
if (mySessionLogin == null || mySessionLogin.isEmpty()) {
|
||||
// here is not open and the user is not authenticated
|
||||
return ACCESS_POLICY.OPEN;
|
||||
}
|
||||
|
||||
return ACCESS_POLICY.RESTICTED;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package org.gcube.application.geoportalcommon.geoportal.config;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Data
|
||||
@XmlRootElement(name = "actionsDefinition")
|
||||
@Slf4j
|
||||
public class ActionDefinition {
|
||||
|
||||
@JsonProperty
|
||||
private String id;
|
||||
@JsonProperty
|
||||
private String title;
|
||||
@JsonProperty
|
||||
private String[] call_STEPS;
|
||||
@JsonProperty
|
||||
private String description;
|
||||
@JsonProperty
|
||||
private String[] display_on_phase;
|
||||
@JsonProperty
|
||||
private boolean searchable;
|
||||
|
||||
private String configID;
|
||||
|
||||
public ActionDefinition() {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package org.gcube.application.geoportalcommon.geoportal.config;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Data
|
||||
@XmlRootElement(name = "filePaths")
|
||||
@Slf4j
|
||||
public class FilePath {
|
||||
|
||||
@JsonProperty
|
||||
String gcubeProfileFieldName;
|
||||
@JsonProperty
|
||||
String fieldDefinition;
|
||||
@JsonProperty
|
||||
String fieldName;
|
||||
|
||||
public FilePath() {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package org.gcube.application.geoportalcommon.geoportal.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Data
|
||||
@XmlRootElement(name = "gcubeProfiles")
|
||||
@Slf4j
|
||||
public class GcubeProfile {
|
||||
|
||||
private static final String FILE_PATHS = "filePaths";
|
||||
|
||||
public static final int MIN_MAX_NOT_SPECIFIED = -1;
|
||||
|
||||
@JsonProperty
|
||||
private String gcubeSecondaryType;
|
||||
|
||||
@JsonProperty
|
||||
private String gcubeName;
|
||||
|
||||
@JsonProperty
|
||||
private String parentName;
|
||||
|
||||
@JsonProperty
|
||||
private String sectionName;
|
||||
|
||||
@JsonProperty
|
||||
private String sectionTitle;
|
||||
|
||||
/**
|
||||
* 0: Not specified means Not Mandatory. The Gcube Profile is not mandatory and means that all its fields must be optional in the gCube Meta Profile.
|
||||
* N: is the MIN number of Occurrences
|
||||
* Default is 1 occurrence
|
||||
*/
|
||||
@JsonProperty
|
||||
private int minOccurs = 1;
|
||||
|
||||
/**
|
||||
* 0: Not specified means max number of Occurrences is arbitrary.
|
||||
* N: is the MAX number of Occurrences
|
||||
*/
|
||||
@JsonProperty
|
||||
private int maxOccurs = 1;
|
||||
|
||||
@JsonProperty(FILE_PATHS)
|
||||
private List<FilePath> filePaths;
|
||||
|
||||
public GcubeProfile() {}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package org.gcube.application.geoportalcommon.geoportal.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Data
|
||||
@XmlRootElement(name = "itemFields")
|
||||
@Slf4j
|
||||
public class ItemField {
|
||||
|
||||
@JsonProperty
|
||||
private String label;
|
||||
@JsonProperty
|
||||
private List<String> paths;
|
||||
@JsonProperty
|
||||
private String operator;
|
||||
@JsonProperty
|
||||
private boolean searchable;
|
||||
@JsonProperty
|
||||
private boolean sortable;
|
||||
@JsonProperty
|
||||
private boolean asResult;
|
||||
|
||||
public ItemField() {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package org.gcube.application.geoportalcommon.geoportal.serdes;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@XmlRootElement(name = "_payloads")
|
||||
@Slf4j
|
||||
public class Payload implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3975356671779455705L;
|
||||
|
||||
@JsonProperty("_mimetype")
|
||||
private String mimetype;
|
||||
|
||||
@JsonProperty("_storageID")
|
||||
private String storageID;
|
||||
|
||||
@JsonProperty("_link")
|
||||
private String link;
|
||||
|
||||
@JsonProperty("_name")
|
||||
private String name;
|
||||
|
||||
public Payload() {
|
||||
|
||||
}
|
||||
|
||||
public String getMimetype() {
|
||||
return mimetype;
|
||||
}
|
||||
|
||||
public String getStorageID() {
|
||||
return storageID;
|
||||
}
|
||||
|
||||
public String getLink() {
|
||||
return link;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setMimetype(String mimetype) {
|
||||
this.mimetype = mimetype;
|
||||
}
|
||||
|
||||
public void setStorageID(String storageID) {
|
||||
this.storageID = storageID;
|
||||
}
|
||||
|
||||
public void setLink(String link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Payload [mimetype=");
|
||||
builder.append(mimetype);
|
||||
builder.append(", storageID=");
|
||||
builder.append(storageID);
|
||||
builder.append(", link=");
|
||||
builder.append(link);
|
||||
builder.append(", name=");
|
||||
builder.append(name);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package org.gcube.application.geoportalcommon.geoportal.util;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.BBOXDV;
|
||||
import org.json.JSONArray;
|
||||
|
||||
public class GisUtil {
|
||||
|
||||
public static BBOXDV fromJSONArray(JSONArray outerArray) {
|
||||
|
||||
try {
|
||||
if (outerArray == null)
|
||||
return new BBOXDV();
|
||||
|
||||
double[] coords = new double[outerArray.length()];
|
||||
|
||||
for (int i = 0; i < outerArray.length(); i++) {
|
||||
coords[i] = outerArray.getDouble(i);
|
||||
}
|
||||
|
||||
return BBOXDV.fromGeoJSON(coords);
|
||||
} catch (Exception e) {
|
||||
return new BBOXDV();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package org.gcube.application.geoportalcommon.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.config.RoleRights;
|
||||
import org.gcube.application.geoportalcommon.shared.guipresentation.DataEntryGUIPresentationConfig;
|
||||
|
||||
/**
|
||||
* The Class GNADataEntryConfigProfile.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 21, 2021
|
||||
*/
|
||||
public class GNADataEntryConfigProfile implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 5152380669677928785L;
|
||||
private List<RoleRights> permissionsForRole;
|
||||
private DataEntryGUIPresentationConfig dataEntryGUIPresentation;
|
||||
|
||||
/**
|
||||
* Instantiates a new GNA data entry config profile.
|
||||
*/
|
||||
public GNADataEntryConfigProfile() {
|
||||
|
||||
}
|
||||
|
||||
public GNADataEntryConfigProfile(List<RoleRights> permissionsForRole,
|
||||
DataEntryGUIPresentationConfig dataEntryGUIPresentation) {
|
||||
this.permissionsForRole = permissionsForRole;
|
||||
this.dataEntryGUIPresentation = dataEntryGUIPresentation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data entry GUI presentation.
|
||||
*
|
||||
* @return the data entry GUI presentation
|
||||
*/
|
||||
public DataEntryGUIPresentationConfig getDataEntryGUIPresentation() {
|
||||
return dataEntryGUIPresentation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data entry GUI presentation.
|
||||
*
|
||||
* @param dataEntryGUIPresentation the new data entry GUI presentation
|
||||
*/
|
||||
public void setDataEntryGUIPresentation(DataEntryGUIPresentationConfig dataEntryGUIPresentation) {
|
||||
this.dataEntryGUIPresentation = dataEntryGUIPresentation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the permissions for role.
|
||||
*
|
||||
* @return the permissions for role
|
||||
*/
|
||||
public List<RoleRights> getPermissionsForRole() {
|
||||
return permissionsForRole;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the permissions for role.
|
||||
*
|
||||
* @param permissionsForRole the new permissions for role
|
||||
*/
|
||||
public void setPermissionsForRole(List<RoleRights> permissionsForRole) {
|
||||
this.permissionsForRole = permissionsForRole;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GNADataEntryConfigProfile [permissionsForRole=");
|
||||
builder.append(permissionsForRole);
|
||||
builder.append(", dataEntryGUIPresentation=");
|
||||
builder.append(dataEntryGUIPresentation);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,17 +1,15 @@
|
|||
package org.gcube.application.geoportalcommon.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* The Class GeoNaDataViewerProfile.
|
||||
* The Class GNADataViewerConfigProfile.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 13, 2020
|
||||
* Dec 21, 2021
|
||||
*/
|
||||
public class GeoNaDataViewerProfile implements Serializable{
|
||||
public class GNADataViewerConfigProfile implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -19,13 +17,11 @@ public class GeoNaDataViewerProfile implements Serializable{
|
|||
private static final long serialVersionUID = 2968334957258327191L;
|
||||
private String restrictedPortletURL;
|
||||
private String openPortletURL;
|
||||
//the key is the layer type
|
||||
private Map<String, LayerItem> mapLayers;
|
||||
|
||||
/**
|
||||
* Instantiates a new geo na data viewer profile.
|
||||
*/
|
||||
public GeoNaDataViewerProfile() {
|
||||
public GNADataViewerConfigProfile() {
|
||||
|
||||
}
|
||||
|
||||
|
@ -65,41 +61,15 @@ public class GeoNaDataViewerProfile implements Serializable{
|
|||
this.openPortletURL = openPortletURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the map layers.
|
||||
*
|
||||
* @return the map layers
|
||||
*/
|
||||
public Map<String, LayerItem> getMapLayers() {
|
||||
return mapLayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the map layers.
|
||||
*
|
||||
* @param mapLayers the map layers
|
||||
*/
|
||||
public void setMapLayers(Map<String, LayerItem> mapLayers) {
|
||||
this.mapLayers = mapLayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GeoNaDataViewerProfile [restrictedPortletURL=");
|
||||
builder.append("GNADataViewerConfigProfile [restrictedPortletURL=");
|
||||
builder.append(restrictedPortletURL);
|
||||
builder.append(", openPortletURL=");
|
||||
builder.append(openPortletURL);
|
||||
builder.append(", mapLayers=");
|
||||
builder.append(mapLayers);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -2,81 +2,88 @@ package org.gcube.application.geoportalcommon.shared;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* The Class GeoNaItemRef.
|
||||
* The Class GeoportalItemReferences.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 1, 2020
|
||||
* Oct 18, 2022
|
||||
*/
|
||||
public class GeoNaItemRef implements Serializable {
|
||||
public class GeoportalItemReferences implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7021431511279022193L;
|
||||
|
||||
private Long itemId;
|
||||
private String itemType;
|
||||
// this is the mongoID
|
||||
private String projectID;
|
||||
private String profileID; // this is the profileID - UCD
|
||||
private String itemName;
|
||||
|
||||
private PublicLink restrictedLink;
|
||||
private PublicLink openLink;
|
||||
|
||||
private String layerObjectType;
|
||||
|
||||
/**
|
||||
* Instantiates a new geo na object.
|
||||
*/
|
||||
public GeoNaItemRef() {
|
||||
public GeoportalItemReferences() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new geo na object.
|
||||
* Instantiates a new geo na item ref.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @param itemType the item type
|
||||
* @param projectID the project ID
|
||||
* @param profileID the profile ID
|
||||
*/
|
||||
public GeoNaItemRef(Long itemId, String itemType) {
|
||||
public GeoportalItemReferences(String projectID, String profileID) {
|
||||
super();
|
||||
this.itemId = itemId;
|
||||
this.itemType = itemType;
|
||||
this.projectID = projectID;
|
||||
this.profileID = profileID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item id.
|
||||
* Instantiates a new geo na item ref.
|
||||
*
|
||||
* @return the item id
|
||||
* @param projectID the project ID
|
||||
* @param profileID the profile ID
|
||||
* @param layerObjectType the layer object type
|
||||
*/
|
||||
public Long getItemId() {
|
||||
return itemId;
|
||||
public GeoportalItemReferences(String projectID, String profileID, String layerObjectType) {
|
||||
super();
|
||||
this.projectID = projectID;
|
||||
this.profileID = profileID;
|
||||
this.layerObjectType = layerObjectType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the item id.
|
||||
* Gets the profile ID.
|
||||
*
|
||||
* @param itemId the new item id
|
||||
* @return the profile ID
|
||||
*/
|
||||
public void setItemId(Long itemId) {
|
||||
this.itemId = itemId;
|
||||
public String getProfileID() {
|
||||
return profileID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item type.
|
||||
* Gets the project ID.
|
||||
*
|
||||
* @return the item type
|
||||
* @return the project ID
|
||||
*/
|
||||
public String getItemType() {
|
||||
return itemType;
|
||||
public String getProjectID() {
|
||||
return projectID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the item type.
|
||||
* Gets the layer object type.
|
||||
*
|
||||
* @param itemType the new item type
|
||||
* @return the layer object type
|
||||
*/
|
||||
public void setItemType(String itemType) {
|
||||
this.itemType = itemType;
|
||||
public String getLayerObjectType() {
|
||||
return layerObjectType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,8 +103,6 @@ public class GeoNaItemRef implements Serializable {
|
|||
public void setItemName(String itemName) {
|
||||
this.itemName = itemName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the restricted link.
|
||||
|
@ -143,20 +148,20 @@ public class GeoNaItemRef implements Serializable {
|
|||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GeoNaItemRef [itemId=");
|
||||
builder.append(itemId);
|
||||
builder.append(", itemType=");
|
||||
builder.append(itemType);
|
||||
builder.append("GeoportalItemReferences [projectID=");
|
||||
builder.append(projectID);
|
||||
builder.append(", profileID=");
|
||||
builder.append(profileID);
|
||||
builder.append(", itemName=");
|
||||
builder.append(itemName);
|
||||
builder.append(", restrictedLink=");
|
||||
builder.append(restrictedLink);
|
||||
builder.append(", openLink=");
|
||||
builder.append(openLink);
|
||||
builder.append(", layerObjectType=");
|
||||
builder.append(layerObjectType);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,185 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.application.geoportalcommon.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
|
||||
|
||||
/**
|
||||
* The Class ResultSetPaginatedData.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Aug 6, 2021
|
||||
*/
|
||||
public class ResultSetPaginatedData implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6800997954077785719L;
|
||||
private List<? extends DocumentDV> data;
|
||||
private int offset = 0;
|
||||
private int limit;
|
||||
private boolean isServerSearchFinished = false;
|
||||
private long totalItems;
|
||||
|
||||
/**
|
||||
* Instantiates a new searched folder.
|
||||
*/
|
||||
public ResultSetPaginatedData() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new result set paginated data.
|
||||
*
|
||||
* @param offset the offset
|
||||
* @param limit the limit
|
||||
* @param isServerSearchFinished the is server search finished
|
||||
*/
|
||||
public ResultSetPaginatedData(int offset, int limit, boolean isServerSearchFinished) {
|
||||
|
||||
this.offset = offset;
|
||||
this.limit = limit;
|
||||
this.isServerSearchFinished = isServerSearchFinished;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data.
|
||||
*
|
||||
* @return the data
|
||||
*/
|
||||
public List<? extends DocumentDV> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the client start index.
|
||||
*
|
||||
* @return the client start index
|
||||
*/
|
||||
public int getClientStartIndex() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the limit.
|
||||
*
|
||||
* @return the limit
|
||||
*/
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is server search finished.
|
||||
*
|
||||
* @return true, if is server search finished
|
||||
*/
|
||||
public boolean isServerSearchFinished() {
|
||||
return isServerSearchFinished;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data.
|
||||
*
|
||||
* @param data the new data
|
||||
*/
|
||||
public void setData(List<ResultDocumentDV> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the client start index.
|
||||
*
|
||||
* @param clientStartIndex the new client start index
|
||||
*/
|
||||
public void setClientStartIndex(int clientStartIndex) {
|
||||
this.offset = clientStartIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the limit.
|
||||
*
|
||||
* @param limit the new limit
|
||||
*/
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the server search finished.
|
||||
*
|
||||
* @param isServerSearchFinished the new server search finished
|
||||
*/
|
||||
public void setServerSearchFinished(boolean isServerSearchFinished) {
|
||||
this.isServerSearchFinished = isServerSearchFinished;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total items.
|
||||
*
|
||||
* @return the total items
|
||||
*/
|
||||
public long getTotalItems() {
|
||||
return totalItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the total items.
|
||||
*
|
||||
* @param totalItems the new total items
|
||||
*/
|
||||
public void setTotalItems(long totalItems) {
|
||||
this.totalItems = totalItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the serialversionuid.
|
||||
*
|
||||
* @return the serialversionuid
|
||||
*/
|
||||
public static long getSerialversionuid() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the offset.
|
||||
*
|
||||
* @return the offset
|
||||
*/
|
||||
public int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the offset.
|
||||
*
|
||||
* @param offset the new offset
|
||||
*/
|
||||
public void setOffset(int offset) {
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ResultSetPaginatedData [data=");
|
||||
builder.append(data);
|
||||
builder.append(", offset=");
|
||||
builder.append(offset);
|
||||
builder.append(", limit=");
|
||||
builder.append(limit);
|
||||
builder.append(", isServerSearchFinished=");
|
||||
builder.append(isServerSearchFinished);
|
||||
builder.append(", totalItems=");
|
||||
builder.append(totalItems);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,207 @@
|
|||
package org.gcube.application.geoportalcommon.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
||||
|
||||
/**
|
||||
* The Class SearchingFilter.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 30, 2021
|
||||
*/
|
||||
public class SearchingFilter implements Serializable {
|
||||
|
||||
/**
|
||||
* The Enum ORDER.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 30, 2021
|
||||
*/
|
||||
public static enum ORDER {
|
||||
ASC("ASCENDING"), DESC("DESCENDING");
|
||||
|
||||
String label;
|
||||
|
||||
/**
|
||||
* Instantiates a new order.
|
||||
*
|
||||
* @param label the label
|
||||
*/
|
||||
ORDER(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the label.
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Enum LOGICAL_OP.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 15, 2021
|
||||
*/
|
||||
public static enum LOGICAL_OP {
|
||||
AND("$and"), OR("$or");
|
||||
|
||||
String operator;
|
||||
|
||||
/**
|
||||
* Instantiates a new order.
|
||||
*
|
||||
* @param operator the operator
|
||||
*/
|
||||
LOGICAL_OP(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the operator.
|
||||
*
|
||||
* @return the operator
|
||||
*/
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4004094263090373626L;
|
||||
|
||||
private List<ItemFieldDV> orderByFields;
|
||||
|
||||
private ORDER order = ORDER.ASC;
|
||||
|
||||
private List<WhereClause> conditions;
|
||||
|
||||
private LinkedHashMap<String, Object> projection;
|
||||
|
||||
/**
|
||||
* Instantiates a new sort filter.
|
||||
*/
|
||||
public SearchingFilter() {
|
||||
|
||||
}
|
||||
|
||||
private void addProjectionBaseInfo() {
|
||||
|
||||
if (projection != null) {
|
||||
projection.put("_profileID", 1);
|
||||
projection.put("_profileVersion", 1);
|
||||
projection.put("_version", 1);
|
||||
projection.put("_lifecycleInformation", 1);
|
||||
projection.put("_info", 1);
|
||||
projection.put("_relationships", 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new sort filter.
|
||||
*
|
||||
* @param orderByFields the order by fields
|
||||
* @param order the order
|
||||
*/
|
||||
public SearchingFilter(List<ItemFieldDV> orderByFields, ORDER order) {
|
||||
this.orderByFields = orderByFields;
|
||||
this.order = order;
|
||||
if (this.order == null)
|
||||
order = ORDER.ASC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new sort filter.
|
||||
*
|
||||
* @param orderByFields the order by fields
|
||||
* @param order the order
|
||||
* @param searchInto the search into
|
||||
*/
|
||||
public SearchingFilter(List<ItemFieldDV> orderByFields, ORDER order, List<WhereClause> conditions) {
|
||||
this.orderByFields = orderByFields;
|
||||
this.order = order;
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
public List<WhereClause> getConditions() {
|
||||
return conditions;
|
||||
}
|
||||
|
||||
public void setConditions(List<WhereClause> conditions) {
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
public void setProjection(LinkedHashMap<String, Object> projection) {
|
||||
this.projection = projection;
|
||||
addProjectionBaseInfo();
|
||||
}
|
||||
|
||||
public LinkedHashMap<String, Object> getProjection() {
|
||||
return projection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the order by fields.
|
||||
*
|
||||
* @return the order by fields
|
||||
*/
|
||||
public List<ItemFieldDV> getOrderByFields() {
|
||||
return orderByFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the order.
|
||||
*
|
||||
* @return the order
|
||||
*/
|
||||
public ORDER getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the order by fields.
|
||||
*
|
||||
* @param orderByFields the new order by fields
|
||||
*/
|
||||
public void setOrderByFields(List<ItemFieldDV> orderByFields) {
|
||||
this.orderByFields = orderByFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the order.
|
||||
*
|
||||
* @param order the new order
|
||||
*/
|
||||
public void setOrder(ORDER order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SearchingFilter [orderByFields=");
|
||||
builder.append(orderByFields);
|
||||
builder.append(", order=");
|
||||
builder.append(order);
|
||||
builder.append(", conditions=");
|
||||
builder.append(conditions);
|
||||
builder.append(", projection=");
|
||||
builder.append(projection);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package org.gcube.application.geoportalcommon.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
||||
|
||||
/**
|
||||
* The Class WhereClause.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 15, 2021
|
||||
*/
|
||||
public class WhereClause implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8577885822669878296L;
|
||||
|
||||
private LOGICAL_OP operator = LOGICAL_OP.OR;
|
||||
|
||||
private Map<String, Object> searchInto;
|
||||
|
||||
/**
|
||||
* Instantiates a new where clause.
|
||||
*/
|
||||
public WhereClause() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new where clause.
|
||||
*
|
||||
* @param operator the operator
|
||||
* @param searchInto the search into
|
||||
*/
|
||||
public WhereClause(LOGICAL_OP operator, Map<String, Object> searchInto) {
|
||||
super();
|
||||
this.operator = operator;
|
||||
this.searchInto = searchInto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the operator.
|
||||
*
|
||||
* @return the operator
|
||||
*/
|
||||
public LOGICAL_OP getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the search into.
|
||||
*
|
||||
* @return the search into
|
||||
*/
|
||||
public Map<String, Object> getSearchInto() {
|
||||
return searchInto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the operator.
|
||||
*
|
||||
* @param operator the new operator
|
||||
*/
|
||||
public void setOperator(LOGICAL_OP operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the search into.
|
||||
*
|
||||
* @param searchInto the search into
|
||||
*/
|
||||
public void setSearchInto(Map<String, Object> searchInto) {
|
||||
this.searchInto = searchInto;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("WhereClause [operator=");
|
||||
builder.append(operator);
|
||||
builder.append(", searchInto=");
|
||||
builder.append(searchInto);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package org.gcube.application.geoportalcommon.shared.config;
|
||||
|
||||
/**
|
||||
* The Enum GcubeUserRole.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 25, 2021
|
||||
*/
|
||||
public enum GcubeUserRole {
|
||||
|
||||
DATA_MEMBER("Data-Member", false, false),
|
||||
DATA_EDITOR("Data-Editor", true, false),
|
||||
DATA_MANAGER("Data-Manager", true, true);
|
||||
|
||||
private String name;
|
||||
private boolean writeOwn;
|
||||
private boolean writeAny;
|
||||
|
||||
/**
|
||||
* Instantiates a new gcube user role.
|
||||
*
|
||||
* @param name the name
|
||||
*/
|
||||
private GcubeUserRole(String name, boolean writeOwn, boolean writeAny) {
|
||||
this.name = name;
|
||||
this.writeOwn = writeOwn;
|
||||
this.writeAny = writeAny;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isWriteOwn() {
|
||||
return writeOwn;
|
||||
}
|
||||
|
||||
public boolean isWriteAny() {
|
||||
return writeAny;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setWriteOwn(boolean writeOwn) {
|
||||
this.writeOwn = writeOwn;
|
||||
}
|
||||
|
||||
public void setWriteAny(boolean writeAny) {
|
||||
this.writeAny = writeAny;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package org.gcube.application.geoportalcommon.shared.config;
|
||||
|
||||
|
||||
/**
|
||||
* The Enum OPERATION_ON_ITEM.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Sep 13, 2022
|
||||
*/
|
||||
public enum OPERATION_ON_ITEM {
|
||||
|
||||
CREATE_NEW_PROJECT("Create New Project"),
|
||||
VIEW_PROJECT_AS_DOCUMENT("View Project as Document"),
|
||||
VIEW_PROJECT_AS_JSON("View Projet as JSON"),
|
||||
VIEW_ON_MAP("View on Map"),
|
||||
VIEW_REPORT("View the Report"),
|
||||
EDIT_PROJECT("Edit the Project"),
|
||||
CLONE_PROJECT("Clone the Project"),
|
||||
PUBLISH_UNPUBLISH_PROJECT("Publish/UnPublish the Project"),
|
||||
DELETE_PROJECT("Delete the Project"),
|
||||
CREATE_RELATION("Create Relation between two Projects"),
|
||||
DELETE_RELATION("Delete Relation between two Projects"),
|
||||
VIEW_RELATIONSHIPS("View the relationship/s created for the Project");
|
||||
|
||||
String label;
|
||||
|
||||
/**
|
||||
* Instantiates a new operation on item.
|
||||
*
|
||||
* @param label the label
|
||||
*/
|
||||
OPERATION_ON_ITEM(String label){
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the label.
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package org.gcube.application.geoportalcommon.shared.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The Class RoleRights.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 26, 2021
|
||||
*/
|
||||
public class RoleRights implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -304157165851633221L;
|
||||
|
||||
/**
|
||||
* The Enum OPERATION_TYPE.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 26, 2021
|
||||
*/
|
||||
public static enum OPERATION_TYPE {
|
||||
READ, WRITE, READ_WRITE, UNKNOWN
|
||||
}
|
||||
|
||||
private Map<OPERATION_ON_ITEM, OPERATION_TYPE> listPermessions;
|
||||
private GcubeUserRole userRole;
|
||||
|
||||
/**
|
||||
* Instantiates a new user rights.
|
||||
*/
|
||||
public RoleRights() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new role rights.
|
||||
*
|
||||
* @param myUsername the my username
|
||||
* @param listPermessions the list permessions
|
||||
* @param userRole the user role
|
||||
*/
|
||||
public RoleRights(Map<OPERATION_ON_ITEM, OPERATION_TYPE> listPermessions, GcubeUserRole userRole) {
|
||||
this.listPermessions = listPermessions;
|
||||
this.userRole = userRole;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list permessions.
|
||||
*
|
||||
* @return the list permessions
|
||||
*/
|
||||
public Map<OPERATION_ON_ITEM, OPERATION_TYPE> getListPermessions() {
|
||||
return listPermessions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the user role.
|
||||
*
|
||||
* @return the user role
|
||||
*/
|
||||
public GcubeUserRole getUserRole() {
|
||||
return userRole;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list permessions.
|
||||
*
|
||||
* @param listPermessions the list permessions
|
||||
*/
|
||||
public void setListPermessions(Map<OPERATION_ON_ITEM, OPERATION_TYPE> listPermessions) {
|
||||
this.listPermessions = listPermessions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user role.
|
||||
*
|
||||
* @param userRole the new user role
|
||||
*/
|
||||
public void setUserRole(GcubeUserRole userRole) {
|
||||
this.userRole = userRole;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("RoleRights [listPermessions=");
|
||||
builder.append(listPermessions);
|
||||
builder.append(", userRole=");
|
||||
builder.append(userRole);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.application.geoportalcommon.shared.exception;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class GNAConfigException extends Exception {
|
||||
public GNAConfigException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.GeoportalConfigurationID;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_CONFIGURATION_TYPE;
|
||||
|
||||
public class ConfigurationDV<T extends List<? extends GeoportalConfigurationID>> implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4836713840177636940L;
|
||||
|
||||
private T configuration;
|
||||
private GEOPORTAL_CONFIGURATION_TYPE configurationType;
|
||||
|
||||
public ConfigurationDV() {
|
||||
}
|
||||
|
||||
public ConfigurationDV(T configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
public GEOPORTAL_CONFIGURATION_TYPE getConfigurationType() {
|
||||
return configurationType;
|
||||
}
|
||||
|
||||
public void setConfigurationType(GEOPORTAL_CONFIGURATION_TYPE configurationType) {
|
||||
this.configurationType = configurationType;
|
||||
}
|
||||
|
||||
public T getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public void setConfiguration(T config) {
|
||||
this.configuration = config;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ConfigurationDV [configuration=");
|
||||
builder.append(configuration);
|
||||
builder.append(", configurationType=");
|
||||
builder.append(configurationType);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class DocumentDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4978517506036855883L;
|
||||
protected LinkedHashMap<String, Object> documentAsMap;
|
||||
private String documentAsJSON;
|
||||
private ConfigurationDV<?> configuration;
|
||||
|
||||
private String projectID;
|
||||
|
||||
public DocumentDV() {
|
||||
}
|
||||
|
||||
public LinkedHashMap<String, Object> getDocumentAsMap() {
|
||||
return documentAsMap;
|
||||
}
|
||||
|
||||
public Entry<String, Object> getFirstEntryOfMap() {
|
||||
if (documentAsMap != null && documentAsMap.size() >= 1) {
|
||||
return documentAsMap.entrySet().iterator().next();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getProjectID() {
|
||||
return projectID;
|
||||
}
|
||||
|
||||
public void setProjectID(String projectID) {
|
||||
this.projectID = projectID;
|
||||
}
|
||||
|
||||
public String getDocumentAsJSON() {
|
||||
return documentAsJSON;
|
||||
}
|
||||
|
||||
public void setDocumentAsMap(LinkedHashMap<String, Object> documentAsMap) {
|
||||
this.documentAsMap = documentAsMap;
|
||||
}
|
||||
|
||||
public void setDocumentAsJSON(String documentAsJSON) {
|
||||
this.documentAsJSON = documentAsJSON;
|
||||
}
|
||||
|
||||
public ConfigurationDV<?> getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public void setConfiguration(ConfigurationDV<?> configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("DocumentDV [documentAsMap=");
|
||||
builder.append(documentAsMap);
|
||||
builder.append(", documentAsJSON=");
|
||||
builder.append(documentAsJSON);
|
||||
builder.append(", configuration=");
|
||||
builder.append(configuration);
|
||||
builder.append(", projectID=");
|
||||
builder.append(projectID);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.BasicLifecycleInformationDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.PublicationInfoDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
|
||||
|
||||
public class ResultDocumentDV extends DocumentDV implements Serializable {
|
||||
|
||||
private String id;
|
||||
private String profileID;
|
||||
private BasicLifecycleInformationDV lifecycleInfo;
|
||||
private PublicationInfoDV publicationInfoDV;
|
||||
private List<RelationshipDV> listRelationshipDV;
|
||||
|
||||
private GeoJSON spatialReference;
|
||||
|
||||
private WORKFLOW_PHASE worflowPhase; //never used. Just for serialization in GWT
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7209592503036632772L;
|
||||
|
||||
public ResultDocumentDV() {
|
||||
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getProfileID() {
|
||||
return profileID;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setProfileID(String profileID) {
|
||||
this.profileID = profileID;
|
||||
}
|
||||
|
||||
public void addItemToMap(String property, Object value) {
|
||||
|
||||
if (documentAsMap == null)
|
||||
documentAsMap = new LinkedHashMap<String, Object>();
|
||||
|
||||
documentAsMap.put(property, value);
|
||||
}
|
||||
|
||||
public BasicLifecycleInformationDV getLifecycleInfo() {
|
||||
return lifecycleInfo;
|
||||
}
|
||||
|
||||
public void setLifecycleInfo(BasicLifecycleInformationDV lifecycleInfo) {
|
||||
this.lifecycleInfo = lifecycleInfo;
|
||||
}
|
||||
|
||||
public void setListRelationship(List<RelationshipDV> listRelationshipDV) {
|
||||
this.listRelationshipDV = listRelationshipDV;
|
||||
}
|
||||
|
||||
public void setPublicationInfoDV(PublicationInfoDV publicationInfoDV) {
|
||||
this.publicationInfoDV = publicationInfoDV;
|
||||
}
|
||||
|
||||
public void setListRelationshipDV(List<RelationshipDV> listRelationshipDV) {
|
||||
this.listRelationshipDV = listRelationshipDV;
|
||||
}
|
||||
|
||||
public List<RelationshipDV> getListRelationshipDV() {
|
||||
return listRelationshipDV;
|
||||
}
|
||||
|
||||
public void setPublicationInfo(PublicationInfoDV publicationInfoDV) {
|
||||
this.publicationInfoDV = publicationInfoDV;
|
||||
|
||||
}
|
||||
|
||||
public PublicationInfoDV getPublicationInfoDV() {
|
||||
return publicationInfoDV;
|
||||
}
|
||||
|
||||
public GeoJSON getSpatialReference() {
|
||||
return spatialReference;
|
||||
}
|
||||
|
||||
public void setSpatialReference(GeoJSON spatialReference) {
|
||||
this.spatialReference = spatialReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ResultDocumentDV [id=");
|
||||
builder.append(id);
|
||||
builder.append(", profileID=");
|
||||
builder.append(profileID);
|
||||
builder.append(", lifecycleInfo=");
|
||||
builder.append(lifecycleInfo);
|
||||
builder.append(", publicationInfoDV=");
|
||||
builder.append(publicationInfoDV);
|
||||
builder.append(", listRelationshipDV=");
|
||||
builder.append(listRelationshipDV);
|
||||
builder.append(", spatialReference=");
|
||||
builder.append(spatialReference);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal;
|
||||
|
||||
/**
|
||||
* The Enum WORKFLOW_PHASE.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jan 19, 2023
|
||||
*/
|
||||
public enum WORKFLOW_PHASE {
|
||||
|
||||
PUBLISHED("Published"), //Should be always the last one
|
||||
DRAFT("Draft");
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Instantiates a new workflow phase.
|
||||
*
|
||||
* @param label the label
|
||||
*/
|
||||
WORKFLOW_PHASE(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the label.
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ActionDefinitionDV implements GeoportalConfigurationID, Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6071900142588642601L;
|
||||
private String id;
|
||||
private String title;
|
||||
private String[] callSteps;
|
||||
private String description;
|
||||
private String[] displayOnPhase;
|
||||
|
||||
private String configID;
|
||||
|
||||
public Set<String> roles = new HashSet<String>(); //No role/s defined means enable the action by default
|
||||
|
||||
public ActionDefinitionDV() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setID(String configID) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String[] getCallSteps() {
|
||||
return callSteps;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String[] getDisplayOnPhase() {
|
||||
return displayOnPhase;
|
||||
}
|
||||
|
||||
public String getConfigID() {
|
||||
return configID;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void setCallSteps(String[] callSteps) {
|
||||
this.callSteps = callSteps;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setDisplayOnPhase(String[] displayOnPhase) {
|
||||
this.displayOnPhase = displayOnPhase;
|
||||
}
|
||||
|
||||
public void setConfigID(String configID) {
|
||||
this.configID = configID;
|
||||
}
|
||||
|
||||
public Set<String> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(Set<String> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ActionDefinitionDV [id=");
|
||||
builder.append(id);
|
||||
builder.append(", title=");
|
||||
builder.append(title);
|
||||
builder.append(", callSteps=");
|
||||
builder.append(Arrays.toString(callSteps));
|
||||
builder.append(", description=");
|
||||
builder.append(description);
|
||||
builder.append(", displayOnPhase=");
|
||||
builder.append(Arrays.toString(displayOnPhase));
|
||||
builder.append(", configID=");
|
||||
builder.append(configID);
|
||||
builder.append(", roles=");
|
||||
builder.append(roles);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class FilePathDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -9186437393759442989L;
|
||||
|
||||
private String gcubeProfileFieldName;
|
||||
private String fieldName;
|
||||
private String fieldDefinition;
|
||||
|
||||
public FilePathDV() {
|
||||
}
|
||||
|
||||
public String getGcubeProfileFieldName() {
|
||||
return gcubeProfileFieldName;
|
||||
}
|
||||
|
||||
public void setGcubeProfileFieldName(String gcubeProfileFieldName) {
|
||||
this.gcubeProfileFieldName = gcubeProfileFieldName;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
public String getFieldDefinition() {
|
||||
return fieldDefinition;
|
||||
}
|
||||
|
||||
public void setFieldName(String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
|
||||
public void setFieldDefinition(String fieldDefinition) {
|
||||
this.fieldDefinition = fieldDefinition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("FilePathDV [gcubeProfileFieldName=");
|
||||
builder.append(gcubeProfileFieldName);
|
||||
builder.append(", fieldName=");
|
||||
builder.append(fieldName);
|
||||
builder.append(", fieldDefinition=");
|
||||
builder.append(fieldDefinition);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,240 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The Class GcubeProfileDV.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Mar 7, 2022
|
||||
*/
|
||||
public class GcubeProfileDV implements GeoportalConfigurationID, Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6177379075015880565L;
|
||||
|
||||
public static final int MIN_MAX_NOT_SPECIFIED = -1;
|
||||
|
||||
private String configID;
|
||||
|
||||
private String gcubeSecondaryType;
|
||||
private String gcubeName;
|
||||
private String sectionName;
|
||||
private String sectionTitle;
|
||||
private String parentName;
|
||||
|
||||
/**
|
||||
* 0: Not specified means Not Mandatory. The Gcube Profile is not mandatory and
|
||||
* means that all its fields must be optional in the gCube Meta Profile. N: is
|
||||
* the MIN number of Occurrences Default is 1 occurrence
|
||||
*/
|
||||
private int minOccurs = 1;
|
||||
|
||||
/**
|
||||
* 0: Not specified means max number of Occurrences is arbitrary. N: is the MAX
|
||||
* number of Occurrences
|
||||
*/
|
||||
private int maxOccurs = 1;
|
||||
|
||||
private List<FilePathDV> filePaths;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new gcube profile DV.
|
||||
*/
|
||||
public GcubeProfileDV() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return configID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setID(String configID) {
|
||||
this.configID = configID;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the gcube secondary type.
|
||||
*
|
||||
* @return the gcube secondary type
|
||||
*/
|
||||
public String getGcubeSecondaryType() {
|
||||
return gcubeSecondaryType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the gcube name.
|
||||
*
|
||||
* @return the gcube name
|
||||
*/
|
||||
public String getGcubeName() {
|
||||
return gcubeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the section name.
|
||||
*
|
||||
* @return the section name
|
||||
*/
|
||||
public String getSectionName() {
|
||||
return sectionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the section title.
|
||||
*
|
||||
* @return the section title
|
||||
*/
|
||||
public String getSectionTitle() {
|
||||
return sectionTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parent name. If is null or empty return the "" /(empty string) as
|
||||
* default.
|
||||
*
|
||||
* @return the parent name
|
||||
*/
|
||||
public String getParentName() {
|
||||
if (parentName == null)
|
||||
return "";
|
||||
|
||||
return parentName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the min occurs.
|
||||
*
|
||||
* @return the min occurs
|
||||
*/
|
||||
public int getMinOccurs() {
|
||||
return minOccurs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the max occurs.
|
||||
*
|
||||
* @return the max occurs
|
||||
*/
|
||||
public int getMaxOccurs() {
|
||||
return maxOccurs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file paths.
|
||||
*
|
||||
* @return the file paths
|
||||
*/
|
||||
public List<FilePathDV> getFilePaths() {
|
||||
return filePaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the gcube secondary type.
|
||||
*
|
||||
* @param gcubeSecondaryType the new gcube secondary type
|
||||
*/
|
||||
public void setGcubeSecondaryType(String gcubeSecondaryType) {
|
||||
this.gcubeSecondaryType = gcubeSecondaryType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the gcube name.
|
||||
*
|
||||
* @param gcubeName the new gcube name
|
||||
*/
|
||||
public void setGcubeName(String gcubeName) {
|
||||
this.gcubeName = gcubeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the section name.
|
||||
*
|
||||
* @param sectionName the new section name
|
||||
*/
|
||||
public void setSectionName(String sectionName) {
|
||||
this.sectionName = sectionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the section title.
|
||||
*
|
||||
* @param sectionTitle the new section title
|
||||
*/
|
||||
public void setSectionTitle(String sectionTitle) {
|
||||
this.sectionTitle = sectionTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent name.
|
||||
*
|
||||
* @param parentName the new parent name
|
||||
*/
|
||||
public void setParentName(String parentName) {
|
||||
this.parentName = parentName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the min occurs.
|
||||
*
|
||||
* @param minOccurs the new min occurs
|
||||
*/
|
||||
public void setMinOccurs(int minOccurs) {
|
||||
this.minOccurs = minOccurs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the max occurs.
|
||||
*
|
||||
* @param maxOccurs the new max occurs
|
||||
*/
|
||||
public void setMaxOccurs(int maxOccurs) {
|
||||
this.maxOccurs = maxOccurs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file paths.
|
||||
*
|
||||
* @param filePaths the new file paths
|
||||
*/
|
||||
public void setFilePaths(List<FilePathDV> filePaths) {
|
||||
this.filePaths = filePaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GcubeProfileDV [gcubeSecondaryType=");
|
||||
builder.append(gcubeSecondaryType);
|
||||
builder.append(", gcubeName=");
|
||||
builder.append(gcubeName);
|
||||
builder.append(", sectionName=");
|
||||
builder.append(sectionName);
|
||||
builder.append(", sectionTitle=");
|
||||
builder.append(sectionTitle);
|
||||
builder.append(", parentName=");
|
||||
builder.append(parentName);
|
||||
builder.append(", minOccurs=");
|
||||
builder.append(minOccurs);
|
||||
builder.append(", maxOccurs=");
|
||||
builder.append(maxOccurs);
|
||||
builder.append(", filePaths=");
|
||||
builder.append(filePaths);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.config;
|
||||
|
||||
public interface GeoportalConfigurationID {
|
||||
|
||||
String getID();
|
||||
|
||||
void setID(String configID);
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* The Class GroupedLayersDV.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* May 12, 2023
|
||||
*/
|
||||
public class GroupedLayersDV<T extends LayerIDV> implements Serializable, GeoportalConfigurationID {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2021774489849084231L;
|
||||
private String name;
|
||||
private String description;
|
||||
|
||||
@JsonProperty(value = "layers")
|
||||
private List<T> listCustomLayers;
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setID(String configID) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public GroupedLayersDV() {
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public List<T> getListCustomLayers() {
|
||||
return listCustomLayers;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setListCustomLayers(List<T> listCustomLayers) {
|
||||
this.listCustomLayers = listCustomLayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GroupedLayersDV [name=");
|
||||
builder.append(name);
|
||||
builder.append(", description=");
|
||||
builder.append(description);
|
||||
builder.append(", listCustomLayers=");
|
||||
builder.append(listCustomLayers);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,196 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The Class ItemFieldDV.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Mar 16, 2022
|
||||
*/
|
||||
public class ItemFieldDV implements GeoportalConfigurationID, Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1489912649531434470L;
|
||||
private String displayName;
|
||||
private List<String> jsonFields;
|
||||
private String operator;
|
||||
private boolean displayAsResult;
|
||||
private boolean sortable;
|
||||
private boolean searchable;
|
||||
|
||||
private String configID;
|
||||
|
||||
/**
|
||||
* Instantiates a new item field.
|
||||
*/
|
||||
public ItemFieldDV() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new item field DV.
|
||||
*
|
||||
* @param displayName the display name
|
||||
* @param jsonFields the json fields
|
||||
* @param operator the operator
|
||||
* @param displayAsResult the display as result
|
||||
* @param sortable the sortable
|
||||
* @param searchable the searchable
|
||||
*/
|
||||
public ItemFieldDV(String displayName, List<String> jsonFields, String operator, boolean displayAsResult,
|
||||
boolean sortable, boolean searchable) {
|
||||
super();
|
||||
this.displayName = displayName;
|
||||
this.jsonFields = jsonFields;
|
||||
this.operator = operator;
|
||||
this.displayAsResult = displayAsResult;
|
||||
this.sortable = sortable;
|
||||
this.searchable = searchable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return configID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setID(String configID) {
|
||||
this.configID = configID;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display name.
|
||||
*
|
||||
* @return the display name
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the json fields.
|
||||
*
|
||||
* @return the json fields
|
||||
*/
|
||||
public List<String> getJsonFields() {
|
||||
return jsonFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the operator.
|
||||
*
|
||||
* @return the operator
|
||||
*/
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is display as result.
|
||||
*
|
||||
* @return true, if is display as result
|
||||
*/
|
||||
public boolean isDisplayAsResult() {
|
||||
return displayAsResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is sortable.
|
||||
*
|
||||
* @return true, if is sortable
|
||||
*/
|
||||
public boolean isSortable() {
|
||||
return sortable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is searchable.
|
||||
*
|
||||
* @return true, if is searchable
|
||||
*/
|
||||
public boolean isSearchable() {
|
||||
return searchable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display name.
|
||||
*
|
||||
* @param displayName the new display name
|
||||
*/
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the json fields.
|
||||
*
|
||||
* @param jsonFields the new json fields
|
||||
*/
|
||||
public void setJsonFields(List<String> jsonFields) {
|
||||
this.jsonFields = jsonFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the operator.
|
||||
*
|
||||
* @param operator the new operator
|
||||
*/
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display as result.
|
||||
*
|
||||
* @param displayAsResult the new display as result
|
||||
*/
|
||||
public void setDisplayAsResult(boolean displayAsResult) {
|
||||
this.displayAsResult = displayAsResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sortable.
|
||||
*
|
||||
* @param sortable the new sortable
|
||||
*/
|
||||
public void setSortable(boolean sortable) {
|
||||
this.sortable = sortable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the searchable.
|
||||
*
|
||||
* @param searchable the new searchable
|
||||
*/
|
||||
public void setSearchable(boolean searchable) {
|
||||
this.searchable = searchable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ItemFieldDV [displayName=");
|
||||
builder.append(displayName);
|
||||
builder.append(", jsonFields=");
|
||||
builder.append(jsonFields);
|
||||
builder.append(", operator=");
|
||||
builder.append(operator);
|
||||
builder.append(", displayAsResult=");
|
||||
builder.append(displayAsResult);
|
||||
builder.append(", sortable=");
|
||||
builder.append(sortable);
|
||||
builder.append(", searchable=");
|
||||
builder.append(searchable);
|
||||
builder.append(", configID=");
|
||||
builder.append(configID);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.config.layers;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* The Class ConfiguredLayerDV.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* May 12, 2023
|
||||
*/
|
||||
public class ConfiguredLayerDV implements LayerIDV, Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6910607957385140987L;
|
||||
|
||||
private String title;
|
||||
private String description;
|
||||
private String name;
|
||||
private String wms_url;
|
||||
private String wfs_url;
|
||||
boolean display = false;
|
||||
|
||||
public ConfiguredLayerDV() {
|
||||
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getWMS_URL() {
|
||||
return wms_url;
|
||||
}
|
||||
|
||||
public String getWFS_URL() {
|
||||
return wfs_url;
|
||||
}
|
||||
|
||||
public boolean isDisplay() {
|
||||
return display;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setWms_url(String wms_url) {
|
||||
this.wms_url = wms_url;
|
||||
}
|
||||
|
||||
public void setWfs_url(String wfs_url) {
|
||||
this.wfs_url = wfs_url;
|
||||
}
|
||||
|
||||
public void setDisplay(boolean display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ConfiguredLayerDV [title=");
|
||||
builder.append(title);
|
||||
builder.append(", description=");
|
||||
builder.append(description);
|
||||
builder.append(", name=");
|
||||
builder.append(name);
|
||||
builder.append(", wms_url=");
|
||||
builder.append(wms_url);
|
||||
builder.append(", wfs_url=");
|
||||
builder.append(wfs_url);
|
||||
builder.append(", display=");
|
||||
builder.append(display);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.config.layers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CrossFilteringLayerDV extends ConfiguredLayerDV {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1130075528037312939L;
|
||||
String table_show_field;
|
||||
String table_key_field;
|
||||
String table_parent_key_field;
|
||||
String table_geometry_name;
|
||||
List<CrossFilteringLayerDV> related_to;
|
||||
|
||||
public CrossFilteringLayerDV() {
|
||||
|
||||
}
|
||||
|
||||
public String getTable_show_field() {
|
||||
return table_show_field;
|
||||
}
|
||||
|
||||
public String getTable_key_field() {
|
||||
return table_key_field;
|
||||
}
|
||||
|
||||
public String getTable_parent_key_field() {
|
||||
return table_parent_key_field;
|
||||
}
|
||||
|
||||
public String getTable_geometry_name() {
|
||||
return table_geometry_name;
|
||||
}
|
||||
|
||||
public List<CrossFilteringLayerDV> getRelated_to() {
|
||||
return related_to;
|
||||
}
|
||||
|
||||
public void setTable_show_field(String table_show_field) {
|
||||
this.table_show_field = table_show_field;
|
||||
}
|
||||
|
||||
public void setTable_key_field(String table_key_field) {
|
||||
this.table_key_field = table_key_field;
|
||||
}
|
||||
|
||||
public void setTable_parent_key_field(String table_parent_key_field) {
|
||||
this.table_parent_key_field = table_parent_key_field;
|
||||
}
|
||||
|
||||
public void setTable_geometry_name(String table_geometry_name) {
|
||||
this.table_geometry_name = table_geometry_name;
|
||||
}
|
||||
|
||||
public void setRelated_to(List<CrossFilteringLayerDV> related_to) {
|
||||
this.related_to = related_to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CrossFilteringLayerDV [table_show_field=");
|
||||
builder.append(table_show_field);
|
||||
builder.append(", table_key_field=");
|
||||
builder.append(table_key_field);
|
||||
builder.append(", table_parent_key_field=");
|
||||
builder.append(table_parent_key_field);
|
||||
builder.append(", table_geometry_name=");
|
||||
builder.append(table_geometry_name);
|
||||
builder.append(", related_to=");
|
||||
builder.append(related_to);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.config.layers;
|
||||
|
||||
public interface LayerIDV {
|
||||
|
||||
String getName();
|
||||
String getTitle();
|
||||
String getWMS_URL();
|
||||
String getWFS_URL();
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.geojson;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class Crs implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8848168371106854638L;
|
||||
|
||||
public Crs(){
|
||||
|
||||
}
|
||||
|
||||
@JsonProperty
|
||||
private String type;
|
||||
@JsonProperty
|
||||
private Map<String, Object> properties = new HashMap<String, Object>();
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Map<String, Object> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(Map<String, Object> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof Crs)) {
|
||||
return false;
|
||||
}
|
||||
Crs crs = (Crs) o;
|
||||
if (properties != null ? !properties.equals(crs.properties) : crs.properties != null) {
|
||||
return false;
|
||||
}
|
||||
return !(type != null ? !type.equals(crs.type) : crs.type != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = type != null ? type.hashCode() : 0;
|
||||
result = 31 * result + (properties != null ? properties.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Crs{" + "type='" + type + '\'' + ", properties=" + properties + '}';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.geojson;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.BBOXDV;
|
||||
|
||||
public class GeoJSON implements Serializable {
|
||||
|
||||
public static final String TYPE = "type";
|
||||
public static final String BBOX = "bbox";
|
||||
public static final String CRS = "crs";
|
||||
public static final String COORDINATES = "coordinates";
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7798331554142534921L;
|
||||
|
||||
private String type;
|
||||
private Crs crs;
|
||||
private BBOXDV bbox;
|
||||
private String geoJSON;
|
||||
|
||||
public GeoJSON() {
|
||||
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Crs getCrs() {
|
||||
return crs;
|
||||
}
|
||||
|
||||
public BBOXDV getBbox() {
|
||||
return bbox;
|
||||
}
|
||||
|
||||
public String getGeoJSON() {
|
||||
return geoJSON;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setCrs(Crs crs) {
|
||||
this.crs = crs;
|
||||
}
|
||||
|
||||
public void setBbox(BBOXDV bbox) {
|
||||
this.bbox = bbox;
|
||||
}
|
||||
|
||||
public void setGeoJSON(String geoJSON) {
|
||||
this.geoJSON = geoJSON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GeoJSON [type=");
|
||||
builder.append(type);
|
||||
builder.append(", crs=");
|
||||
builder.append(crs);
|
||||
builder.append(", bbox=");
|
||||
builder.append(bbox);
|
||||
builder.append(", geoJSON=");
|
||||
builder.append(geoJSON);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.materialization;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.BBOXDV;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
public class GCubeSDILayer implements Serializable {
|
||||
|
||||
// TODO manage heterogeneus collection
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 5317964084778336268L;
|
||||
@JsonProperty(value = "_type")
|
||||
private String type;
|
||||
@JsonProperty(value = "_platformInfo")
|
||||
private List<GeoServerPlatformInfoDV> platformInfos;
|
||||
@JsonProperty(value = "_bbox")
|
||||
private BBOXDV bbox;
|
||||
@JsonProperty(value = "_ogcLinks")
|
||||
private HashMap<String, String> ogcLinks;
|
||||
|
||||
public GCubeSDILayer() {
|
||||
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public List<GeoServerPlatformInfoDV> getPlatformInfos() {
|
||||
return platformInfos;
|
||||
}
|
||||
|
||||
public BBOXDV getBbox() {
|
||||
return bbox;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getOgcLinks() {
|
||||
return ogcLinks;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setPlatformInfos(List<GeoServerPlatformInfoDV> platformInfos) {
|
||||
this.platformInfos = platformInfos;
|
||||
}
|
||||
|
||||
public void setBbox(BBOXDV bbox) {
|
||||
this.bbox = bbox;
|
||||
}
|
||||
|
||||
public void setOgcLinks(HashMap<String, String> ogcLinks) {
|
||||
this.ogcLinks = ogcLinks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GCubeSDILayer [type=");
|
||||
builder.append(type);
|
||||
builder.append(", platformInfos=");
|
||||
builder.append(platformInfos);
|
||||
builder.append(", bbox=");
|
||||
builder.append(bbox);
|
||||
builder.append(", ogcLinks=");
|
||||
builder.append(ogcLinks);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.materialization;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.BBOXDV;
|
||||
|
||||
public class GCubeSDIViewerLayerDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6620710416056942397L;
|
||||
private String type;
|
||||
private BBOXDV bbox;
|
||||
private HashMap<String, String> ogcLinks;
|
||||
private String layerName;
|
||||
|
||||
public GCubeSDIViewerLayerDV() {
|
||||
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public BBOXDV getBbox() {
|
||||
return bbox;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getOgcLinks() {
|
||||
return ogcLinks;
|
||||
}
|
||||
|
||||
public String getWMSLink() {
|
||||
if (ogcLinks != null) {
|
||||
return ogcLinks.get("wms");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setBbox(BBOXDV bbox) {
|
||||
this.bbox = bbox;
|
||||
}
|
||||
|
||||
public void setOgcLinks(HashMap<String, String> ogcLinks) {
|
||||
this.ogcLinks = ogcLinks;
|
||||
}
|
||||
|
||||
public void setLayerName(String layerName) {
|
||||
this.layerName = layerName;
|
||||
}
|
||||
|
||||
public String getLayerName() {
|
||||
return layerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GCubeSDIViewerLayerDV [type=");
|
||||
builder.append(type);
|
||||
builder.append(", bbox=");
|
||||
builder.append(bbox);
|
||||
builder.append(", ogcLinks=");
|
||||
builder.append(ogcLinks);
|
||||
builder.append(", layerName=");
|
||||
builder.append(layerName);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.materialization;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class GeoServerPlatformInfoDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2630467451758269625L;
|
||||
|
||||
@JsonProperty(value = "_type")
|
||||
private String type;
|
||||
private String workspace;
|
||||
private String storeName;
|
||||
|
||||
@JsonProperty(value = "_host")
|
||||
private String host;
|
||||
|
||||
private Map<String, String> ogcLinks;
|
||||
|
||||
public GeoServerPlatformInfoDV() {
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getWorkspace() {
|
||||
return workspace;
|
||||
}
|
||||
|
||||
public void setWorkspace(String workspace) {
|
||||
this.workspace = workspace;
|
||||
}
|
||||
|
||||
public String getStoreName() {
|
||||
return storeName;
|
||||
}
|
||||
|
||||
public void setStoreName(String storeName) {
|
||||
this.storeName = storeName;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public Map<String, String> getOgcLinks() {
|
||||
return ogcLinks;
|
||||
}
|
||||
|
||||
public void setOgcLinks(Map<String, String> ogcLinks) {
|
||||
this.ogcLinks = ogcLinks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GeoServerPlatformInfoDV [type=");
|
||||
builder.append(type);
|
||||
builder.append(", workspace=");
|
||||
builder.append(workspace);
|
||||
builder.append(", storeName=");
|
||||
builder.append(storeName);
|
||||
builder.append(", host=");
|
||||
builder.append(host);
|
||||
builder.append(", ogcLinks=");
|
||||
builder.append(ogcLinks);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.materialization;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class IndexLayerDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 5352754312327975329L;
|
||||
|
||||
@JsonProperty(value = "_type")
|
||||
private String type;
|
||||
private GCubeSDILayer layer;
|
||||
private String indexName;
|
||||
private int records;
|
||||
private String flag;
|
||||
|
||||
public IndexLayerDV() {
|
||||
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public GCubeSDILayer getLayer() {
|
||||
return layer;
|
||||
}
|
||||
|
||||
public void setLayer(GCubeSDILayer layer) {
|
||||
this.layer = layer;
|
||||
}
|
||||
|
||||
public String getIndexName() {
|
||||
return indexName;
|
||||
}
|
||||
|
||||
public void setIndexName(String indexName) {
|
||||
this.indexName = indexName;
|
||||
}
|
||||
|
||||
public int getRecords() {
|
||||
return records;
|
||||
}
|
||||
|
||||
public void setRecords(int records) {
|
||||
this.records = records;
|
||||
}
|
||||
|
||||
public String getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(String flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("IndexLayerDV [type=");
|
||||
builder.append(type);
|
||||
builder.append(", layer=");
|
||||
builder.append(layer);
|
||||
builder.append(", indexName=");
|
||||
builder.append(indexName);
|
||||
builder.append(", records=");
|
||||
builder.append(records);
|
||||
builder.append(", flag=");
|
||||
builder.append(flag);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,186 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class BBOXDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4438327945612263171L;
|
||||
|
||||
public static final String MAX_X = "_maxX";
|
||||
public static final String MAX_Y = "_maxY";
|
||||
public static final String MAX_Z = "_maxZ";
|
||||
public static final String MIN_X = "_minX";
|
||||
public static final String MIN_Y = "_minY";
|
||||
public static final String MIN_Z = "_minZ";
|
||||
|
||||
public static final BBOXDV WORLD = new BBOXDV(180d, -180d, 90d, -90d);
|
||||
|
||||
public static final BBOXDV WORLD_3D = new BBOXDV(180d, -180d, 90d, -90d);
|
||||
|
||||
private HashMap<String, Double> bbox = new HashMap<String, Double>();
|
||||
|
||||
public BBOXDV() {
|
||||
|
||||
}
|
||||
|
||||
public BBOXDV(Double maxX, Double minX, Double maxY, Double minY) {
|
||||
setMaxX(maxX);
|
||||
setMinX(minX);
|
||||
setMaxY(maxY);
|
||||
setMinY(minY);
|
||||
}
|
||||
|
||||
public BBOXDV(Double maxX, Double minX, Double maxY, Double minY, Double maxZ, Double minZ) {
|
||||
this(maxX, minX, maxY, minY);
|
||||
setMaxZ(maxZ);
|
||||
setMinZ(minZ);
|
||||
}
|
||||
|
||||
public BBOXDV(HashMap<String, Object> hash) {
|
||||
setMaxX(toDouble(hash.get(MAX_X)));
|
||||
setMaxY(toDouble(hash.get(MAX_Y)));
|
||||
setMinX(toDouble(hash.get(MIN_X)));
|
||||
setMinY(toDouble(hash.get(MIN_Y)));
|
||||
|
||||
setMinZ(toDouble(hash.get(MIN_Z)));
|
||||
setMaxZ(toDouble(hash.get(MAX_Z)));
|
||||
}
|
||||
|
||||
private Double toDouble(Object toDouble) {
|
||||
|
||||
try {
|
||||
return new Double((double) toDouble);
|
||||
|
||||
} catch (Exception e) {
|
||||
// System.out.println(toDouble + " is not castable to " +
|
||||
// Double.class.getSimpleName());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static final BBOXDV fromGeoJSON(double[] coords) {
|
||||
BBOXDV toReturn = new BBOXDV();
|
||||
toReturn.setMaxX(coords[0]);
|
||||
toReturn.setMinY(coords[1]);
|
||||
|
||||
if (coords.length == 6) {
|
||||
// 3D
|
||||
toReturn.setMinZ(coords[2]);
|
||||
toReturn.setMinX(coords[3]);
|
||||
toReturn.setMaxY(coords[4]);
|
||||
toReturn.setMaxZ(coords[5]);
|
||||
} else {
|
||||
toReturn.setMinX(coords[2]);
|
||||
toReturn.setMaxY(coords[3]);
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public BBOXDV setMaxX(Double d) {
|
||||
this.bbox.put(MAX_X, d);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BBOXDV setMaxY(Double d) {
|
||||
this.bbox.put(MAX_Y, d);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BBOXDV setMaxZ(Double d) {
|
||||
this.bbox.put(MAX_Z, d);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BBOXDV setMinX(Double d) {
|
||||
this.bbox.put(MIN_X, d);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BBOXDV setMinY(Double d) {
|
||||
this.bbox.put(MIN_Y, d);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BBOXDV setMinZ(Double d) {
|
||||
this.bbox.put(MIN_Z, d);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Double getMinY() {
|
||||
try {
|
||||
return this.bbox.get(MIN_Y);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return new Double(-90d);
|
||||
}
|
||||
|
||||
public Double getMaxY() {
|
||||
try {
|
||||
return this.bbox.get(MAX_Y);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return new Double(90d);
|
||||
}
|
||||
|
||||
public Double getMinX() {
|
||||
try {
|
||||
return this.bbox.get(MIN_X);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return new Double(-180d);
|
||||
}
|
||||
|
||||
public Double getMaxX() {
|
||||
try {
|
||||
return this.bbox.get(MAX_X);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return new Double(180d);
|
||||
}
|
||||
|
||||
public Double getMinZ() {
|
||||
return (Double) this.bbox.getOrDefault(MIN_Z, null);
|
||||
}
|
||||
|
||||
public Double getMaxZ() {
|
||||
return (Double) this.bbox.getOrDefault(MAX_Z, null);
|
||||
}
|
||||
|
||||
public Boolean is3d() {
|
||||
return getMinZ() != null && getMaxZ() != null;
|
||||
}
|
||||
|
||||
public final String asGeoJSONBBox() {
|
||||
StringBuilder builder = new StringBuilder("[");
|
||||
builder.append(getMaxX() + ","); // W
|
||||
builder.append(getMinY() + ","); // S
|
||||
if (is3d())
|
||||
builder.append(getMinZ() + ","); // Z
|
||||
|
||||
builder.append(getMinX() + ","); // E
|
||||
builder.append(getMaxY() + ","); // N
|
||||
if (is3d())
|
||||
builder.append(getMaxZ() + ","); // Z
|
||||
|
||||
builder.deleteCharAt(builder.length());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public double[] asGeoJSONArray() {
|
||||
if (is3d()) {
|
||||
return new double[] { getMaxX(), getMinY(), getMinZ(), getMinX(), getMaxY(), getMaxZ() };
|
||||
} else
|
||||
return new double[] { getMaxX(), getMinY(), getMinX(), getMaxY() };
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FilesetDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3108729581669778828L;
|
||||
private String gcubeProfileFieldName; // It is the gcubeProfileFieldName in the UCD filePaths
|
||||
private String filesetFieldName; // It is the fieldName in the UCD filePaths
|
||||
private List<PayloadDV> listPayloads = new ArrayList<PayloadDV>();
|
||||
|
||||
public FilesetDV() {
|
||||
|
||||
}
|
||||
|
||||
public String getFilesetFieldName() {
|
||||
return filesetFieldName;
|
||||
}
|
||||
|
||||
public void setFilesetFieldName(String filesetFieldName) {
|
||||
this.filesetFieldName = filesetFieldName;
|
||||
}
|
||||
|
||||
public String getGcubeProfileFieldName() {
|
||||
return gcubeProfileFieldName;
|
||||
}
|
||||
|
||||
public void setGcubeProfileFieldName(String name) {
|
||||
this.gcubeProfileFieldName = name;
|
||||
}
|
||||
|
||||
public List<PayloadDV> getListPayload() {
|
||||
return listPayloads;
|
||||
}
|
||||
|
||||
public void addPayloadDV(PayloadDV payloadDV) {
|
||||
listPayloads.add(payloadDV);
|
||||
}
|
||||
|
||||
public void addListPayloadsDV(List<PayloadDV> listPayloadsDV) {
|
||||
listPayloads.addAll(listPayloadsDV);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("FilesetDV [gcubeProfileFieldName=");
|
||||
builder.append(gcubeProfileFieldName);
|
||||
builder.append(", filesetFieldName=");
|
||||
builder.append(filesetFieldName);
|
||||
builder.append(", listPayloads=");
|
||||
builder.append(listPayloads);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class PayloadDV implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1638565659484691126L;
|
||||
|
||||
private String mimetype;
|
||||
|
||||
private String storageID;
|
||||
|
||||
private String link;
|
||||
|
||||
private String name;
|
||||
|
||||
public PayloadDV() {
|
||||
|
||||
}
|
||||
|
||||
public String getMimetype() {
|
||||
return mimetype;
|
||||
}
|
||||
|
||||
public String getStorageID() {
|
||||
return storageID;
|
||||
}
|
||||
|
||||
public String getLink() {
|
||||
return link;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setMimetype(String mimetype) {
|
||||
this.mimetype = mimetype;
|
||||
}
|
||||
|
||||
public void setStorageID(String storageID) {
|
||||
this.storageID = storageID;
|
||||
}
|
||||
|
||||
public void setLink(String link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Payload [mimetype=");
|
||||
builder.append(mimetype);
|
||||
builder.append(", storageID=");
|
||||
builder.append(storageID);
|
||||
builder.append(", link=");
|
||||
builder.append(link);
|
||||
builder.append(", name=");
|
||||
builder.append(name);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* The Class AccessDV.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Aug 10, 2022
|
||||
*/
|
||||
public class AccessDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8017931037814730958L;
|
||||
|
||||
private String policy;
|
||||
|
||||
private String license;
|
||||
|
||||
/**
|
||||
* Instantiates a new access DV.
|
||||
*/
|
||||
public AccessDV() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the policy.
|
||||
*
|
||||
* @return the policy
|
||||
*/
|
||||
public String getPolicy() {
|
||||
return policy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the license.
|
||||
*
|
||||
* @return the license
|
||||
*/
|
||||
public String getLicense() {
|
||||
return license;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the policy.
|
||||
*
|
||||
* @param policy the new policy
|
||||
*/
|
||||
public void setPolicy(String policy) {
|
||||
this.policy = policy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the license.
|
||||
*
|
||||
* @param license the new license
|
||||
*/
|
||||
public void setLicense(String license) {
|
||||
this.license = license;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("AccessDV [policy=");
|
||||
builder.append(policy);
|
||||
builder.append(", license=");
|
||||
builder.append(license);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* The Class AccountingInfoDV.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Aug 10, 2022
|
||||
*/
|
||||
public class AccountingInfoDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5676731760855130687L;
|
||||
private String username;
|
||||
private Set<String> roles;
|
||||
private String context;
|
||||
private String localDate;
|
||||
|
||||
/**
|
||||
* Instantiates a new accounting info DV.
|
||||
*/
|
||||
public AccountingInfoDV() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the username.
|
||||
*
|
||||
* @return the username
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the roles.
|
||||
*
|
||||
* @return the roles
|
||||
*/
|
||||
public Set<String> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the context.
|
||||
*
|
||||
* @return the context
|
||||
*/
|
||||
public String getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the username.
|
||||
*
|
||||
* @param username the new username
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the roles.
|
||||
*
|
||||
* @param roles the new roles
|
||||
*/
|
||||
public void setRoles(Set<String> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the context.
|
||||
*
|
||||
* @param context the new context
|
||||
*/
|
||||
public void setContext(String context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public String getLocalDate() {
|
||||
return localDate;
|
||||
}
|
||||
|
||||
public void setLocalDate(String localDate) {
|
||||
this.localDate = localDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("AccountingInfoDV [username=");
|
||||
builder.append(username);
|
||||
builder.append(", roles=");
|
||||
builder.append(roles);
|
||||
builder.append(", context=");
|
||||
builder.append(context);
|
||||
builder.append(", localDate=");
|
||||
builder.append(localDate);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* The Class BasicLifecycleInformationDV.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Aug 10, 2022
|
||||
*/
|
||||
public class BasicLifecycleInformationDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 2301238401365921132L;
|
||||
|
||||
/**
|
||||
* The Enum Status.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Mar 21, 2022
|
||||
*/
|
||||
public static enum Status {
|
||||
OK("Success"), ERROR("Error"), WARNING("Warning"), NOT_SPECIFIED("Not specified");
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Instantiates a new status.
|
||||
*
|
||||
* @param label the label
|
||||
*/
|
||||
private Status(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the label.
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
protected String phase;
|
||||
protected Status lastOperationStatus;
|
||||
|
||||
/**
|
||||
* Instantiates a new basic lifecycle information DV.
|
||||
*/
|
||||
public BasicLifecycleInformationDV() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the phase.
|
||||
*
|
||||
* @return the phase
|
||||
*/
|
||||
public String getPhase() {
|
||||
return phase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last operation status.
|
||||
*
|
||||
* @return the last operation status
|
||||
*/
|
||||
public Status getLastOperationStatus() {
|
||||
return lastOperationStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the phase.
|
||||
*
|
||||
* @param phase the new phase
|
||||
*/
|
||||
public void setPhase(String phase) {
|
||||
this.phase = phase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the last operation status.
|
||||
*
|
||||
* @param lastOperationStatus the new last operation status
|
||||
*/
|
||||
public void setLastOperationStatus(Status lastOperationStatus) {
|
||||
this.lastOperationStatus = lastOperationStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("BasicLifecycleInformationDV [phase=");
|
||||
builder.append(phase);
|
||||
builder.append(", lastOperationStatus=");
|
||||
builder.append(lastOperationStatus);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
|
||||
|
||||
public class IdentificationReferenceDV extends DocumentDV implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4038859146891291745L;
|
||||
private String type;
|
||||
|
||||
public IdentificationReferenceDV() {
|
||||
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public IdentificationReferencesTYPE asIdentificationReferencesTYPE() {
|
||||
try {
|
||||
return IdentificationReferencesTYPE.valueOf(type);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("IdentificationReferenceDV [type=");
|
||||
builder.append(type);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||
|
||||
|
||||
/**
|
||||
* The Enum IdentificationReferencesTYPE.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Oct 26, 2022
|
||||
*/
|
||||
public enum IdentificationReferencesTYPE {
|
||||
|
||||
SPATIAL_REFERENCE("SPATIAL REFERENCE");
|
||||
|
||||
String type;
|
||||
|
||||
/**
|
||||
* Instantiates a new identification references TYPE.
|
||||
*
|
||||
* @param type the type
|
||||
*/
|
||||
IdentificationReferencesTYPE(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The Class LifecycleInformationDV.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Mar 21, 2022
|
||||
*/
|
||||
public class LifecycleInformationDV extends BasicLifecycleInformationDV {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3042285563158430778L;
|
||||
private String lastInvokedStep;
|
||||
private List<String> errorMessages;
|
||||
private List<String> warningMessages;
|
||||
private String asJSONString;
|
||||
private String lastEvent;
|
||||
|
||||
/**
|
||||
* Instantiates a new lifecycle information DV.
|
||||
*/
|
||||
public LifecycleInformationDV() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new lifecycle information DV.
|
||||
*
|
||||
* @param lastInvokedStep the last invoked step
|
||||
* @param errorMessages the error messages
|
||||
* @param warningMessages the warning messages
|
||||
* @param asJSONString the as JSON string
|
||||
* @param lastEvent the last event
|
||||
*/
|
||||
public LifecycleInformationDV(String lastInvokedStep, List<String> errorMessages, List<String> warningMessages,
|
||||
String asJSONString, String lastEvent) {
|
||||
super();
|
||||
this.lastInvokedStep = lastInvokedStep;
|
||||
this.errorMessages = errorMessages;
|
||||
this.warningMessages = warningMessages;
|
||||
this.asJSONString = asJSONString;
|
||||
this.lastEvent = lastEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the phase.
|
||||
*
|
||||
* @return the phase
|
||||
*/
|
||||
public String getPhase() {
|
||||
return phase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last invoked step.
|
||||
*
|
||||
* @return the last invoked step
|
||||
*/
|
||||
public String getLastInvokedStep() {
|
||||
return lastInvokedStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last operation status.
|
||||
*
|
||||
* @return the last operation status
|
||||
*/
|
||||
public Status getLastOperationStatus() {
|
||||
return lastOperationStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the error messages.
|
||||
*
|
||||
* @return the error messages
|
||||
*/
|
||||
public List<String> getErrorMessages() {
|
||||
return errorMessages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the warning messages.
|
||||
*
|
||||
* @return the warning messages
|
||||
*/
|
||||
public List<String> getWarningMessages() {
|
||||
return warningMessages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the phase.
|
||||
*
|
||||
* @param phase the new phase
|
||||
*/
|
||||
public void setPhase(String phase) {
|
||||
this.phase = phase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the last invoked step.
|
||||
*
|
||||
* @param lastInvokedStep the new last invoked step
|
||||
*/
|
||||
public void setLastInvokedStep(String lastInvokedStep) {
|
||||
this.lastInvokedStep = lastInvokedStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the last operation status.
|
||||
*
|
||||
* @param lastOperationStatus the new last operation status
|
||||
*/
|
||||
public void setLastOperationStatus(Status lastOperationStatus) {
|
||||
this.lastOperationStatus = lastOperationStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the error messages.
|
||||
*
|
||||
* @param errorMessages the new error messages
|
||||
*/
|
||||
public void setErrorMessages(List<String> errorMessages) {
|
||||
this.errorMessages = errorMessages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the warning messages.
|
||||
*
|
||||
* @param warningMessages the new warning messages
|
||||
*/
|
||||
public void setWarningMessages(List<String> warningMessages) {
|
||||
this.warningMessages = warningMessages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the as JSON string.
|
||||
*
|
||||
* @param json the new as JSON string
|
||||
*/
|
||||
public void setAsJSONString(String json) {
|
||||
this.asJSONString = json;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the last event.
|
||||
*
|
||||
* @param lastEvent the new last event
|
||||
*/
|
||||
public void setLastEvent(String lastEvent) {
|
||||
this.lastEvent = lastEvent;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last event.
|
||||
*
|
||||
* @return the last event
|
||||
*/
|
||||
public String getLastEvent() {
|
||||
return lastEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the as JSON string.
|
||||
*
|
||||
* @return the as JSON string
|
||||
*/
|
||||
public String getAsJSONString() {
|
||||
return asJSONString;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("LifecycleInformationDV [lastInvokedStep=");
|
||||
builder.append(lastInvokedStep);
|
||||
builder.append(", errorMessages=");
|
||||
builder.append(errorMessages);
|
||||
builder.append(", warningMessages=");
|
||||
builder.append(warningMessages);
|
||||
builder.append(", asJSONString=");
|
||||
builder.append(asJSONString);
|
||||
builder.append(", lastEvent=");
|
||||
builder.append(lastEvent);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class PhaseDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1894531938705738017L;
|
||||
|
||||
private Integer count;
|
||||
private Phase_Id _id;
|
||||
|
||||
public PhaseDV() {
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
class Phase_Id {
|
||||
String phase;
|
||||
String status;
|
||||
|
||||
public Phase_Id() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
|
||||
|
||||
public class ProjectDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6296612945369540613L;
|
||||
private String id;
|
||||
private String version;
|
||||
// private PublicationInfo info;
|
||||
private String profileID; // the profile == UCD
|
||||
private String profileVersion; // the profile == UCD
|
||||
private String profileName;
|
||||
private List<RelationshipDV> relationships;
|
||||
private DocumentDV theDocument;
|
||||
|
||||
// the key is the IdentificationReferenceDV.getType()
|
||||
private Map<String, IdentificationReferenceDV> mapIdentReferenceDV;
|
||||
private LifecycleInformationDV lifecycleInformationDV;
|
||||
|
||||
// Shortcut to "SPATIAL REFERENCE" containted into IdentificationReferenceDV
|
||||
private GeoJSON spatialReference;
|
||||
private TemporalReferenceDV temporalReference;
|
||||
|
||||
public ProjectDV() {
|
||||
|
||||
}
|
||||
|
||||
public String getProfileName() {
|
||||
return profileName;
|
||||
}
|
||||
|
||||
public void setProfileName(String profileName) {
|
||||
this.profileName = profileName;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getProfileID() {
|
||||
return profileID;
|
||||
}
|
||||
|
||||
public String getProfileVersion() {
|
||||
return profileVersion;
|
||||
}
|
||||
|
||||
public List<RelationshipDV> getRelationships() {
|
||||
return relationships;
|
||||
}
|
||||
|
||||
public DocumentDV getTheDocument() {
|
||||
return theDocument;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public void setProfileID(String profileID) {
|
||||
this.profileID = profileID;
|
||||
}
|
||||
|
||||
public void setProfileVersion(String profileVersion) {
|
||||
this.profileVersion = profileVersion;
|
||||
}
|
||||
|
||||
public void setRelationships(List<RelationshipDV> relationships) {
|
||||
this.relationships = relationships;
|
||||
}
|
||||
|
||||
public void setTheDocument(DocumentDV theDocument) {
|
||||
this.theDocument = theDocument;
|
||||
}
|
||||
|
||||
public LifecycleInformationDV getLifecycleInformationDV() {
|
||||
return lifecycleInformationDV;
|
||||
}
|
||||
|
||||
public Map<String, IdentificationReferenceDV> getMapIdentReferenceDV() {
|
||||
return mapIdentReferenceDV;
|
||||
}
|
||||
|
||||
public void setMapIdentReferenceDV(Map<String, IdentificationReferenceDV> mapIdentReferenceDV) {
|
||||
this.mapIdentReferenceDV = mapIdentReferenceDV;
|
||||
}
|
||||
|
||||
public void setLifecycleInformationDV(LifecycleInformationDV lifecycleInformationDV) {
|
||||
this.lifecycleInformationDV = lifecycleInformationDV;
|
||||
}
|
||||
|
||||
public GeoJSON getSpatialReference() {
|
||||
return spatialReference;
|
||||
}
|
||||
|
||||
public void setSpatialReference(GeoJSON spatialReference) {
|
||||
this.spatialReference = spatialReference;
|
||||
}
|
||||
|
||||
public TemporalReferenceDV getTemporalReference() {
|
||||
return temporalReference;
|
||||
}
|
||||
|
||||
public void setTemporalReference(TemporalReferenceDV temporalReference) {
|
||||
this.temporalReference = temporalReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ProjectDV [id=");
|
||||
builder.append(id);
|
||||
builder.append(", version=");
|
||||
builder.append(version);
|
||||
builder.append(", profileID=");
|
||||
builder.append(profileID);
|
||||
builder.append(", profileVersion=");
|
||||
builder.append(profileVersion);
|
||||
builder.append(", profileName=");
|
||||
builder.append(profileName);
|
||||
builder.append(", relationships=");
|
||||
builder.append(relationships);
|
||||
builder.append(", theDocument=");
|
||||
builder.append(theDocument);
|
||||
builder.append(", mapIdentReferenceDV=");
|
||||
builder.append(mapIdentReferenceDV);
|
||||
builder.append(", lifecycleInformationDV=");
|
||||
builder.append(lifecycleInformationDV);
|
||||
builder.append(", spatialReference=");
|
||||
builder.append(spatialReference);
|
||||
builder.append(", temporalReference=");
|
||||
builder.append(temporalReference);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class PublicationInfoDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6381578837148417563L;
|
||||
private AccountingInfoDV creationInfo;
|
||||
private AccountingInfoDV lastEditInfo;
|
||||
private AccessDV access;
|
||||
|
||||
public PublicationInfoDV() {
|
||||
|
||||
}
|
||||
|
||||
public AccountingInfoDV getCreationInfo() {
|
||||
return creationInfo;
|
||||
}
|
||||
|
||||
public AccountingInfoDV getLastEditInfo() {
|
||||
return lastEditInfo;
|
||||
}
|
||||
|
||||
public AccessDV getAccess() {
|
||||
return access;
|
||||
}
|
||||
|
||||
public void setCreationInfo(AccountingInfoDV creationInfo) {
|
||||
this.creationInfo = creationInfo;
|
||||
}
|
||||
|
||||
public void setLastEditInfo(AccountingInfoDV lastEditInfo) {
|
||||
this.lastEditInfo = lastEditInfo;
|
||||
}
|
||||
|
||||
public void setAccess(AccessDV access) {
|
||||
this.access = access;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("PublicationInfoDV [creationInfo=");
|
||||
builder.append(creationInfo);
|
||||
builder.append(", lastEditInfo=");
|
||||
builder.append(lastEditInfo);
|
||||
builder.append(", access=");
|
||||
builder.append(access);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class RelationshipDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8295671124305773593L;
|
||||
private String relationshipName;
|
||||
private String targetID;
|
||||
private String asJSON;
|
||||
private String targetUCD;
|
||||
|
||||
public RelationshipDV() {
|
||||
|
||||
}
|
||||
|
||||
public RelationshipDV(String relationshipName, String targetID, String targetUCD, String asJSON) {
|
||||
super();
|
||||
this.relationshipName = relationshipName;
|
||||
this.targetID = targetID;
|
||||
this.targetUCD = targetUCD;
|
||||
this.asJSON = asJSON;
|
||||
}
|
||||
|
||||
public String getTargetUCD() {
|
||||
return targetUCD;
|
||||
}
|
||||
|
||||
public void setTargetUCD(String targetUCD) {
|
||||
this.targetUCD = targetUCD;
|
||||
}
|
||||
|
||||
public String getTargetID() {
|
||||
return targetID;
|
||||
}
|
||||
|
||||
public void setTargetID(String targetID) {
|
||||
this.targetID = targetID;
|
||||
}
|
||||
|
||||
public String getRelationshipName() {
|
||||
return relationshipName;
|
||||
}
|
||||
|
||||
public void setRelationshipName(String relationshipName) {
|
||||
this.relationshipName = relationshipName;
|
||||
}
|
||||
|
||||
public String getAsJSON() {
|
||||
return asJSON;
|
||||
}
|
||||
|
||||
public void setAsJSON(String asJSON) {
|
||||
this.asJSON = asJSON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("RelationshipDV [relationshipName=");
|
||||
builder.append(relationshipName);
|
||||
builder.append(", targetID=");
|
||||
builder.append(targetID);
|
||||
builder.append(", asJSON=");
|
||||
builder.append(asJSON);
|
||||
builder.append(", targetUCD=");
|
||||
builder.append(targetUCD);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
|
||||
|
||||
/**
|
||||
* The Class TemporalReferenceDV.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Mar 10, 2022
|
||||
* @param <T>
|
||||
*/
|
||||
public class TemporalReferenceDV extends DocumentDV {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7990905553022863653L;
|
||||
private String profileID;
|
||||
private String projectID;
|
||||
|
||||
private String jsonTimelineObject;
|
||||
|
||||
private Date start;
|
||||
private Date end;
|
||||
|
||||
/**
|
||||
* Instantiates a new temporal reference DV.
|
||||
*/
|
||||
public TemporalReferenceDV() {
|
||||
|
||||
}
|
||||
|
||||
public String getJsonTimelineObject() {
|
||||
return jsonTimelineObject;
|
||||
}
|
||||
|
||||
public void setJsonTimelineObject(String jsonTimelineObject) {
|
||||
this.jsonTimelineObject = jsonTimelineObject;
|
||||
}
|
||||
|
||||
public String getProfileID() {
|
||||
return profileID;
|
||||
}
|
||||
|
||||
public String getProjectID() {
|
||||
return projectID;
|
||||
}
|
||||
|
||||
public Date getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public Date getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
public void setProfileID(String profileID) {
|
||||
this.profileID = profileID;
|
||||
}
|
||||
|
||||
public void setProjectID(String projectID) {
|
||||
this.projectID = projectID;
|
||||
}
|
||||
|
||||
public void setStart(Date start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public void setEnd(Date end) {
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("TemporalReferenceDV [profileID=");
|
||||
builder.append(profileID);
|
||||
builder.append(", projectID=");
|
||||
builder.append(projectID);
|
||||
builder.append(", jsonTimelineObject=");
|
||||
builder.append(jsonTimelineObject);
|
||||
builder.append(", start=");
|
||||
builder.append(start);
|
||||
builder.append(", end=");
|
||||
builder.append(end);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.ucd;
|
||||
|
||||
public enum GEOPORTAL_CONFIGURATION_TYPE {
|
||||
item_fields("itemFields"),
|
||||
gcube_profiles("gcubeProfiles"),
|
||||
actions_definition("actionsDefinition"),
|
||||
grouped_overlay_layers("grouped_overlay_layers"),
|
||||
grouped_cross_filtering_layers("grouped_cross_filtering_layers");
|
||||
|
||||
String id;
|
||||
|
||||
/**
|
||||
* Instantiates a new gna config managed.
|
||||
*
|
||||
* @param id the id
|
||||
*/
|
||||
GEOPORTAL_CONFIGURATION_TYPE(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.ucd;
|
||||
|
||||
public enum GEOPORTAL_DATA_HANDLER {
|
||||
|
||||
geoportal_data_list("org.gcube.portlets.user.geoportal-data-list", "DATA_LIST_GUI"),
|
||||
geoportal_basic_data_list("org.gcube.portlets.user.geoportal-basic-data-list", "BASIC_DATA_LIST_GUI"),
|
||||
geoportal_data_entry("org.gcube.portlets.user.geoportal-data-entry-app", "DATA_ENTRY_GUI"),
|
||||
geoportal_workflow_action_list("org.gcube.portlets.user.geoportal-workflow-action-list","WORKFLOW_ACTION_LIST_GUI"),
|
||||
geoportal_timeline_json_template("org.gcube.portlets.user.geoportal-timeline-json-template","TIMELINE_JSON_TEMPLATE"),
|
||||
geoportal_grouped_cross_filtering("org.gcube.portlets.user.grouped_cross_filtering_layers","GROUPED_CROSS_FILTERING_LAYERS"),
|
||||
geoportal_grouped_overlay_layers("org.gcube.portlets.user.grouped_overlay_layers","GROUPED_OVERLAY_LAYERS"),
|
||||
gna_concessioni_lc("GNA-CONCESSIONI-LC", "LifecycleManagement");
|
||||
|
||||
String id;
|
||||
String type;
|
||||
|
||||
GEOPORTAL_DATA_HANDLER(String id, String type) {
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,167 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.ucd;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
|
||||
|
||||
/**
|
||||
* The Class HandlerDeclarationDV.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Mar 17, 2022
|
||||
*/
|
||||
public class HandlerDeclarationDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3664650151266716354L;
|
||||
|
||||
private String id;
|
||||
private String type;
|
||||
private String itemType; // This is the use case (e.g. Concessioni)
|
||||
private ConfigurationDV<?> configuration;
|
||||
private GEOPORTAL_DATA_HANDLER dataHandlerType;
|
||||
|
||||
/**
|
||||
* Instantiates a new handler declaration DV.
|
||||
*/
|
||||
public HandlerDeclarationDV() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new handler declaration DV.
|
||||
*
|
||||
* @param id the id
|
||||
* @param type the type
|
||||
* @param itemType the item type
|
||||
* @param configuration the configuration
|
||||
* @param dataHandlerType the data handler type
|
||||
*/
|
||||
public HandlerDeclarationDV(String id, String type, String itemType,
|
||||
ConfigurationDV<?> configuration,
|
||||
GEOPORTAL_DATA_HANDLER dataHandlerType) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.itemType = itemType;
|
||||
this.configuration = configuration;
|
||||
this.dataHandlerType = dataHandlerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item type.
|
||||
*
|
||||
* @return the item type
|
||||
*/
|
||||
public String getItemType() {
|
||||
return itemType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration.
|
||||
*
|
||||
* @return the configuration
|
||||
*/
|
||||
public ConfigurationDV<?> getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data handler type.
|
||||
*
|
||||
* @return the data handler type
|
||||
*/
|
||||
public GEOPORTAL_DATA_HANDLER getDataHandlerType() {
|
||||
return dataHandlerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id.
|
||||
*
|
||||
* @param id the new id
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type.
|
||||
*
|
||||
* @param type the new type
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the item type.
|
||||
*
|
||||
* @param itemType the new item type
|
||||
*/
|
||||
public void setItemType(String itemType) {
|
||||
this.itemType = itemType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the configuration.
|
||||
*
|
||||
* @param configuration the new configuration
|
||||
*/
|
||||
public void setConfiguration(ConfigurationDV<?> configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data handler type.
|
||||
*
|
||||
* @param dataHandlerType the new data handler type
|
||||
*/
|
||||
public void setDataHandlerType(GEOPORTAL_DATA_HANDLER dataHandlerType) {
|
||||
this.dataHandlerType = dataHandlerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("HandlerDeclarationDV [id=");
|
||||
builder.append(id);
|
||||
builder.append(", type=");
|
||||
builder.append(type);
|
||||
builder.append(", itemType=");
|
||||
builder.append(itemType);
|
||||
builder.append(", configuration=");
|
||||
builder.append(configuration);
|
||||
builder.append(", dataHandlerType=");
|
||||
builder.append(dataHandlerType);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.ucd;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class RelationshipDefinitionDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8542669180440066726L;
|
||||
private String id;
|
||||
private String label;
|
||||
private String reverseRelationId;
|
||||
|
||||
public RelationshipDefinitionDV() {
|
||||
|
||||
}
|
||||
|
||||
public RelationshipDefinitionDV(String id, String label, String reverseRelationId) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.label = label;
|
||||
this.reverseRelationId = reverseRelationId;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public String getReverseRelationId() {
|
||||
return reverseRelationId;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public void setReverseRelationId(String reverseRelationId) {
|
||||
this.reverseRelationId = reverseRelationId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("RelationshipDefinitionDV [id=");
|
||||
builder.append(id);
|
||||
builder.append(", label=");
|
||||
builder.append(label);
|
||||
builder.append(", reverseRelationId=");
|
||||
builder.append(reverseRelationId);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.ucd;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class UseCaseDescriptorDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2864888245002804887L;
|
||||
private String id; // this is the ProfileID
|
||||
private String version;
|
||||
private String name;
|
||||
private String description;
|
||||
|
||||
private List<HandlerDeclarationDV> handlers;
|
||||
|
||||
public UseCaseDescriptorDV() {
|
||||
}
|
||||
|
||||
public UseCaseDescriptorDV(String id, String version, String name, String description) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.version = version;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getProfileID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public List<HandlerDeclarationDV> getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setHandlers(List<HandlerDeclarationDV> handlers) {
|
||||
this.handlers = handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("UseCaseDescriptorDV [id=");
|
||||
builder.append(id);
|
||||
builder.append(", version=");
|
||||
builder.append(version);
|
||||
builder.append(", name=");
|
||||
builder.append(name);
|
||||
builder.append(", description=");
|
||||
builder.append(description);
|
||||
builder.append(", handlers=");
|
||||
builder.append(handlers);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.view;
|
||||
|
||||
public interface CheckEmpty {
|
||||
|
||||
public Boolean isEmpty();
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.view;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||
|
||||
public class ProjectView implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1681876085329564419L;
|
||||
private ProjectDV theProjectDV;
|
||||
// The DocumentDV (contained in the ProjectDV) is listed in SectionView
|
||||
private List<SectionView> listSections = new ArrayList<SectionView>();
|
||||
|
||||
public ProjectView() {
|
||||
|
||||
}
|
||||
|
||||
public void addSectionView(SectionView sectionView) {
|
||||
listSections.add(sectionView);
|
||||
}
|
||||
|
||||
public ProjectDV getTheProjectDV() {
|
||||
return theProjectDV;
|
||||
}
|
||||
|
||||
public List<SectionView> getListSections() {
|
||||
return listSections;
|
||||
}
|
||||
|
||||
public void setTheProjectDV(ProjectDV theProjectDV) {
|
||||
this.theProjectDV = theProjectDV;
|
||||
}
|
||||
|
||||
public void setListSections(List<SectionView> listSections) {
|
||||
this.listSections = listSections;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ProjectView [theProjectDV=");
|
||||
builder.append(theProjectDV);
|
||||
builder.append(", listSections=");
|
||||
builder.append(listSections);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.view;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The Class SectionView.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 11, 2022
|
||||
*/
|
||||
public class SectionView implements Serializable, CheckEmpty {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5360469987059239067L;
|
||||
|
||||
private String sectionTitle;
|
||||
|
||||
private List<SubDocumentView> listSubDocuments;
|
||||
|
||||
/**
|
||||
* Instantiates a new section view.
|
||||
*/
|
||||
public SectionView() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is empty.
|
||||
*
|
||||
* @return true, if is empty
|
||||
*/
|
||||
@Override
|
||||
public Boolean isEmpty() {
|
||||
if (listSubDocuments == null)
|
||||
return true;
|
||||
|
||||
for (SubDocumentView subDocumentView : listSubDocuments) {
|
||||
boolean isEmpty = subDocumentView.isEmpty();
|
||||
if (isEmpty)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for spatial layers.
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
public Boolean hasSpatialLayers() {
|
||||
if (listSubDocuments == null)
|
||||
return false;
|
||||
|
||||
for (SubDocumentView subDocumentView : listSubDocuments) {
|
||||
boolean hasLayers = subDocumentView.getListLayers() != null && subDocumentView.getListLayers().size() > 0;
|
||||
if (hasLayers)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the section title.
|
||||
*
|
||||
* @return the section title
|
||||
*/
|
||||
public String getSectionTitle() {
|
||||
return sectionTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the sub document.
|
||||
*
|
||||
* @param subDocumentView the sub document view
|
||||
*/
|
||||
public void addSubDocument(SubDocumentView subDocumentView) {
|
||||
|
||||
if (listSubDocuments == null)
|
||||
listSubDocuments = new ArrayList<SubDocumentView>();
|
||||
|
||||
listSubDocuments.add(subDocumentView);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list sub documents.
|
||||
*
|
||||
* @return the list sub documents
|
||||
*/
|
||||
public List<SubDocumentView> getListSubDocuments() {
|
||||
|
||||
if (listSubDocuments == null)
|
||||
listSubDocuments = new ArrayList<SubDocumentView>();
|
||||
|
||||
return listSubDocuments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the section title.
|
||||
*
|
||||
* @param sectionTitle the new section title
|
||||
*/
|
||||
public void setSectionTitle(String sectionTitle) {
|
||||
this.sectionTitle = sectionTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SectionView [sectionTitle=");
|
||||
builder.append(sectionTitle);
|
||||
builder.append(", listSubDocuments=");
|
||||
builder.append(listSubDocuments);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.view;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.FilesetDV;
|
||||
|
||||
public class SubDocumentView implements Serializable, CheckEmpty {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3563782450418275140L;
|
||||
|
||||
private String metadataAsJSON;
|
||||
|
||||
private List<FilesetDV> listFiles;
|
||||
private List<FilesetDV> listImages;
|
||||
private List<GCubeSDIViewerLayerDV> listLayers;
|
||||
|
||||
public SubDocumentView() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isEmpty() {
|
||||
|
||||
if (metadataAsJSON != null && !metadataAsJSON.isEmpty())
|
||||
return false;
|
||||
|
||||
if (listFiles != null && !listFiles.isEmpty())
|
||||
return false;
|
||||
|
||||
if (listImages != null && !listImages.isEmpty())
|
||||
return false;
|
||||
|
||||
if (listLayers != null && !listLayers.isEmpty())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getMetadataAsJSON() {
|
||||
return metadataAsJSON;
|
||||
}
|
||||
|
||||
public List<FilesetDV> getListFiles() {
|
||||
return listFiles;
|
||||
}
|
||||
|
||||
public List<FilesetDV> getListImages() {
|
||||
return listImages;
|
||||
}
|
||||
|
||||
public List<GCubeSDIViewerLayerDV> getListLayers() {
|
||||
return listLayers;
|
||||
}
|
||||
|
||||
public void setMetadataAsJSON(String metadataAsJSON) {
|
||||
this.metadataAsJSON = metadataAsJSON;
|
||||
}
|
||||
|
||||
public void setListFiles(List<FilesetDV> listFiles) {
|
||||
this.listFiles = listFiles;
|
||||
}
|
||||
|
||||
public void setListImages(List<FilesetDV> listImages) {
|
||||
this.listImages = listImages;
|
||||
}
|
||||
|
||||
public void setListLayers(List<GCubeSDIViewerLayerDV> listLayers) {
|
||||
this.listLayers = listLayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SubDocumentView [metadataAsJSON=");
|
||||
builder.append(metadataAsJSON);
|
||||
builder.append(", listFiles=");
|
||||
builder.append(listFiles);
|
||||
builder.append(", listImages=");
|
||||
builder.append(listImages);
|
||||
builder.append(", listLayers=");
|
||||
builder.append(listLayers);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,170 @@
|
|||
package org.gcube.application.geoportalcommon.shared.gis;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* The Class BoundsMap.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Oct 27, 2020
|
||||
*/
|
||||
public class BoundsMap implements Serializable{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 69005924452960006L;
|
||||
|
||||
/** The lower left X. */
|
||||
private double lowerLeftX = 0.0;
|
||||
|
||||
/** The lower left Y. */
|
||||
private double lowerLeftY = 0.0;
|
||||
|
||||
/** The upper right X. */
|
||||
private double upperRightX = 0.0;
|
||||
|
||||
/** The upper right Y. */
|
||||
private double upperRightY = 0.0;
|
||||
|
||||
/** The crs. */
|
||||
private String crs = "";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new bounds map.
|
||||
*/
|
||||
public BoundsMap() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new bounds map.
|
||||
*
|
||||
* @param lowerLeftX the lower left X
|
||||
* @param lowerLeftY the lower left Y
|
||||
* @param upperRightX the upper right X
|
||||
* @param upperRightY the upper right Y
|
||||
* @param crs the crs
|
||||
*/
|
||||
public BoundsMap(double lowerLeftX, double lowerLeftY, double upperRightX,
|
||||
double upperRightY, String crs) {
|
||||
super();
|
||||
this.lowerLeftX = lowerLeftX;
|
||||
this.lowerLeftY = lowerLeftY;
|
||||
this.upperRightX = upperRightX;
|
||||
this.upperRightY = upperRightY;
|
||||
this.crs = crs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the lower left X.
|
||||
*
|
||||
* @return the lower left X
|
||||
*/
|
||||
public double getLowerLeftX() {
|
||||
return lowerLeftX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the lower left X.
|
||||
*
|
||||
* @param lowerLeftX the new lower left X
|
||||
*/
|
||||
public void setLowerLeftX(double lowerLeftX) {
|
||||
this.lowerLeftX = lowerLeftX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the lower left Y.
|
||||
*
|
||||
* @return the lower left Y
|
||||
*/
|
||||
public double getLowerLeftY() {
|
||||
return lowerLeftY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the lower left Y.
|
||||
*
|
||||
* @param lowerLeftY the new lower left Y
|
||||
*/
|
||||
public void setLowerLeftY(double lowerLeftY) {
|
||||
this.lowerLeftY = lowerLeftY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the upper right X.
|
||||
*
|
||||
* @return the upper right X
|
||||
*/
|
||||
public double getUpperRightX() {
|
||||
return upperRightX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the upper right X.
|
||||
*
|
||||
* @param upperRightX the new upper right X
|
||||
*/
|
||||
public void setUpperRightX(double upperRightX) {
|
||||
this.upperRightX = upperRightX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the upper right Y.
|
||||
*
|
||||
* @return the upper right Y
|
||||
*/
|
||||
public double getUpperRightY() {
|
||||
return upperRightY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the upper right Y.
|
||||
*
|
||||
* @param upperRightY the new upper right Y
|
||||
*/
|
||||
public void setUpperRightY(double upperRightY) {
|
||||
this.upperRightY = upperRightY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the crs.
|
||||
*
|
||||
* @return the crs
|
||||
*/
|
||||
public String getCrs() {
|
||||
return crs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the crs.
|
||||
*
|
||||
* @param crs the new crs
|
||||
*/
|
||||
public void setCrs(String crs) {
|
||||
this.crs = crs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("BoundsMap [lowerLeftX=");
|
||||
builder.append(lowerLeftX);
|
||||
builder.append(", lowerLeftY=");
|
||||
builder.append(lowerLeftY);
|
||||
builder.append(", upperRightX=");
|
||||
builder.append(upperRightX);
|
||||
builder.append(", upperRightY=");
|
||||
builder.append(upperRightY);
|
||||
builder.append(", crs=");
|
||||
builder.append(crs);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package org.gcube.application.geoportalcommon.shared.guipresentation;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "body_welcome")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class BodyWelcome implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 801731912505360534L;
|
||||
|
||||
@XmlElement
|
||||
private String title;
|
||||
@XmlElement
|
||||
private String description;
|
||||
|
||||
public BodyWelcome() {
|
||||
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("BodyWelcome [title=");
|
||||
builder.append(title);
|
||||
builder.append(", description=");
|
||||
builder.append(description);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package org.gcube.application.geoportalcommon.shared.guipresentation;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* The Class DataEntryGUIPresentationConfig.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Sep 26, 2022
|
||||
*/
|
||||
public class DataEntryGUIPresentationConfig implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6007504380531152501L;
|
||||
private Header header;
|
||||
private BodyWelcome bodyWelcome;
|
||||
|
||||
/**
|
||||
* Instantiates a new data entry GUI presentation config.
|
||||
*/
|
||||
public DataEntryGUIPresentationConfig() {
|
||||
|
||||
}
|
||||
|
||||
public Header getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public BodyWelcome getBodyWelcome() {
|
||||
return bodyWelcome;
|
||||
}
|
||||
|
||||
public void setHeader(Header header) {
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
public void setBodyWelcome(BodyWelcome bodyWelcome) {
|
||||
this.bodyWelcome = bodyWelcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("DataEntryGUIPresentationConfig [header=");
|
||||
builder.append(header);
|
||||
builder.append(", bodyWelcome=");
|
||||
builder.append(bodyWelcome);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package org.gcube.application.geoportalcommon.shared.guipresentation;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* The Class Header.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Sep 26, 2022
|
||||
*/
|
||||
@XmlRootElement(name = "header")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class Header implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1914492109448706008L;
|
||||
|
||||
@XmlElement
|
||||
private String title;
|
||||
|
||||
@XmlElement
|
||||
private String subtitle;
|
||||
|
||||
/**
|
||||
* Instantiates a new header.
|
||||
*/
|
||||
public Header() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the title.
|
||||
*
|
||||
* @return the title
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the subtitle.
|
||||
*
|
||||
* @return the subtitle
|
||||
*/
|
||||
public String getSubtitle() {
|
||||
return subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the title.
|
||||
*
|
||||
* @param title the new title
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the subtitle.
|
||||
*
|
||||
* @param subtitle the new subtitle
|
||||
*/
|
||||
public void setSubtitle(String subtitle) {
|
||||
this.subtitle = subtitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Header [title=");
|
||||
builder.append(title);
|
||||
builder.append(", subtitle=");
|
||||
builder.append(subtitle);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package org.gcube.application.geoportalcommon.util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* The Class DateUtils.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Aug 4, 2021
|
||||
*/
|
||||
public class DateUtils {
|
||||
|
||||
/**
|
||||
* As date.
|
||||
*
|
||||
* @param localDate the local date
|
||||
* @return the date
|
||||
*/
|
||||
public static Date asDate(LocalDate localDate) {
|
||||
if (localDate == null)
|
||||
return null;
|
||||
return Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
/**
|
||||
* As date.
|
||||
*
|
||||
* @param localDateTime the local date time
|
||||
* @return the date
|
||||
*/
|
||||
public static Date asDate(LocalDateTime localDateTime) {
|
||||
if (localDateTime == null)
|
||||
return null;
|
||||
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
/**
|
||||
* As local date.
|
||||
*
|
||||
* @param date the date
|
||||
* @return the local date
|
||||
*/
|
||||
public static LocalDate asLocalDate(Date date) {
|
||||
if (date == null)
|
||||
return null;
|
||||
return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* As local date time.
|
||||
*
|
||||
* @param date the date
|
||||
* @return the local date time
|
||||
*/
|
||||
public static LocalDateTime asLocalDateTime(Date date) {
|
||||
if (date == null)
|
||||
return null;
|
||||
return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
}
|
||||
|
||||
public static Date toDate(String date) {
|
||||
|
||||
if (date == null || date.isEmpty())
|
||||
return null;
|
||||
|
||||
try {
|
||||
LocalDate localDate = LocalDate.parse(date);
|
||||
return asDate(localDate);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
||||
try {
|
||||
LocalDateTime dateTime = LocalDateTime.parse(date);
|
||||
return asDate(dateTime);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
||||
try {
|
||||
return new SimpleDateFormat("yyy-MM-dd").parse(date);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package org.gcube.application.geoportalcommon.util;
|
||||
|
||||
/**
|
||||
* The Class StringUtil.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Aug 31, 2023
|
||||
*/
|
||||
public class StringUtil {
|
||||
|
||||
/**
|
||||
* Ellipsize.
|
||||
*
|
||||
* @param input the input
|
||||
* @param maxLength the max length
|
||||
* @return the string
|
||||
*/
|
||||
public static String ellipsize(String input, int maxLength) {
|
||||
String ellip = "...";
|
||||
if (input == null || input.length() <= maxLength || input.length() < ellip.length()) {
|
||||
return input;
|
||||
}
|
||||
return input.substring(0, maxLength - ellip.length()).concat(ellip);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package org.gcube.application.geoportalcommon.util;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The Class URLUtil.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Oct 29, 2020
|
||||
*/
|
||||
public class URLParserUtil {
|
||||
|
||||
/**
|
||||
* Adds the parameter to query string.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @param prefixAmpersand the prefix ampersand
|
||||
* @param suffixAmpersand the suffix ampersand
|
||||
* @return the string
|
||||
*/
|
||||
public static String addParameterToQueryString(String key, String value, boolean prefixAmpersand,
|
||||
boolean suffixAmpersand) {
|
||||
|
||||
String queryParameter = "";
|
||||
|
||||
if (prefixAmpersand)
|
||||
queryParameter += "&";
|
||||
|
||||
queryParameter += key + "=" + value;
|
||||
|
||||
if (suffixAmpersand)
|
||||
queryParameter += "&";
|
||||
|
||||
return queryParameter;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract value of parameter from URL.
|
||||
*
|
||||
* @param paramName the param name
|
||||
* @param url the url
|
||||
* @return the string
|
||||
*/
|
||||
public static String extractValueOfParameterFromURL(String paramName, String url) {
|
||||
int index = url.toLowerCase().indexOf(paramName.toLowerCase() + "="); // ADDING CHAR "=" IN TAIL TO BE SURE THAT
|
||||
// IT
|
||||
// IS A PARAMETER
|
||||
String value = "";
|
||||
if (index > -1) {
|
||||
|
||||
int start = index + paramName.length() + 1; // add +1 for char '='
|
||||
String sub = url.substring(start, url.length());
|
||||
int indexOfSeparator = sub.indexOf("&");
|
||||
int end = indexOfSeparator != -1 ? indexOfSeparator : sub.length();
|
||||
value = sub.substring(0, end);
|
||||
} else
|
||||
return null;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Split query.
|
||||
*
|
||||
* @param url the url
|
||||
* @return the map
|
||||
* @throws UnsupportedEncodingException the unsupported encoding exception
|
||||
*/
|
||||
public static Map<String, List<String>> splitQuery(URL url) throws UnsupportedEncodingException {
|
||||
final Map<String, List<String>> query_pairs = new LinkedHashMap<String, List<String>>();
|
||||
final String[] pairs = url.getQuery().split("&");
|
||||
for (String pair : pairs) {
|
||||
final int idx = pair.indexOf("=");
|
||||
final String key = idx > 0 ? URLDecoder.decode(pair.substring(0, idx), "UTF-8") : pair;
|
||||
if (!query_pairs.containsKey(key)) {
|
||||
query_pairs.put(key, new LinkedList<String>());
|
||||
}
|
||||
final String value = idx > 0 && pair.length() > idx + 1
|
||||
? URLDecoder.decode(pair.substring(idx + 1), "UTF-8")
|
||||
: null;
|
||||
query_pairs.get(key).add(value);
|
||||
}
|
||||
return query_pairs;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
/resources/
|
|
@ -0,0 +1,43 @@
|
|||
package org.gcube.application;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public class ContextConfigTest {
|
||||
|
||||
private static final String GCUBE_CONFIG_PROPERTIES_FILENAME = "gcube_config.properties";
|
||||
// APP Working Directory + /src/test/resources must be the location of
|
||||
// gcube_config.properties
|
||||
private static String gcube_config_path = String.format("%s/%s",
|
||||
System.getProperty("user.dir") + "/src/test/resources", GCUBE_CONFIG_PROPERTIES_FILENAME);
|
||||
|
||||
|
||||
public static String CONTEXT;
|
||||
public static String TOKEN;
|
||||
|
||||
/**
|
||||
* Read context settings.
|
||||
*/
|
||||
public static void readContextSettings() {
|
||||
|
||||
try (InputStream input = new FileInputStream(gcube_config_path)) {
|
||||
|
||||
Properties prop = new Properties();
|
||||
|
||||
// load a properties file
|
||||
prop.load(input);
|
||||
|
||||
CONTEXT = prop.getProperty("CONTEXT");
|
||||
TOKEN = prop.getProperty("TOKEN");
|
||||
// get the property value and print it out
|
||||
System.out.println("CONTEXT: " + CONTEXT);
|
||||
System.out.println("TOKEN: " + TOKEN);
|
||||
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,428 @@
|
|||
package org.gcube.application;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
||||
import org.gcube.application.geoportalcommon.ProjectDVBuilder;
|
||||
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
||||
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
||||
import org.gcube.application.geoportalcommon.shared.WhereClause;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||
import org.gcube.application.se.RuntimeResourceReader;
|
||||
import org.gcube.application.se.ServiceEndpointBean;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
|
||||
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder;
|
||||
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder.RESOLVE_AS;
|
||||
|
||||
public class CreateGeoportalGisLinkInTheCentroidLayers {
|
||||
|
||||
// private static String CONTEXT = "/gcube/devsec/devVRE";
|
||||
// private static String TOKEN = ""; // devVRE
|
||||
|
||||
// private static final String CONTEXT = "/pred4s/preprod/preVRE";
|
||||
// private static final String TOKEN = ""; //preVRE
|
||||
|
||||
// private static final String CONTEXT = "/d4science.research-infrastructures.eu/D4OS/GNA";
|
||||
// private static final String TOKEN = ""; //GNA
|
||||
|
||||
//Esquiline
|
||||
private static final String CONTEXT = "/d4science.research-infrastructures.eu/gCubeApps/Esquiline";
|
||||
private static final String TOKEN = ""; //Esquiline
|
||||
private static String PROFILE_ID = "esquilino";
|
||||
|
||||
// GEOPORTAL
|
||||
//private static String PROFILE_ID = "profiledConcessioni";
|
||||
// private static final String PROFILE_ID = "concessioni-estere";
|
||||
private static final String JSON_KEY_DATA_FINE_PROGETTO = "dataFineProgetto";
|
||||
private static final String JSON_KEY_DATA_INIZIO_PROGETTO = "dataInizioProgetto";
|
||||
private static final String JSON_KEY_INTRODUZIONE = "introduzione";
|
||||
|
||||
// DB
|
||||
private static final String platformName = "postgis";
|
||||
private static final String category = "Database";
|
||||
// private static final String resourceName = "GNA-POSTGIS-DB"; // devVRE
|
||||
//private static final String resourceName = "Geoserver-t postgis"; //preVRE
|
||||
private static final String resourceName = "GNA-postgis"; // GNA
|
||||
|
||||
private static final String TABLE_COLUMN_GEO_VIEWER_LINK = "geov_link";
|
||||
|
||||
private static ProjectsCaller client = null;
|
||||
|
||||
public static final boolean READ_ONLY_MODE = true;
|
||||
|
||||
/**
|
||||
* Gets the client.
|
||||
*
|
||||
* @return the client
|
||||
*/
|
||||
// @Before
|
||||
public static void initGeoportalClient() {
|
||||
// assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
client = GeoportalClientCaller.projects();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.out.println("READ_ONLY_MODE ENABLED: " + READ_ONLY_MODE);
|
||||
System.out.println("CONTEXT IS: " + CONTEXT);
|
||||
System.out.println("PROFILE_ID: " + PROFILE_ID);
|
||||
|
||||
initGeoportalClient();
|
||||
|
||||
//devVRE
|
||||
// PROFILE_ID = "profiledConcessioni";
|
||||
// String tableName = "profiledconcessioni_devvre_centroids";
|
||||
// tableName = "profiledconcessioni_internal__devvre_centroids";
|
||||
// PROFILE_ID = "concessioni-estere";
|
||||
// String tableName = "concessioni_estere_devvre_centroids";
|
||||
// tableName = "concessioni_estere_internal__devvre_centroids";
|
||||
|
||||
// preVRE
|
||||
// PROFILE_ID = "profiledConcessioni";
|
||||
//String tableName = "profiledconcessioni_internal__prevre_centroids";
|
||||
// String tableName = "profiledconcessioni_prevre_centroids";
|
||||
// PROFILE_ID = "concessioni-estere";
|
||||
// String tableName = "concessioni_estere_internal__prevre_centroids";
|
||||
// tableName = "concessioni_estere_prevre_centroids";
|
||||
|
||||
// GNA
|
||||
// PROFILE_ID = "concessioni-estere";
|
||||
// String tableName = "concessioni_estere_internal__gna_centroids";
|
||||
// String tableName = "concessioni_estere_gna_centroids";
|
||||
// PROFILE_ID = "profiledConcessioni";
|
||||
// String tableName = "profiledconcessioni_internal__gna_centroids";
|
||||
// String tableName = "profiledconcessioni_gna_centroids";
|
||||
|
||||
|
||||
// Esquiline
|
||||
PROFILE_ID = "esquilino";
|
||||
String tableName = "esquilino_esquiline_centroids";
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
RuntimeResourceReader rrr = new RuntimeResourceReader(CONTEXT, resourceName, platformName, category, null);
|
||||
ServiceEndpointBean se = rrr.getListSE().get(0);
|
||||
AccessPoint ap = se.getListAP().get(0);
|
||||
|
||||
System.out.println(ap.address());
|
||||
System.out.println(ap.username());
|
||||
String pwdDB = RuntimeResourceReader.dectryptPassword(CONTEXT, ap);
|
||||
System.out.println(pwdDB);
|
||||
|
||||
Connection dbConnection = getDatabaseConnection(ap.address(), ap.username(), pwdDB);
|
||||
|
||||
// MUST BE DONE JUST ONCE
|
||||
try {
|
||||
boolean columnExists = checkColumnExists(dbConnection, tableName, TABLE_COLUMN_GEO_VIEWER_LINK);
|
||||
|
||||
if(!columnExists) {
|
||||
addColumnTable(dbConnection, tableName, TABLE_COLUMN_GEO_VIEWER_LINK, "TEXT");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> listProjectIdsIntoDB = readTableIDs(dbConnection, tableName, "projectid");
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
// List<ResultDocumentDV> listPublishedProjectsIntoService =
|
||||
// getListProjectsDVFiltered();
|
||||
|
||||
int counter = 1;
|
||||
UriResolverManager uriResolverManager = new UriResolverManager("GEO");
|
||||
for (String projectId : listProjectIdsIntoDB) {
|
||||
Project project = null;
|
||||
System.out.println("\n\n################ " + counter + " of " + listProjectIdsIntoDB.size()
|
||||
+ ") Reading the project id: " + projectId);
|
||||
try {
|
||||
project = client.getProjectByID(PROFILE_ID, projectId);
|
||||
} catch (Exception e) {
|
||||
System.err.println("Project id not found: " + projectId);
|
||||
}
|
||||
try {
|
||||
|
||||
if (project == null)
|
||||
continue;
|
||||
|
||||
System.out.println("\n###### Trying to update " + TABLE_COLUMN_GEO_VIEWER_LINK
|
||||
+ " column for project id: " + projectId);
|
||||
|
||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(false);
|
||||
ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder);
|
||||
//Geoportal Resolver QueryString Builder
|
||||
GeoportalResolverQueryStringBuilder builder = new GeoportalResolverQueryStringBuilder(projectDV.getProfileID(),projectId);
|
||||
builder.scope(CONTEXT);
|
||||
|
||||
if(tableName.contains("internal")) {
|
||||
builder.resolverAs(RESOLVE_AS.PRIVATE);
|
||||
}
|
||||
|
||||
Map<String, String> params = builder.buildQueryParameters();
|
||||
String shortLink = uriResolverManager.getLink(params, true);
|
||||
|
||||
LinkedHashMap<String, String> hashMap = new LinkedHashMap<String, String>();
|
||||
hashMap.put(TABLE_COLUMN_GEO_VIEWER_LINK, shortLink);
|
||||
updateTable(dbConnection, tableName, "projectId='" + projectId + "'", hashMap);
|
||||
System.out.println("###UPDATED project id: " + projectId);
|
||||
|
||||
Thread.sleep(500);
|
||||
System.out.println("################ Update completed for: " + projectId);
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error on updating the table for the project id: " + projectId);
|
||||
}
|
||||
|
||||
counter++;
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
long endTime = System.currentTimeMillis();
|
||||
System.out.println("\n\nSCRIPT END at: " + endTime);
|
||||
double toSec = (endTime - startTime) / 1000;
|
||||
System.out.println("SCRIPT TERMINATED in " + toSec + "sec");
|
||||
|
||||
}
|
||||
|
||||
public static List<ResultDocumentDV> getListProjectsDVFiltered() throws Exception {
|
||||
// List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
||||
|
||||
SearchingFilter filter = new SearchingFilter();
|
||||
|
||||
// Where Clause
|
||||
List<WhereClause> conditions = new ArrayList<WhereClause>();
|
||||
Map<String, Object> searchInto = new HashMap<String, Object>();
|
||||
searchInto.put("_lifecycleInformation._phase", "Published");
|
||||
WhereClause whereClause = new WhereClause(LOGICAL_OP.OR, searchInto);
|
||||
|
||||
conditions.add(whereClause);
|
||||
filter.setConditions(conditions);
|
||||
|
||||
LinkedHashMap<String, Object> projection = new LinkedHashMap<String, Object>();
|
||||
// default
|
||||
// PROJECTION
|
||||
String theDoc = Project.THE_DOCUMENT + ".";
|
||||
projection.put(Project.ID, 1);
|
||||
projection.put(theDoc + "nome", 1);
|
||||
projection.put(theDoc + JSON_KEY_DATA_INIZIO_PROGETTO, 1);
|
||||
projection.put(theDoc + JSON_KEY_DATA_FINE_PROGETTO, 1);
|
||||
|
||||
filter.setProjection(projection);
|
||||
|
||||
Integer totalDocs = client.getTotalDocument(PROFILE_ID);
|
||||
Iterator<Project> projects = client.queryOnMongo(PROFILE_ID, totalDocs, 0, null, filter);
|
||||
|
||||
List<ResultDocumentDV> results = ConvertToDataValueObjectModel.toListResultDocument(projects);
|
||||
int i = 0;
|
||||
for (ResultDocumentDV projectDV : results) {
|
||||
System.out.println(++i + ") " + projectDV.getId() + " " + JSON_KEY_DATA_INIZIO_PROGETTO + ": "
|
||||
+ projectDV.getDocumentAsMap().get(JSON_KEY_DATA_INIZIO_PROGETTO) + " "
|
||||
+ JSON_KEY_DATA_FINE_PROGETTO + ": " + projectDV.getDocumentAsMap().get(JSON_KEY_DATA_FINE_PROGETTO)
|
||||
+ " " + JSON_KEY_INTRODUZIONE + ": " + projectDV.getDocumentAsMap().get(JSON_KEY_INTRODUZIONE));
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the database connection.
|
||||
*
|
||||
* @param dbURL the db url
|
||||
* @param user the user
|
||||
* @param pwd the pwd
|
||||
* @return the database connection
|
||||
*/
|
||||
public static Connection getDatabaseConnection(String dbURL, String user, String pwd) {
|
||||
|
||||
System.out.println("dbURL: " + dbURL);
|
||||
Connection c = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
c = DriverManager.getConnection(dbURL, user, pwd);
|
||||
c.setAutoCommit(false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.err.println(e.getClass().getName() + ": " + e.getMessage());
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
System.out.println("Opened database successfully");
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public static void addColumnTable(Connection con, String tableName, String newColumn, String type)
|
||||
throws SQLException {
|
||||
|
||||
String alterTableString = String.format("ALTER TABLE %s ADD COLUMN %s %s", tableName, newColumn, type);
|
||||
|
||||
System.out.println("Executing: " + alterTableString);
|
||||
|
||||
try {
|
||||
con.setAutoCommit(false);
|
||||
if (!READ_ONLY_MODE) {
|
||||
con.createStatement().execute(alterTableString);
|
||||
con.commit();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
if (con != null) {
|
||||
try {
|
||||
System.err.print("Transaction is being rolled back");
|
||||
con.rollback();
|
||||
} catch (SQLException excep) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Executed: " + alterTableString);
|
||||
}
|
||||
|
||||
public static Boolean checkColumnExists(Connection con, String tableName, String columnName) throws SQLException {
|
||||
|
||||
String columnExistsLabel = "COLUMN_EXISTS";
|
||||
|
||||
String sql = String.format(
|
||||
"SELECT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name='%s' AND column_name='%s') as %s",
|
||||
tableName, columnName, columnExistsLabel);
|
||||
|
||||
System.out.println("Executing: " + sql);
|
||||
|
||||
PreparedStatement p;
|
||||
ResultSet resultSet;
|
||||
try {
|
||||
|
||||
p = con.prepareStatement(sql);
|
||||
resultSet = p.executeQuery();
|
||||
// Expected 1 row
|
||||
resultSet.next();
|
||||
Boolean columnExists = resultSet.getBoolean(columnExistsLabel);
|
||||
System.out.println("\n####Column exists: " + columnExists + "\n");
|
||||
return columnExists;
|
||||
|
||||
} catch (SQLException e) {
|
||||
System.err.println(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateTable(Connection con, String tableName, String whereCondition,
|
||||
LinkedHashMap<String, String> mapColumnValue) throws SQLException {
|
||||
|
||||
StringBuilder updateSQL = new StringBuilder();
|
||||
updateSQL.append("UPDATE " + tableName + " SET");
|
||||
|
||||
int i = 1;
|
||||
for (String column : mapColumnValue.keySet()) {
|
||||
updateSQL.append(" " + column + "=?");
|
||||
if (i < mapColumnValue.size())
|
||||
updateSQL.append(", ");
|
||||
i++;
|
||||
}
|
||||
|
||||
updateSQL.append(" WHERE " + whereCondition);
|
||||
|
||||
String update = updateSQL.toString();
|
||||
|
||||
// System.out.println("Executing: " + update);
|
||||
try (PreparedStatement updatePS = con.prepareStatement(update);) {
|
||||
int index = 1;
|
||||
for (String column : mapColumnValue.keySet()) {
|
||||
updatePS.setString(index, mapColumnValue.get(column));
|
||||
index++;
|
||||
}
|
||||
con.setAutoCommit(false);
|
||||
|
||||
System.out.println("Executing: " + updatePS.toString());
|
||||
if (!READ_ONLY_MODE) {
|
||||
updatePS.executeUpdate();
|
||||
con.commit();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
if (con != null) {
|
||||
try {
|
||||
System.err.print("Transaction is being rolled back");
|
||||
con.rollback();
|
||||
} catch (SQLException excep) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Step1: Main driver method
|
||||
public static List<String> readTableIDs(Connection con, String tableName, String columnNameProjectId) {
|
||||
PreparedStatement p = null;
|
||||
ResultSet resultSet = null;
|
||||
|
||||
// Try block to catch exception/s
|
||||
List<String> listProjectIds = new ArrayList<String>();
|
||||
try {
|
||||
|
||||
// SQL command data stored in String datatype
|
||||
String sql = String.format("SELECT * FROM %s", tableName);
|
||||
p = con.prepareStatement(sql);
|
||||
resultSet = p.executeQuery();
|
||||
|
||||
ResultSetMetaData rsmd = resultSet.getMetaData();
|
||||
int columnsNumber = rsmd.getColumnCount();
|
||||
int row = 1;
|
||||
System.out.println("\n####TABLE: " + tableName + " content..\n");
|
||||
while (resultSet.next()) {
|
||||
System.out.print("" + row + "] ");
|
||||
for (int i = 1; i <= columnsNumber; i++) {
|
||||
String columnValue = resultSet.getString(i);
|
||||
System.out.print("(" + rsmd.getColumnName(i) + ") " + columnValue + " | ");
|
||||
}
|
||||
row++;
|
||||
System.out.println("\n");
|
||||
|
||||
String projectId = resultSet.getString(columnNameProjectId);
|
||||
listProjectIds.add(projectId);
|
||||
}
|
||||
System.out.println("####TABLE: " + tableName + " end content\n");
|
||||
}
|
||||
|
||||
// Catch block to handle exception
|
||||
catch (SQLException e) {
|
||||
|
||||
// Print exception pop-up on screen
|
||||
System.err.println(e);
|
||||
}
|
||||
|
||||
System.out.println("returning list IDs: " + listProjectIds);
|
||||
return listProjectIds;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,538 @@
|
|||
package org.gcube.application;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
||||
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
||||
import org.gcube.application.se.RuntimeResourceReader;
|
||||
import org.gcube.application.se.ServiceEndpointBean;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
public class GNA_New_DataModel_IndexTable_25925 {
|
||||
|
||||
private static String PROFILE_ID = "profiledConcessioni";
|
||||
|
||||
private static final String platformName = "postgis";
|
||||
private static final String category = "Database";
|
||||
|
||||
// These are defined via ContextConfigTest.readContextSettings();
|
||||
private static String CONTEXT = "";
|
||||
private static String TOKEN = "";
|
||||
|
||||
// #### DEV
|
||||
// DB
|
||||
// private static final String resourceName = "GNA-POSTGIS-DB"; // devVRE
|
||||
|
||||
// #### PRE
|
||||
// DB
|
||||
private static final String resourceName = "Geoserver-t postgis"; // preVRE
|
||||
|
||||
// #### PROD
|
||||
// DB
|
||||
// private static final String resourceName = "GNA-postgis"; // GNA
|
||||
|
||||
// Esquiline
|
||||
// private static final String CONTEXT = "/d4science.research-infrastructures.eu/gCubeApps/Esquiline";
|
||||
// private static final String TOKEN = ""; //Esquiline
|
||||
// private static String PROFILE_ID = "esquilino";
|
||||
|
||||
// GEOPORTAL
|
||||
// private static String PROFILE_ID = "profiledConcessioni";
|
||||
// private static final String PROFILE_ID = "concessioni-estere";
|
||||
|
||||
private static final Map<String, String> ADD_TABLE_COLUMNS = new LinkedHashMap<>();
|
||||
// static {
|
||||
// ADD_TABLE_COLUMNS.put("ufficio_mic_competente", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("funzionario_responsabile", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("modalita_individuazione", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("contesto_indagine", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("denominazione", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("stato_attuale", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("accessibilita", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("cronologia_macrofase", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("specifiche_cronologia", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("quota_max", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("quota_min", "TEXT");
|
||||
// }
|
||||
|
||||
private static final Map<String, String> DROP_TABLE_COLUMNS = new HashMap<>();
|
||||
// static {
|
||||
// DROP_TABLE_COLUMNS.put("autore", "");
|
||||
// DROP_TABLE_COLUMNS.put("titolare", "");
|
||||
// DROP_TABLE_COLUMNS.put("titolare_licenza", "");
|
||||
// }
|
||||
|
||||
private static final Map<String, String> RENAME_TABLE_COLUMNS = new HashMap<>();
|
||||
//Rename from column to column
|
||||
// static {
|
||||
// RENAME_TABLE_COLUMNS.put("ufficio_mic_competente", "ufficio_competente");
|
||||
// }
|
||||
|
||||
private static ProjectsCaller client = null;
|
||||
|
||||
public static final boolean READ_ONLY_MODE = true;
|
||||
|
||||
public static List<String> listTable = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Gets the client.
|
||||
*
|
||||
* @return the client
|
||||
*/
|
||||
// @Before
|
||||
public static void initGeoportalClient() {
|
||||
// assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
ContextConfigTest.readContextSettings();
|
||||
CONTEXT = ContextConfigTest.CONTEXT;
|
||||
TOKEN = ContextConfigTest.TOKEN;
|
||||
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
client = GeoportalClientCaller.projects();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
initGeoportalClient();
|
||||
|
||||
System.out.println("READ_ONLY_MODE ENABLED: " + READ_ONLY_MODE);
|
||||
System.out.println("CONTEXT IS: " + CONTEXT);
|
||||
System.out.println("PROFILE_ID: " + PROFILE_ID);
|
||||
|
||||
// devVRE
|
||||
// PROFILE_ID = "profiledConcessioni";
|
||||
// String tableName = "profiledconcessioni_devvre_centroids";
|
||||
// tableName = "profiledconcessioni_internal__devvre_centroids";
|
||||
// PROFILE_ID = "concessioni-estere";
|
||||
// String tableName = "concessioni_estere_devvre_centroids";
|
||||
// tableName = "concessioni_estere_internal__devvre_centroids";
|
||||
|
||||
// preVRE
|
||||
// PROFILE_ID = "profiledConcessioni";
|
||||
// listTable.add("profiledconcessioni_internal__prevre_centroids");
|
||||
// listTable.add("profiledconcessioni_prevre_centroids");
|
||||
PROFILE_ID = "concessioni-estere";
|
||||
listTable.add("concessioni_estere_internal__prevre_centroids");
|
||||
listTable.add("concessioni_estere_prevre_centroids");
|
||||
|
||||
// GNA
|
||||
// PROFILE_ID = "concessioni-estere";
|
||||
// String tableName = "concessioni_estere_internal__gna_centroids";
|
||||
// String tableName = "concessioni_estere_gna_centroids";
|
||||
// PROFILE_ID = "profiledConcessioni";
|
||||
// String tableName = "profiledconcessioni_internal__gna_centroids";
|
||||
// String tableName = "profiledconcessioni_gna_centroids";
|
||||
|
||||
// Esquiline
|
||||
// PROFILE_ID = "esquilino";
|
||||
// String tableName = "esquilino_esquiline_centroids";
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
RuntimeResourceReader rrr = new RuntimeResourceReader(CONTEXT, resourceName, platformName, category, null);
|
||||
ServiceEndpointBean se = rrr.getListSE().get(0);
|
||||
AccessPoint ap = se.getListAP().get(0);
|
||||
|
||||
System.out.println(ap.address());
|
||||
System.out.println(ap.username());
|
||||
String pwdDB = RuntimeResourceReader.dectryptPassword(CONTEXT, ap);
|
||||
System.out.println(pwdDB);
|
||||
|
||||
Connection dbConnection = getDatabaseConnection(ap.address(), ap.username(), pwdDB);
|
||||
|
||||
for (String tableName : listTable) {
|
||||
|
||||
System.out.println("\n\n# SOURCE TABLE");
|
||||
Boolean tableExists = checkTableExists(dbConnection, tableName);
|
||||
|
||||
if (!tableExists) {
|
||||
throw new Exception("Table '" + tableName + "' does not exits in the DB!!! Exit");
|
||||
}
|
||||
|
||||
printTableColumn(dbConnection, tableName);
|
||||
|
||||
System.out.println("\n\n### ADDING COLUMNS...\n");
|
||||
|
||||
// ADD NEW COLUMNS
|
||||
for (String columnName : ADD_TABLE_COLUMNS.keySet()) {
|
||||
try {
|
||||
|
||||
boolean columnExists = checkColumnExists(dbConnection, tableName, columnName);
|
||||
|
||||
if (!columnExists) {
|
||||
addColumnTable(dbConnection, tableName, columnName, ADD_TABLE_COLUMNS.get(columnName));
|
||||
int sleeping = 500;
|
||||
System.out.println("... sleeping " + sleeping + " ...");
|
||||
Thread.sleep(sleeping);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("\n\n### END ADD COLUMNS");
|
||||
|
||||
System.out.println("\n\n### DROPPING COLUMNS...\n");
|
||||
|
||||
// REMOVE OLD COLUMNS
|
||||
for (String columnName : DROP_TABLE_COLUMNS.keySet()) {
|
||||
try {
|
||||
|
||||
boolean columnExists = checkColumnExists(dbConnection, tableName, columnName);
|
||||
|
||||
if (columnExists) {
|
||||
dropColumnTable(dbConnection, tableName, columnName, DROP_TABLE_COLUMNS.get(columnName));
|
||||
int sleeping = 1000;
|
||||
System.out.println("... sleeping " + sleeping + " ...");
|
||||
Thread.sleep(sleeping);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("\n\n### END DROP COLUMNS");
|
||||
|
||||
System.out.println("\n\n### RENAMING COLUMNS...\n");
|
||||
// RENAME_TABLE_COLUMNS
|
||||
for (String columnName : RENAME_TABLE_COLUMNS.keySet()) {
|
||||
try {
|
||||
|
||||
boolean columnExists = checkColumnExists(dbConnection, tableName, columnName);
|
||||
|
||||
if (columnExists) {
|
||||
renameColumnTable(dbConnection, tableName, columnName, RENAME_TABLE_COLUMNS.get(columnName));
|
||||
int sleeping = 1000;
|
||||
System.out.println("... sleeping " + sleeping + " ...");
|
||||
Thread.sleep(sleeping);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("\n\n### END RENAME COLUMNS");
|
||||
|
||||
System.out.println("\n\n# UPDATED TABLE");
|
||||
printTableColumn(dbConnection, tableName);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
long endTime = System.currentTimeMillis();
|
||||
System.out.println("\n\nSCRIPT END at: " + endTime);
|
||||
double toSec = (endTime - startTime) / 1000;
|
||||
System.out.println("SCRIPT TERMINATED in " + toSec + "sec");
|
||||
|
||||
}
|
||||
|
||||
public static void printTableColumn(Connection con, String tablename) {
|
||||
|
||||
try {
|
||||
DatabaseMetaData databaseMetaData = con.getMetaData();
|
||||
// Print TABLE_TYPE "TABLE"
|
||||
ResultSet columns = databaseMetaData.getColumns(null, null, tablename, null);
|
||||
System.out.println("\n==== TABLE " + tablename + " ");
|
||||
System.out.println("[COLUMN_NAME - TYPE_NAME ( COLUMN_SIZE )]");
|
||||
System.out.println("-----------------------------------------------");
|
||||
while (columns.next()) {
|
||||
String columnName = columns.getString("COLUMN_NAME");
|
||||
String columnType = columns.getString("TYPE_NAME");
|
||||
int columnSize = columns.getInt("COLUMN_SIZE");
|
||||
System.out.println("\t" + columnName + " - " + columnType + " (" + columnSize + ")");
|
||||
}
|
||||
System.out.println("-----------------------------------------------");
|
||||
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the database connection.
|
||||
*
|
||||
* @param dbURL the db url
|
||||
* @param user the user
|
||||
* @param pwd the pwd
|
||||
* @return the database connection
|
||||
*/
|
||||
public static Connection getDatabaseConnection(String dbURL, String user, String pwd) {
|
||||
|
||||
System.out.println("dbURL: " + dbURL);
|
||||
Connection c = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
c = DriverManager.getConnection(dbURL, user, pwd);
|
||||
c.setAutoCommit(false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.err.println(e.getClass().getName() + ": " + e.getMessage());
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
System.out.println("Opened database successfully");
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public static void addColumnTable(Connection con, String tableName, String newColumn, String type)
|
||||
throws SQLException {
|
||||
|
||||
String alterTableString = String.format("ALTER TABLE %s ADD COLUMN %s %s", tableName, newColumn, type);
|
||||
|
||||
System.out.println("Executing: " + alterTableString);
|
||||
|
||||
try {
|
||||
con.setAutoCommit(false);
|
||||
if (!READ_ONLY_MODE) {
|
||||
con.createStatement().execute(alterTableString);
|
||||
con.commit();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
if (con != null) {
|
||||
try {
|
||||
System.err.print("Transaction is being rolled back");
|
||||
con.rollback();
|
||||
} catch (SQLException excep) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Executed: " + alterTableString);
|
||||
}
|
||||
|
||||
public static void renameColumnTable(Connection con, String tableName, String oldColumn, String newColumn)
|
||||
throws SQLException {
|
||||
|
||||
String alterTableString = String.format("ALTER TABLE %s RENAME COLUMN %s TO %s", tableName, oldColumn,
|
||||
newColumn);
|
||||
|
||||
System.out.println("Executing: " + alterTableString);
|
||||
|
||||
try {
|
||||
con.setAutoCommit(false);
|
||||
if (!READ_ONLY_MODE) {
|
||||
con.createStatement().execute(alterTableString);
|
||||
con.commit();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
if (con != null) {
|
||||
try {
|
||||
System.err.print("Transaction is being rolled back");
|
||||
con.rollback();
|
||||
} catch (SQLException excep) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Executed: " + alterTableString);
|
||||
}
|
||||
|
||||
public static void dropColumnTable(Connection con, String tableName, String oldColumn, String type)
|
||||
throws SQLException {
|
||||
|
||||
String alterTableString = String.format("ALTER TABLE %s DROP COLUMN %s", tableName, oldColumn);
|
||||
|
||||
System.out.println("Executing: " + alterTableString);
|
||||
|
||||
try {
|
||||
con.setAutoCommit(false);
|
||||
if (!READ_ONLY_MODE) {
|
||||
con.createStatement().execute(alterTableString);
|
||||
con.commit();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
if (con != null) {
|
||||
try {
|
||||
System.err.print("Transaction is being rolled back");
|
||||
con.rollback();
|
||||
} catch (SQLException excep) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Executed: " + alterTableString);
|
||||
}
|
||||
|
||||
public static Boolean checkColumnExists(Connection con, String tableName, String columnName) throws SQLException {
|
||||
|
||||
String columnExistsLabel = "COLUMN_EXISTS";
|
||||
|
||||
String sql = String.format(
|
||||
"SELECT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name='%s' AND column_name='%s') as %s",
|
||||
tableName, columnName, columnExistsLabel);
|
||||
|
||||
System.out.println("\n+++ " + columnExistsLabel + " checking '" + tableName + "': " + sql);
|
||||
|
||||
PreparedStatement p;
|
||||
ResultSet resultSet;
|
||||
try {
|
||||
|
||||
p = con.prepareStatement(sql);
|
||||
resultSet = p.executeQuery();
|
||||
// Expected 1 row
|
||||
resultSet.next();
|
||||
Boolean columnExists = resultSet.getBoolean(columnExistsLabel);
|
||||
System.out.println("\t RESP --> Column '" + columnName + "' exists: " + columnExists + "\n");
|
||||
return columnExists;
|
||||
|
||||
} catch (SQLException e) {
|
||||
System.err.println(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean checkTableExists(Connection con, String tableName) throws SQLException {
|
||||
|
||||
String tableExistsLabel = "TABLE_EXISTS";
|
||||
|
||||
String sql = String.format(
|
||||
"SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name='%s' AND table_type LIKE 'BASE TABLE' AND table_schema LIKE 'public') as %s",
|
||||
tableName, tableExistsLabel);
|
||||
|
||||
System.out.println("\n+++ " + tableExistsLabel + " checking '" + tableName + "': " + sql);
|
||||
|
||||
PreparedStatement p;
|
||||
ResultSet resultSet;
|
||||
try {
|
||||
|
||||
p = con.prepareStatement(sql);
|
||||
resultSet = p.executeQuery();
|
||||
// Expected 1 row
|
||||
resultSet.next();
|
||||
Boolean tableExists = resultSet.getBoolean(tableExistsLabel);
|
||||
System.out.println("\t RESP --> Table '" + tableName + "' exists: " + tableExists + "\n");
|
||||
return tableExists;
|
||||
|
||||
} catch (SQLException e) {
|
||||
System.err.println(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateTable(Connection con, String tableName, String whereCondition,
|
||||
LinkedHashMap<String, String> mapColumnValue) throws SQLException {
|
||||
|
||||
StringBuilder updateSQL = new StringBuilder();
|
||||
updateSQL.append("UPDATE " + tableName + " SET");
|
||||
|
||||
int i = 1;
|
||||
for (String column : mapColumnValue.keySet()) {
|
||||
updateSQL.append(" " + column + "=?");
|
||||
if (i < mapColumnValue.size())
|
||||
updateSQL.append(", ");
|
||||
i++;
|
||||
}
|
||||
|
||||
updateSQL.append(" WHERE " + whereCondition);
|
||||
|
||||
String update = updateSQL.toString();
|
||||
|
||||
// System.out.println("Executing: " + update);
|
||||
try (PreparedStatement updatePS = con.prepareStatement(update);) {
|
||||
int index = 1;
|
||||
for (String column : mapColumnValue.keySet()) {
|
||||
updatePS.setString(index, mapColumnValue.get(column));
|
||||
index++;
|
||||
}
|
||||
con.setAutoCommit(false);
|
||||
|
||||
System.out.println("Executing: " + updatePS.toString());
|
||||
if (!READ_ONLY_MODE) {
|
||||
updatePS.executeUpdate();
|
||||
con.commit();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
if (con != null) {
|
||||
try {
|
||||
System.err.print("Transaction is being rolled back");
|
||||
con.rollback();
|
||||
} catch (SQLException excep) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Step1: Main driver method
|
||||
public static List<String> readTableIDs(Connection con, String tableName, String columnNameProjectId) {
|
||||
PreparedStatement p = null;
|
||||
ResultSet resultSet = null;
|
||||
|
||||
// Try block to catch exception/s
|
||||
List<String> listProjectIds = new ArrayList<String>();
|
||||
try {
|
||||
|
||||
// SQL command data stored in String datatype
|
||||
String sql = String.format("SELECT * FROM %s", tableName);
|
||||
p = con.prepareStatement(sql);
|
||||
resultSet = p.executeQuery();
|
||||
|
||||
ResultSetMetaData rsmd = resultSet.getMetaData();
|
||||
int columnsNumber = rsmd.getColumnCount();
|
||||
int row = 1;
|
||||
System.out.println("\n####TABLE: " + tableName + " content..\n");
|
||||
while (resultSet.next()) {
|
||||
System.out.print("" + row + "] ");
|
||||
for (int i = 1; i <= columnsNumber; i++) {
|
||||
String columnValue = resultSet.getString(i);
|
||||
System.out.print("(" + rsmd.getColumnName(i) + ") " + columnValue + " | ");
|
||||
}
|
||||
row++;
|
||||
System.out.println("\n");
|
||||
|
||||
String projectId = resultSet.getString(columnNameProjectId);
|
||||
listProjectIds.add(projectId);
|
||||
}
|
||||
System.out.println("####TABLE: " + tableName + " end content\n");
|
||||
}
|
||||
|
||||
// Catch block to handle exception
|
||||
catch (SQLException e) {
|
||||
|
||||
// Print exception pop-up on screen
|
||||
System.err.println(e);
|
||||
}
|
||||
|
||||
System.out.println("returning list IDs: " + listProjectIds);
|
||||
return listProjectIds;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,511 @@
|
|||
package org.gcube.application;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
||||
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
||||
import org.gcube.application.se.RuntimeResourceReader;
|
||||
import org.gcube.application.se.ServiceEndpointBean;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
public class GNA_New_DataModel_IndexTable_PROD_25926 {
|
||||
|
||||
private static String PROFILE_ID = "profiledConcessioni";
|
||||
|
||||
private static final String platformName = "postgis";
|
||||
private static final String category = "Database";
|
||||
|
||||
// These are defined via ContextConfigTest.readContextSettings();
|
||||
private static String CONTEXT = "";
|
||||
private static String TOKEN = "";
|
||||
|
||||
// #### PROD
|
||||
// DB
|
||||
private static final String resourceName = "GNA-postgis"; // GNA
|
||||
|
||||
// Esquiline
|
||||
// private static final String CONTEXT = "/d4science.research-infrastructures.eu/gCubeApps/Esquiline";
|
||||
// private static final String TOKEN = ""; //Esquiline
|
||||
// private static String PROFILE_ID = "esquilino";
|
||||
|
||||
private static final Map<String, String> ADD_TABLE_COLUMNS = new LinkedHashMap<>();
|
||||
// static {
|
||||
// ADD_TABLE_COLUMNS.put("ufficio_mic_competente", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("funzionario_responsabile", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("modalita_individuazione", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("contesto_indagine", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("denominazione", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("stato_attuale", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("accessibilita", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("cronologia_macrofase", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("specifiche_cronologia", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("quota_max", "TEXT");
|
||||
// ADD_TABLE_COLUMNS.put("quota_min", "TEXT");
|
||||
// }
|
||||
//
|
||||
private static final Map<String, String> DROP_TABLE_COLUMNS = new HashMap<>();
|
||||
// static {
|
||||
// DROP_TABLE_COLUMNS.put("autore", "");
|
||||
// DROP_TABLE_COLUMNS.put("titolare", "");
|
||||
// DROP_TABLE_COLUMNS.put("titolare_licenza", "");
|
||||
// }
|
||||
|
||||
private static final Map<String, String> RENAME_TABLE_COLUMNS = new HashMap<>();
|
||||
// Rename from column to column
|
||||
static {
|
||||
RENAME_TABLE_COLUMNS.put("ufficio_mic_competente", "ufficio_competente");
|
||||
}
|
||||
|
||||
private static ProjectsCaller client = null;
|
||||
|
||||
public static final boolean READ_ONLY_MODE = true;
|
||||
|
||||
public static List<String> listTable = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Gets the client.
|
||||
*
|
||||
* @return the client
|
||||
*/
|
||||
// @Before
|
||||
public static void initGeoportalClient() {
|
||||
// assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
ContextConfigTest.readContextSettings();
|
||||
CONTEXT = ContextConfigTest.CONTEXT;
|
||||
TOKEN = ContextConfigTest.TOKEN;
|
||||
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
client = GeoportalClientCaller.projects();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
initGeoportalClient();
|
||||
|
||||
System.out.println("READ_ONLY_MODE ENABLED: " + READ_ONLY_MODE);
|
||||
System.out.println("CONTEXT IS: " + CONTEXT);
|
||||
System.out.println("PROFILE_ID: " + PROFILE_ID);
|
||||
|
||||
// GNA
|
||||
// PROFILE_ID = "profiledConcessioni";
|
||||
// listTable.add("profiledconcessioni_internal__gna_centroids");
|
||||
// listTable.add("profiledconcessioni_gna_centroids");
|
||||
// PROFILE_ID = "concessioni-estere";
|
||||
// listTable.add("concessioni_estere_internal__gna_centroids");
|
||||
// listTable.add("concessioni_estere_gna_centroids");
|
||||
|
||||
// Esquiline
|
||||
// PROFILE_ID = "esquilino";
|
||||
// String tableName = "esquilino_esquiline_centroids";
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
RuntimeResourceReader rrr = new RuntimeResourceReader(CONTEXT, resourceName, platformName, category, null);
|
||||
ServiceEndpointBean se = rrr.getListSE().get(0);
|
||||
AccessPoint ap = se.getListAP().get(0);
|
||||
|
||||
System.out.println(ap.address());
|
||||
System.out.println(ap.username());
|
||||
String pwdDB = RuntimeResourceReader.dectryptPassword(CONTEXT, ap);
|
||||
System.out.println(pwdDB);
|
||||
|
||||
Connection dbConnection = getDatabaseConnection(ap.address(), ap.username(), pwdDB);
|
||||
|
||||
for (String tableName : listTable) {
|
||||
|
||||
System.out.println("\n\n# SOURCE TABLE");
|
||||
Boolean tableExists = checkTableExists(dbConnection, tableName);
|
||||
|
||||
if (!tableExists) {
|
||||
throw new Exception("Table '" + tableName + "' does not exits in the DB!!! Exit");
|
||||
}
|
||||
|
||||
printTableColumn(dbConnection, tableName);
|
||||
|
||||
System.out.println("\n\n### ADDING COLUMNS...\n");
|
||||
|
||||
// ADD NEW COLUMNS
|
||||
for (String columnName : ADD_TABLE_COLUMNS.keySet()) {
|
||||
try {
|
||||
|
||||
boolean columnExists = checkColumnExists(dbConnection, tableName, columnName);
|
||||
|
||||
if (!columnExists) {
|
||||
addColumnTable(dbConnection, tableName, columnName, ADD_TABLE_COLUMNS.get(columnName));
|
||||
int sleeping = 500;
|
||||
System.out.println("... sleeping " + sleeping + " ...");
|
||||
Thread.sleep(sleeping);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("\n\n### END ADD COLUMNS");
|
||||
|
||||
System.out.println("\n\n### DROPPING COLUMNS...\n");
|
||||
|
||||
// REMOVE OLD COLUMNS
|
||||
for (String columnName : DROP_TABLE_COLUMNS.keySet()) {
|
||||
try {
|
||||
|
||||
boolean columnExists = checkColumnExists(dbConnection, tableName, columnName);
|
||||
|
||||
if (columnExists) {
|
||||
dropColumnTable(dbConnection, tableName, columnName, DROP_TABLE_COLUMNS.get(columnName));
|
||||
int sleeping = 1000;
|
||||
System.out.println("... sleeping " + sleeping + " ...");
|
||||
Thread.sleep(sleeping);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("\n\n### END DROP COLUMNS");
|
||||
|
||||
System.out.println("\n\n### RENAMING COLUMNS...\n");
|
||||
// RENAME_TABLE_COLUMNS
|
||||
for (String columnName : RENAME_TABLE_COLUMNS.keySet()) {
|
||||
try {
|
||||
|
||||
boolean columnExists = checkColumnExists(dbConnection, tableName, columnName);
|
||||
|
||||
if (columnExists) {
|
||||
renameColumnTable(dbConnection, tableName, columnName,
|
||||
RENAME_TABLE_COLUMNS.get(columnName));
|
||||
int sleeping = 1000;
|
||||
System.out.println("... sleeping " + sleeping + " ...");
|
||||
Thread.sleep(sleeping);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("\n\n### END RENAME COLUMNS");
|
||||
|
||||
System.out.println("\n\n# UPDATED TABLE");
|
||||
printTableColumn(dbConnection, tableName);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
long endTime = System.currentTimeMillis();
|
||||
System.out.println("\n\nSCRIPT END at: " + endTime);
|
||||
double toSec = (endTime - startTime) / 1000;
|
||||
System.out.println("SCRIPT TERMINATED in " + toSec + "sec");
|
||||
|
||||
}
|
||||
|
||||
public static void printTableColumn(Connection con, String tablename) {
|
||||
|
||||
try {
|
||||
DatabaseMetaData databaseMetaData = con.getMetaData();
|
||||
// Print TABLE_TYPE "TABLE"
|
||||
ResultSet columns = databaseMetaData.getColumns(null, null, tablename, null);
|
||||
System.out.println("\n==== TABLE " + tablename + " ");
|
||||
System.out.println("[COLUMN_NAME - TYPE_NAME ( COLUMN_SIZE )]");
|
||||
System.out.println("-----------------------------------------------");
|
||||
while (columns.next()) {
|
||||
String columnName = columns.getString("COLUMN_NAME");
|
||||
String columnType = columns.getString("TYPE_NAME");
|
||||
int columnSize = columns.getInt("COLUMN_SIZE");
|
||||
System.out.println("\t" + columnName + " - " + columnType + " (" + columnSize + ")");
|
||||
}
|
||||
System.out.println("-----------------------------------------------");
|
||||
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the database connection.
|
||||
*
|
||||
* @param dbURL the db url
|
||||
* @param user the user
|
||||
* @param pwd the pwd
|
||||
* @return the database connection
|
||||
*/
|
||||
public static Connection getDatabaseConnection(String dbURL, String user, String pwd) {
|
||||
|
||||
System.out.println("dbURL: " + dbURL);
|
||||
Connection c = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
c = DriverManager.getConnection(dbURL, user, pwd);
|
||||
c.setAutoCommit(false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.err.println(e.getClass().getName() + ": " + e.getMessage());
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
System.out.println("Opened database successfully");
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public static void addColumnTable(Connection con, String tableName, String newColumn, String type)
|
||||
throws SQLException {
|
||||
|
||||
String alterTableString = String.format("ALTER TABLE %s ADD COLUMN %s %s", tableName, newColumn, type);
|
||||
|
||||
System.out.println("Executing: " + alterTableString);
|
||||
|
||||
try {
|
||||
con.setAutoCommit(false);
|
||||
if (!READ_ONLY_MODE) {
|
||||
con.createStatement().execute(alterTableString);
|
||||
con.commit();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
if (con != null) {
|
||||
try {
|
||||
System.err.print("Transaction is being rolled back");
|
||||
con.rollback();
|
||||
} catch (SQLException excep) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Executed: " + alterTableString);
|
||||
}
|
||||
|
||||
public static void renameColumnTable(Connection con, String tableName, String oldColumn, String newColumn)
|
||||
throws SQLException {
|
||||
|
||||
String alterTableString = String.format("ALTER TABLE %s RENAME COLUMN %s TO %s", tableName, oldColumn,
|
||||
newColumn);
|
||||
|
||||
System.out.println("Executing: " + alterTableString);
|
||||
|
||||
try {
|
||||
con.setAutoCommit(false);
|
||||
if (!READ_ONLY_MODE) {
|
||||
con.createStatement().execute(alterTableString);
|
||||
con.commit();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
if (con != null) {
|
||||
try {
|
||||
System.err.print("Transaction is being rolled back");
|
||||
con.rollback();
|
||||
} catch (SQLException excep) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Executed: " + alterTableString);
|
||||
}
|
||||
|
||||
public static void dropColumnTable(Connection con, String tableName, String oldColumn, String type)
|
||||
throws SQLException {
|
||||
|
||||
String alterTableString = String.format("ALTER TABLE %s DROP COLUMN %s", tableName, oldColumn);
|
||||
|
||||
System.out.println("Executing: " + alterTableString);
|
||||
|
||||
try {
|
||||
con.setAutoCommit(false);
|
||||
if (!READ_ONLY_MODE) {
|
||||
con.createStatement().execute(alterTableString);
|
||||
con.commit();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
if (con != null) {
|
||||
try {
|
||||
System.err.print("Transaction is being rolled back");
|
||||
con.rollback();
|
||||
} catch (SQLException excep) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Executed: " + alterTableString);
|
||||
}
|
||||
|
||||
public static Boolean checkColumnExists(Connection con, String tableName, String columnName) throws SQLException {
|
||||
|
||||
String columnExistsLabel = "COLUMN_EXISTS";
|
||||
|
||||
String sql = String.format(
|
||||
"SELECT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name='%s' AND column_name='%s') as %s",
|
||||
tableName, columnName, columnExistsLabel);
|
||||
|
||||
System.out.println("\n+++ " + columnExistsLabel + " checking '" + tableName + "': " + sql);
|
||||
|
||||
PreparedStatement p;
|
||||
ResultSet resultSet;
|
||||
try {
|
||||
|
||||
p = con.prepareStatement(sql);
|
||||
resultSet = p.executeQuery();
|
||||
// Expected 1 row
|
||||
resultSet.next();
|
||||
Boolean columnExists = resultSet.getBoolean(columnExistsLabel);
|
||||
System.out.println("\t RESP --> Column '" + columnName + "' exists: " + columnExists + "\n");
|
||||
return columnExists;
|
||||
|
||||
} catch (SQLException e) {
|
||||
System.err.println(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean checkTableExists(Connection con, String tableName) throws SQLException {
|
||||
|
||||
String tableExistsLabel = "TABLE_EXISTS";
|
||||
|
||||
String sql = String.format(
|
||||
"SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name='%s' AND table_type LIKE 'BASE TABLE' AND table_schema LIKE 'public') as %s",
|
||||
tableName, tableExistsLabel);
|
||||
|
||||
System.out.println("\n+++ " + tableExistsLabel + " checking '" + tableName + "': " + sql);
|
||||
|
||||
PreparedStatement p;
|
||||
ResultSet resultSet;
|
||||
try {
|
||||
|
||||
p = con.prepareStatement(sql);
|
||||
resultSet = p.executeQuery();
|
||||
// Expected 1 row
|
||||
resultSet.next();
|
||||
Boolean tableExists = resultSet.getBoolean(tableExistsLabel);
|
||||
System.out.println("\t RESP --> Table '" + tableName + "' exists: " + tableExists + "\n");
|
||||
return tableExists;
|
||||
|
||||
} catch (SQLException e) {
|
||||
System.err.println(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateTable(Connection con, String tableName, String whereCondition,
|
||||
LinkedHashMap<String, String> mapColumnValue) throws SQLException {
|
||||
|
||||
StringBuilder updateSQL = new StringBuilder();
|
||||
updateSQL.append("UPDATE " + tableName + " SET");
|
||||
|
||||
int i = 1;
|
||||
for (String column : mapColumnValue.keySet()) {
|
||||
updateSQL.append(" " + column + "=?");
|
||||
if (i < mapColumnValue.size())
|
||||
updateSQL.append(", ");
|
||||
i++;
|
||||
}
|
||||
|
||||
updateSQL.append(" WHERE " + whereCondition);
|
||||
|
||||
String update = updateSQL.toString();
|
||||
|
||||
// System.out.println("Executing: " + update);
|
||||
try (PreparedStatement updatePS = con.prepareStatement(update);) {
|
||||
int index = 1;
|
||||
for (String column : mapColumnValue.keySet()) {
|
||||
updatePS.setString(index, mapColumnValue.get(column));
|
||||
index++;
|
||||
}
|
||||
con.setAutoCommit(false);
|
||||
|
||||
System.out.println("Executing: " + updatePS.toString());
|
||||
if (!READ_ONLY_MODE) {
|
||||
updatePS.executeUpdate();
|
||||
con.commit();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
if (con != null) {
|
||||
try {
|
||||
System.err.print("Transaction is being rolled back");
|
||||
con.rollback();
|
||||
} catch (SQLException excep) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Step1: Main driver method
|
||||
public static List<String> readTableIDs(Connection con, String tableName, String columnNameProjectId) {
|
||||
PreparedStatement p = null;
|
||||
ResultSet resultSet = null;
|
||||
|
||||
// Try block to catch exception/s
|
||||
List<String> listProjectIds = new ArrayList<String>();
|
||||
try {
|
||||
|
||||
// SQL command data stored in String datatype
|
||||
String sql = String.format("SELECT * FROM %s", tableName);
|
||||
p = con.prepareStatement(sql);
|
||||
resultSet = p.executeQuery();
|
||||
|
||||
ResultSetMetaData rsmd = resultSet.getMetaData();
|
||||
int columnsNumber = rsmd.getColumnCount();
|
||||
int row = 1;
|
||||
System.out.println("\n####TABLE: " + tableName + " content..\n");
|
||||
while (resultSet.next()) {
|
||||
System.out.print("" + row + "] ");
|
||||
for (int i = 1; i <= columnsNumber; i++) {
|
||||
String columnValue = resultSet.getString(i);
|
||||
System.out.print("(" + rsmd.getColumnName(i) + ") " + columnValue + " | ");
|
||||
}
|
||||
row++;
|
||||
System.out.println("\n");
|
||||
|
||||
String projectId = resultSet.getString(columnNameProjectId);
|
||||
listProjectIds.add(projectId);
|
||||
}
|
||||
System.out.println("####TABLE: " + tableName + " end content\n");
|
||||
}
|
||||
|
||||
// Catch block to handle exception
|
||||
catch (SQLException e) {
|
||||
|
||||
// Print exception pop-up on screen
|
||||
System.err.println(e);
|
||||
}
|
||||
|
||||
System.out.println("returning list IDs: " + listProjectIds);
|
||||
return listProjectIds;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package org.gcube.application;
|
||||
|
||||
import org.gcube.application.geoportalcommon.GNADataEntryConfigProfileReader;
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataEntryConfigProfile;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
public class IS_Read_Configurations_Tests {
|
||||
|
||||
private static String CONTEXT = "/gcube/devsec/devVRE";
|
||||
private static String TOKEN = ""; // devVRE
|
||||
|
||||
//@Before
|
||||
public void getClient() {
|
||||
// assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void loadGNA_DataEntry_Configs() throws Exception{
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
GNADataEntryConfigProfileReader dataEntryConfigs = new GNADataEntryConfigProfileReader();
|
||||
GNADataEntryConfigProfile configProfile = dataEntryConfigs.readProfileFromInfrastrucure();
|
||||
System.out.println(configProfile);
|
||||
|
||||
System.out.println("GUI presentantion: "+configProfile.getDataEntryGUIPresentation());
|
||||
System.out.println("GUI permissions: "+configProfile.getPermissionsForRole());
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
package org.gcube.application;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
||||
import org.gcube.application.geoportalcommon.geoportal.config.GcubeProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class LoadDocumentConfiguration {
|
||||
|
||||
private static String TOKEN = "";
|
||||
private static String CONTEXT = "/gcube/devsec/devVRE";
|
||||
private static String USERNAME = "francesco.mangiacrapa";
|
||||
private static Logger LOG = LoggerFactory.getLogger(LoadDocumentConfiguration.class);
|
||||
|
||||
// @Before
|
||||
public void init() {
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadDocumentConfiguration() throws Exception {
|
||||
|
||||
// MockDocumentConfigurationReader mock = new MockDocumentConfigurationReader();
|
||||
// System.out.println(mock.getListDocumentConfig());
|
||||
|
||||
toHandlerDeclarationDV(null);
|
||||
}
|
||||
|
||||
private static String readFile(String filePath) {
|
||||
String content = "";
|
||||
|
||||
try {
|
||||
content = new String(Files.readAllBytes(Paths.get(filePath)));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* To handler declaration DV.
|
||||
*
|
||||
* @param <T> the generic type
|
||||
* @param handlerDeclaration the handler declaration
|
||||
* @return the handler declaration DV
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HandlerDeclarationDV toHandlerDeclarationDV(HandlerDeclaration handlerDeclaration) throws Exception {
|
||||
|
||||
// if (handlerDeclaration == null) {
|
||||
// LOG.warn(HandlerDeclaration.class.getSimpleName() + " is null");
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// Document configuration = handlerDeclaration.getConfiguration();
|
||||
//
|
||||
// if (configuration == null) {
|
||||
// LOG.warn("Configuration is null");
|
||||
// return null;
|
||||
// }
|
||||
|
||||
String jsonConfig = readFile(
|
||||
"/home/francescomangiacrapa/git/geoportal-data-common/src/test/resources/geoportal-config5.json");
|
||||
|
||||
LOG.debug("File as JSON: " + jsonConfig);
|
||||
|
||||
Document document = org.gcube.application.geoportal.client.utils.Serialization.read(jsonConfig, Document.class);
|
||||
|
||||
LinkedHashMap<String, String> configuration = (LinkedHashMap<String, String>) document.get("_configuration");
|
||||
|
||||
// configuration.values();
|
||||
|
||||
try {
|
||||
List<String> gcubeProfiles = new ArrayList<String>(configuration.values());
|
||||
// try {
|
||||
// gcubeProfiles = configuration.get("gcubeProfiles", ArrayList.class);
|
||||
// } catch (Exception e) {
|
||||
// LOG.info("gcubeProfiles not found in the handler");
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// HANDLER OF "gcubeProfiles" configuration
|
||||
if (gcubeProfiles != null) {
|
||||
|
||||
List<GcubeProfileDV> listGcubeProfiles = new ArrayList<GcubeProfileDV>(gcubeProfiles.size());
|
||||
|
||||
int i = 0;
|
||||
for (String gCubeProfile : gcubeProfiles) {
|
||||
LOG.debug(i++ + ") the gCubeProfile is: " + gCubeProfile);
|
||||
GcubeProfile profile = org.gcube.application.geoportal.client.utils.Serialization.read(gCubeProfile,
|
||||
GcubeProfile.class);
|
||||
listGcubeProfiles.add(ConvertToDataValueObjectModel.toGcubeProfileDV(profile));
|
||||
}
|
||||
|
||||
HandlerDeclarationDV hdDV = new HandlerDeclarationDV();
|
||||
hdDV.setId(handlerDeclaration.getId());
|
||||
hdDV.setType(handlerDeclaration.getType());
|
||||
|
||||
ConfigurationDV<List<GcubeProfileDV>> dDV = new ConfigurationDV<List<GcubeProfileDV>>(
|
||||
listGcubeProfiles);
|
||||
dDV.setConfiguration(listGcubeProfiles);
|
||||
hdDV.setConfiguration(dDV);
|
||||
|
||||
LOG.info("returning {}", hdDV);
|
||||
return hdDV;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on getting " + HandlerDeclaration.class.getSimpleName(), e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,675 @@
|
|||
package org.gcube.application;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.configuration.Configuration;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
||||
import org.gcube.application.geoportal.common.model.document.relationships.Relationship;
|
||||
import org.gcube.application.geoportal.common.model.document.relationships.RelationshipNavigationObject;
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
||||
import org.gcube.application.geoportalcommon.ProjectDVBuilder;
|
||||
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
||||
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
||||
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
||||
import org.gcube.application.geoportalcommon.shared.WhereClause;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleInformationDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.PhaseDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.junit.Before;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class Project_Tests {
|
||||
|
||||
private static final String GCUBE_CONFIG_PROPERTIES_FILENAME = "gcube_config.properties";
|
||||
// APP Working Directory + /src/test/resources must be the location of
|
||||
// gcube_config.properties
|
||||
private static String gcube_config_path = String.format("%s/%s",
|
||||
System.getProperty("user.dir") + "/src/test/resources", GCUBE_CONFIG_PROPERTIES_FILENAME);
|
||||
private static String CONTEXT;
|
||||
private static String TOKEN;
|
||||
|
||||
private static UseCaseDescriptorCaller clientUCD = null;
|
||||
private static ProjectsCaller clientPrj = null;
|
||||
|
||||
private static String PROFILE_ID = "profiledConcessioni";
|
||||
private static String PROJECT_ID = "6384aaac308f5c28c5ee0888";
|
||||
|
||||
private static String MY_LOGIN = "francesco.mangiacrapa";
|
||||
|
||||
private static final String FOLLOWS = "follows";
|
||||
private static final String PRECEDES = "precedes";
|
||||
|
||||
protected static class Phases {
|
||||
public static final String PENDING_APPROVAL = "Pending Approval";
|
||||
public static final String PUBLISHED = "Published";
|
||||
public static final String UNPUBLISHED = "UnPublished";
|
||||
|
||||
}
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
ContextConfigTest.readContextSettings();
|
||||
CONTEXT = ContextConfigTest.CONTEXT;
|
||||
TOKEN = ContextConfigTest.TOKEN;
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
clientPrj = GeoportalClientCaller.projects();
|
||||
clientUCD = GeoportalClientCaller.useCaseDescriptors();
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void getList() throws Exception {
|
||||
List<Project> listOfProjects = clientPrj.getListForProfileID(PROFILE_ID);
|
||||
|
||||
int i = 0;
|
||||
for (Project project : listOfProjects) {
|
||||
System.out.println(++i + ") " + project);
|
||||
}
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void getByID() throws Exception {
|
||||
Project project = clientPrj.getProjectByID(PROFILE_ID, PROJECT_ID);
|
||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||
ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder);
|
||||
System.out.println(projectDV);
|
||||
|
||||
LinkedHashMap<String, Object> theMap = projectDV.getTheDocument().getDocumentAsMap();
|
||||
for (String key : theMap.keySet()) {
|
||||
Object theValue = theMap.get(key);
|
||||
System.out.println("The key: " + key + " has value: " + theValue);
|
||||
}
|
||||
|
||||
System.out.println("JSON: " + projectDV.getTheDocument().getDocumentAsJSON());
|
||||
|
||||
System.out.println("Spatial reference: " + projectDV.getSpatialReference());
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void checkDocumentSerDes() throws Exception {
|
||||
Project project = clientPrj.getProjectByID(PROFILE_ID, PROJECT_ID);
|
||||
|
||||
String documentValueAsJson = project.getTheDocument().toJson();
|
||||
System.out.println("1 " + documentValueAsJson);
|
||||
String updatedDocumentAsJson = new Document(Project.THE_DOCUMENT, documentValueAsJson).toJson();
|
||||
System.out.println("2 " + updatedDocumentAsJson);
|
||||
Document setUpdatedDocument = new Document("$set", updatedDocumentAsJson);
|
||||
System.out.println("3 " + setUpdatedDocument);
|
||||
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void getListProjectsDV() throws Exception {
|
||||
List<Project> listOfProjects = clientPrj.getListForProfileID(PROFILE_ID);
|
||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||
int i = 0;
|
||||
for (Project project : listOfProjects) {
|
||||
ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder);
|
||||
System.out.println(++i + ") " + projectDV);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void getResultDocumentForID() {
|
||||
try {
|
||||
ProjectsCaller projects = GeoportalClientCaller.projects();
|
||||
Project project = projects.getProjectByID(PROFILE_ID, PROJECT_ID);
|
||||
ResultDocumentDV documentDV = ConvertToDataValueObjectModel.toResultDocumentDV(project);
|
||||
System.out.println("returning: " + documentDV);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void getListProjectsDVFilteredJSONDocument() throws Exception {
|
||||
// List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
||||
|
||||
SearchingFilter filter = new SearchingFilter();
|
||||
|
||||
// Where Clause
|
||||
List<WhereClause> conditions = new ArrayList<WhereClause>();
|
||||
Map<String, Object> searchInto = new HashMap<String, Object>();
|
||||
//searchInto.put("_id", "6384aaac308f5c28c5ee0888");
|
||||
searchInto.put("_theDocument.nome", "della Civita di Tarquinia ");
|
||||
|
||||
WhereClause whereClause = new WhereClause(LOGICAL_OP.OR, searchInto);
|
||||
|
||||
conditions.add(whereClause);
|
||||
filter.setConditions(conditions);
|
||||
|
||||
/* ORDER BY */
|
||||
// List<ItemFieldDV> orderByFields = new ArrayList<ItemFieldDV>();
|
||||
// List<String> jsonFields = Arrays.asList("_theDocument.dataInizioProgetto");
|
||||
// ItemFieldDV itemField = new ItemFieldDV("dataInizioProgetto", jsonFields, "$or", false, false, false);
|
||||
// orderByFields.add(itemField);
|
||||
// filter.setOrderByFields(orderByFields);
|
||||
|
||||
LinkedHashMap<String, Object> projection = new LinkedHashMap<String, Object>();
|
||||
// default
|
||||
// PROJECTION
|
||||
projection.put(Project.ID, 1);
|
||||
// projection.put("_theDocument.nome", 1);
|
||||
// projection.put("_profileID", 1);
|
||||
// projection.put("_profileVersion", 1);
|
||||
// projection.put("_version", 1);
|
||||
// projection.put("_theDocument", 1);
|
||||
//
|
||||
// projection.put("_theDocument.paroleChiaveLibere", 1);
|
||||
// projection.put("_theDocument.editore", 1);
|
||||
// projection.put("_theDocument.paroleChiaveICCD", 1);
|
||||
// projection.put("_theDocument.responsabile", 1);
|
||||
//
|
||||
// projection.put("_theDocument.introduzione", 1);
|
||||
// projection.put("_theDocument.authors", 1);
|
||||
// projection.put("_theDocument.dataInizioProgetto", 1);
|
||||
|
||||
//filter.setProjection(projection);
|
||||
|
||||
Integer totalDocs = clientPrj.getTotalDocument(PROFILE_ID);
|
||||
Iterator<Project> projects = clientPrj.queryOnMongo(PROFILE_ID, 10, 0, null, filter);
|
||||
//Iterable<Project> itP = () -> projects;
|
||||
//Stream<Project> targetStream = StreamSupport.stream(itP.spliterator(), false);
|
||||
//List<String> listProjectIDs = targetStream.map(Project::getId).collect(Collectors.toList());
|
||||
|
||||
List<ResultDocumentDV> results = ConvertToDataValueObjectModel.toListResultDocument(projects);
|
||||
int i = 0;
|
||||
for (ResultDocumentDV projectDV : results) {
|
||||
System.out.println(++i + ") " + projectDV.getId() + " JSON: "
|
||||
+ projectDV.getDocumentAsJSON());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//@Test
|
||||
public void getListProjectsDVFiltered() throws Exception {
|
||||
// List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
||||
|
||||
SearchingFilter filter = new SearchingFilter();
|
||||
|
||||
// Where Clause
|
||||
List<WhereClause> conditions = new ArrayList<WhereClause>();
|
||||
Map<String, Object> searchInto = new HashMap<String, Object>();
|
||||
// searchInto.put("_id", "61f0299baf51592c36795f52");
|
||||
// searchInto.put("_theDocument.nome", "Test progetto con clustering di
|
||||
// fileset");
|
||||
// searchInto.put("_theDocument.paroleChiaveLibere", "scavo");
|
||||
// searchInto.put("_theDocument.editore", "scavo");
|
||||
// searchInto.put("_theDocument.paroleChiaveICCD", "scavo");
|
||||
// searchInto.put("_theDocument.responsabile", "scavo");
|
||||
|
||||
searchInto.put("_theDocument.dataInizioProgetto", "2019");
|
||||
WhereClause whereClause = new WhereClause(LOGICAL_OP.OR, searchInto);
|
||||
|
||||
conditions.add(whereClause);
|
||||
filter.setConditions(conditions);
|
||||
|
||||
/* ORDER BY */
|
||||
// List<ItemFieldDV> orderByFields = new ArrayList<ItemFieldDV>();
|
||||
// List<String> jsonFields = Arrays.asList("_theDocument.dataInizioProgetto");
|
||||
// ItemFieldDV itemField = new ItemFieldDV("dataInizioProgetto", jsonFields, "$or", false, false, false);
|
||||
// orderByFields.add(itemField);
|
||||
// filter.setOrderByFields(orderByFields);
|
||||
|
||||
LinkedHashMap<String, Object> projection = new LinkedHashMap<String, Object>();
|
||||
// default
|
||||
// PROJECTION
|
||||
projection.put(Project.ID, 1);
|
||||
// projection.put("_theDocument.nome", 1);
|
||||
// projection.put("_profileID", 1);
|
||||
// projection.put("_profileVersion", 1);
|
||||
// projection.put("_version", 1);
|
||||
// projection.put("_theDocument", 1);
|
||||
//
|
||||
// projection.put("_theDocument.paroleChiaveLibere", 1);
|
||||
// projection.put("_theDocument.editore", 1);
|
||||
// projection.put("_theDocument.paroleChiaveICCD", 1);
|
||||
// projection.put("_theDocument.responsabile", 1);
|
||||
//
|
||||
// projection.put("_theDocument.introduzione", 1);
|
||||
// projection.put("_theDocument.authors", 1);
|
||||
// projection.put("_theDocument.dataInizioProgetto", 1);
|
||||
|
||||
filter.setProjection(projection);
|
||||
|
||||
Integer totalDocs = clientPrj.getTotalDocument(PROFILE_ID);
|
||||
Iterator<Project> projects = clientPrj.queryOnMongo(PROFILE_ID, totalDocs, 0, null, filter);
|
||||
Iterable<Project> itP = () -> projects;
|
||||
Stream<Project> targetStream = StreamSupport.stream(itP.spliterator(), false);
|
||||
List<String> listProjectIDs = targetStream.map(Project::getId).collect(Collectors.toList());
|
||||
|
||||
List<ResultDocumentDV> results = ConvertToDataValueObjectModel.toListResultDocument(projects);
|
||||
int i = 0;
|
||||
for (ResultDocumentDV projectDV : results) {
|
||||
System.out.println(++i + ") " + projectDV.getId() + " dataInizioProgetto: "
|
||||
+ projectDV.getDocumentAsMap().get("dataInizioProgetto"));
|
||||
}
|
||||
|
||||
// TEST TO PROJECT DV
|
||||
/*
|
||||
* ProjectDVBuilder projectBuilder =
|
||||
* ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||
*
|
||||
* List<ProjectDV> listProjects =
|
||||
* ConvertToDataValueObjectModel.toListProject(projects, projectBuilder); i = 0;
|
||||
* for (ProjectDV projectDV : listProjects) { System.out.println(++i + ") " +
|
||||
* projectDV); }
|
||||
*/
|
||||
|
||||
/*
|
||||
* int limit = 2; LinkedHashMap<String, Object> documentAsMap = new
|
||||
* LinkedHashMap<String, Object>(limit);
|
||||
*
|
||||
* try { // Project theProject = //
|
||||
* GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
|
||||
*
|
||||
* QueryRequest request = new QueryRequest();
|
||||
* request.setFilter(Document.parse("{\"" + Project.ID + "\" : " +
|
||||
* "{\"$eq\" : \"" + PROJECT_ID + "\"}}"));
|
||||
* request.setProjection(Document.parse("{\"" + Project.ID + "\" : " + "1}"));
|
||||
* // should be one projects(PROFILE_ID).build().f
|
||||
* projects(PROFILE_ID).build().query(request).forEachRemaining(p -> { try {
|
||||
* System.out.println("p is: "+p); Iterator<Entry<String, Object>> entrySetsIt =
|
||||
* p.getTheDocument().entrySet().iterator(); int i = 0; while
|
||||
* (entrySetsIt.hasNext()) { if (i > limit) break;
|
||||
*
|
||||
* Entry<String, Object> entry = entrySetsIt.next();
|
||||
* documentAsMap.put(entry.getKey(), entry.getValue()); i++; }
|
||||
*
|
||||
* } catch (Exception e) { throw e; } });
|
||||
*
|
||||
* System.out.println("getEntrySetsDocumentForProjectID returning map: "
|
||||
* +documentAsMap);
|
||||
*
|
||||
*
|
||||
* } catch (Exception e) { String erroMsg =
|
||||
* "Error occurred on loading EntrySets document for profileID " + PROFILE_ID +
|
||||
* " and projectID " + PROJECT_ID; e.printStackTrace(); }
|
||||
*/
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void getLifecycleForProjectId() throws Exception {
|
||||
Project project = clientPrj.getProjectByID(PROFILE_ID, PROJECT_ID);
|
||||
LifecycleInformation lci = project.getLifecycleInformation();
|
||||
LifecycleInformationDV liDV = ConvertToDataValueObjectModel.toLifecycleInformationDV(lci);
|
||||
System.out.println(liDV);
|
||||
//
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void getConfiguration() throws Exception {
|
||||
Configuration config = clientPrj.getConfiguration(PROFILE_ID);
|
||||
System.out.println(config);
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void getTotalDocument() throws Exception {
|
||||
|
||||
System.out.println(clientPrj.getTotalDocument(PROFILE_ID));
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void getListPhases() throws Exception {
|
||||
|
||||
List<String> idsPhases = clientPrj.getIDsPhases(PROFILE_ID);
|
||||
System.out.println(idsPhases);
|
||||
|
||||
PhaseDV[] phases = clientPrj.getPhasesIntoDocumentStoreCollection(PROFILE_ID);
|
||||
for (PhaseDV phaseDV : phases) {
|
||||
System.out.println(phaseDV);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void getCountByPhase() throws Exception {
|
||||
|
||||
Integer integer = clientPrj.getCountByPhaseFor(PROFILE_ID, "Published", "OK");
|
||||
System.out.println(integer);
|
||||
integer = clientPrj.getCountByPhaseFor(PROFILE_ID, "Pending Approval", "OK");
|
||||
System.out.println(integer);
|
||||
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void getRelationshipsChain() throws Exception {
|
||||
System.out.println("getRelationshipsChain test");
|
||||
Project project = clientPrj.getProjectByID(PROFILE_ID, PROJECT_ID);
|
||||
|
||||
List<Relationship> relations = project.getRelationships();
|
||||
|
||||
for (Relationship relationship : relations) {
|
||||
System.out.println("\n\ngetRelationshipsChain for " + relationship);
|
||||
Iterator<RelationshipNavigationObject> iterator = clientPrj.getRelationshipChain(PROFILE_ID, PROJECT_ID,
|
||||
relationship.getRelationshipName(), true);
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
RelationshipNavigationObject nav = (RelationshipNavigationObject) iterator.next();
|
||||
visitRelationshipsChain(nav, relationship.getRelationshipName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void visitRelationshipsChain(RelationshipNavigationObject nav, String relationshipName) {
|
||||
System.out.println("visitRelationshipsChain of target: " + nav.getTarget().getId() + ", relationshipName: "
|
||||
+ relationshipName + ", doc: " + nav.getTarget().getTheDocument());
|
||||
System.out.println("visitRelationshipsChain children " + nav.getChildren());
|
||||
|
||||
if (nav == null)
|
||||
return;
|
||||
|
||||
printObject(nav.getTarget());
|
||||
|
||||
if (nav.getChildren() != null) {
|
||||
|
||||
for (RelationshipNavigationObject relationship : nav.getChildren()) {
|
||||
visitRelationshipsChain(relationship, relationshipName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void printObject(Project project) {
|
||||
|
||||
System.out.println("Project id: " + project.getId() + ", profile: " + project.getProfileID() + ", doc: "
|
||||
+ project.getTheDocument().toJson());
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void deserializeISOJSONObjectAsDate() throws Exception {
|
||||
|
||||
String jsonDate = "{hour=0, minute=0, " + "dayOfYear=259, " + "dayOfWeek=MONDAY, " + "dayOfMonth=16, "
|
||||
+ "monthValue=9, " + "year=2019, " + "month=SEPTEMBER, " + "second=0, " + "nano=0, "
|
||||
+ "chronology={calendarType=iso8601, id=ISO}" + "}";
|
||||
|
||||
try {
|
||||
|
||||
/*
|
||||
* ObjectMapper objectMapper = new ObjectMapper(); JavaTimeModule javaTimeModule
|
||||
* = new JavaTimeModule(); javaTimeModule.addDeserializer(LocalDate.class, new
|
||||
* MyLocalDateDeserializer()); javaTimeModule.addSerializer(LocalDate.class, new
|
||||
* MyLocalDateSerializer()); objectMapper.registerModule(javaTimeModule);
|
||||
*
|
||||
* objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
* objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
|
||||
* false); objectMapper.configure(SerializationFeature.
|
||||
* WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); LocalDate date =
|
||||
* objectMapper.readerFor(LocalDate.class).readValue(jsonDate);
|
||||
* System.out.println(date);
|
||||
*/
|
||||
|
||||
// checking if the jsonDate is a LocalDate
|
||||
// LocalDateTime date =
|
||||
// org.gcube.application.geoportal.client.utils.Serialization.read(jsonDate,
|
||||
// LocalDateTime.class);
|
||||
LocalDate date = org.gcube.application.geoportal.client.utils.Serialization.read(jsonDate, LocalDate.class);
|
||||
System.out.println(date);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static final DateTimeFormatter FULL_FORMATTER = DateTimeFormatter.ofPattern("uuuuMMdd_HH-mm-ss");
|
||||
|
||||
public static class MyLocalDateSerializer extends JsonSerializer<LocalDate> {
|
||||
@Override
|
||||
public void serialize(LocalDate value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
gen.writeString(value.format(FULL_FORMATTER));
|
||||
}
|
||||
}
|
||||
|
||||
public static class MyLocalDateDeserializer extends JsonDeserializer<LocalDate> {
|
||||
|
||||
@Override
|
||||
public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
||||
return LocalDate.parse(p.getValueAsString(), FULL_FORMATTER);
|
||||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void testEvaluateRelationshipsChain() throws Exception {
|
||||
System.out.println("testEvaluateRelationshipsChain test");
|
||||
|
||||
// PROJECT_ID = "6399de3ca0a4545420373251";
|
||||
//
|
||||
// PROJECT_ID = "6399de68a0a4545420373257";
|
||||
//
|
||||
//
|
||||
// PROJECT_ID = "6399de96a0a4545420373258"; //no Relation
|
||||
//
|
||||
|
||||
PROJECT_ID = "63c80aebacb8c7657b858741";
|
||||
|
||||
Project project = clientPrj.getProjectByID(PROFILE_ID, PROJECT_ID);
|
||||
|
||||
evaluateAdditionalIndexParameters(project);
|
||||
|
||||
}
|
||||
|
||||
public static Document evaluateAdditionalIndexParameters(Project project) throws Exception {
|
||||
Document toReturn = null;
|
||||
if (toReturn == null)
|
||||
toReturn = new Document();
|
||||
Project indexingProject = project;
|
||||
|
||||
// Evaluate to display project IDs
|
||||
log.debug("Evaluating Last ID in relationship chain. Current Concessione ID is {}", indexingProject.getId());
|
||||
try {
|
||||
ArrayList<Project> projects = new ArrayList<>();
|
||||
|
||||
// get Last ID in relation chain
|
||||
projects.add(indexingProject);
|
||||
|
||||
if (!indexingProject.getRelationshipsByName(PRECEDES).isEmpty()) {
|
||||
List<RelationshipNavigationObject> relChain = getRelationshipChain(indexingProject.getProfileID(),
|
||||
indexingProject, PRECEDES, true);
|
||||
scanRelation(projects, relChain.get(0), false);
|
||||
}
|
||||
if (!indexingProject.getRelationshipsByName(FOLLOWS).isEmpty()) {
|
||||
List<RelationshipNavigationObject> relChain = getRelationshipChain(indexingProject.getProfileID(),
|
||||
indexingProject, FOLLOWS, true);
|
||||
scanRelation(projects, relChain.get(0), false);
|
||||
}
|
||||
|
||||
log.debug("Produced full chain [size : {}] from {}, evaluating last available for PHASE {} ",
|
||||
projects.size(), indexingProject.getId(), indexingProject.getLifecycleInformation().getPhase());
|
||||
|
||||
List<String> toDisplayId = new ArrayList<>();
|
||||
List<String> toHideIds = new ArrayList<>();
|
||||
|
||||
log.info("projects are: " + projects.size());
|
||||
|
||||
// Reverse Order means from the last FOLLOW to the first one (temporal reverse
|
||||
// order)
|
||||
Collections.sort(projects, Collections.reverseOrder(new ProjectRelationComparator()));
|
||||
|
||||
int j = 0;
|
||||
for (Project theProject : projects) {
|
||||
log.info(++j + ") " + theProject.getId() + " data inizio: "
|
||||
+ theProject.getTheDocument().get("dataInizioProgetto"));
|
||||
}
|
||||
|
||||
log.trace("Checking from LAST.. ");
|
||||
|
||||
for (int i = 0; i < projects.size(); i++) {
|
||||
|
||||
Project p = projects.get(i);
|
||||
String phase = p.getLifecycleInformation().getPhase();
|
||||
// IS TO DISPLAY EMPTY? Step into only once
|
||||
if (toDisplayId.isEmpty()) {
|
||||
// IF PHASE IS PENDING APPROVAL OR PUBLISHED
|
||||
if ((phase.equals(Phases.PENDING_APPROVAL) || phase.equals(Phases.PUBLISHED))) {
|
||||
toDisplayId.add(p.getId());
|
||||
}
|
||||
} else {
|
||||
|
||||
switch (phase) {
|
||||
case Phases.PENDING_APPROVAL:
|
||||
case Phases.PUBLISHED: {
|
||||
if ((p.getLifecycleInformation().getPhase().equals(Phases.PENDING_APPROVAL)
|
||||
|| p.getLifecycleInformation().getPhase().equals(Phases.PUBLISHED)))
|
||||
toHideIds.add(p.getId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
toReturn.put("_toHideIds", toHideIds);
|
||||
toReturn.put("_toDisplayIds", toDisplayId);
|
||||
|
||||
log.info("Indexing request for Concessione [ID {}] with to HIDE {} and toDisplay {} ",
|
||||
indexingProject.getId(), toHideIds, toDisplayId);
|
||||
return toReturn;
|
||||
} catch (Exception e) {
|
||||
log.error("Unable to evaluate to Hide and Display Ids ", e);
|
||||
throw new Exception("Unable to evaluate chain ids to hide / display", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class ProjectRelationComparator implements Comparator<Project> {
|
||||
@Override
|
||||
public int compare(Project p1, Project p2) {
|
||||
|
||||
if (p1 == null)
|
||||
return 1;
|
||||
if (p2 == null)
|
||||
return -1;
|
||||
|
||||
Integer compareResult = null;
|
||||
compareResult = compareProjectAgainstRelations(p1, p2);
|
||||
log.trace("p1 & p2, comparator result: {}", compareResult);
|
||||
if (compareResult == null) {
|
||||
log.debug("No relations beetween p1 & p2, checking inverted relations");
|
||||
compareResult = compareProjectAgainstRelations(p2, p1);
|
||||
log.trace("p2 & p1, comparator result: {}", compareResult);
|
||||
|
||||
if (compareResult == null) {
|
||||
log.trace("p1 & p2, are not comparable, returning 0");
|
||||
compareResult = 0;
|
||||
}
|
||||
}
|
||||
|
||||
log.debug("p1 & p2, comparator result, returns: {}", compareResult);
|
||||
return compareResult;
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer compareProjectAgainstRelations(Project source, Project target) {
|
||||
log.debug("comparing source {} and target {}", source.getId(), target.getId());
|
||||
List<Relationship> listRel = source.getRelationships();
|
||||
log.debug("relationships of {} are : {}", source.getId(), listRel);
|
||||
if (listRel != null) {
|
||||
String targetId = target.getId();
|
||||
for (Relationship relationship : listRel) {
|
||||
String relTargetId = relationship.getTargetID();
|
||||
if (targetId.compareTo(relTargetId) == 0) {
|
||||
String relationName = relationship.getRelationshipName();
|
||||
if (relationName.equals(PRECEDES)) {
|
||||
log.debug("source {} [rel {} ] target {}, so source < target ", source.getId(), PRECEDES,
|
||||
target.getId());
|
||||
// source < target
|
||||
return -1;
|
||||
} else if (relationName.equals(FOLLOWS)) {
|
||||
log.debug("source {} [rel {} ] target {}, so source > target ", source.getId(), FOLLOWS,
|
||||
target.getId());
|
||||
// source > target
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
log.debug("No relations beetween a & b");
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void scanRelation(ArrayList chain, RelationshipNavigationObject obj, boolean putBefore) {
|
||||
if (putBefore)
|
||||
chain.add(0, obj.getTarget());
|
||||
else
|
||||
chain.add(obj.getTarget());
|
||||
if (obj.getChildren() != null)
|
||||
obj.getChildren().forEach(r -> scanRelation(chain, r, putBefore));
|
||||
}
|
||||
|
||||
public static List<RelationshipNavigationObject> getRelationshipChain(String ucid, Project current,
|
||||
String relationshipId, Boolean deep) throws Exception {
|
||||
// recursive
|
||||
// ProfiledMongoManager manager = new ProfiledMongoManager(ucid);
|
||||
log.info("UCD {} : Getting Relationships List for {} [rel : {}, recurse {}]", ucid, current.getId(),
|
||||
relationshipId, deep);
|
||||
// Project current = manager.getByID(id);
|
||||
long startTime = System.currentTimeMillis();
|
||||
List<RelationshipNavigationObject> toReturn = getLinked(current, relationshipId, deep);
|
||||
log.info("Got {} relationship elements in {}ms", toReturn.size(), (System.currentTimeMillis() - startTime));
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private static List<RelationshipNavigationObject> getLinked(Project current, String relationName, Boolean recurse) {
|
||||
log.debug("Getting Relationships Lists for {} [rel : {}, recurse {}]", current.getId(), relationName, recurse);
|
||||
ArrayList<RelationshipNavigationObject> toReturn = new ArrayList<>();
|
||||
List<Relationship> existing = current.getRelationshipsByName(relationName);
|
||||
for (Relationship relationship : existing) {
|
||||
try {
|
||||
log.debug("Navigating from {} : {} to[rel {} ] {} : {}", relationship.getTargetUCD(),
|
||||
relationship.getTargetID(), relationship.getRelationshipName(), current.getProfileID(),
|
||||
current.getId());
|
||||
RelationshipNavigationObject linkedProject = new RelationshipNavigationObject();
|
||||
// linkedProject.setTarget(new
|
||||
// ProfiledMongoManager(relationship.getTargetUCD()).getByID(relationship.getTargetID()));
|
||||
// Project target = new Project();
|
||||
// target.setProfileID(relationship.getTargetUCD());
|
||||
// target.setId(relationship.getTargetID());
|
||||
|
||||
Project target = clientPrj.getProjectByID(relationship.getTargetUCD(), relationship.getTargetID());
|
||||
|
||||
linkedProject.setTarget(target);
|
||||
if (recurse) {
|
||||
List<RelationshipNavigationObject> linked = getLinked(linkedProject.getTarget(), relationName,
|
||||
recurse);
|
||||
linkedProject.setChildren(linked);
|
||||
}
|
||||
toReturn.add(linkedProject);
|
||||
} catch (Exception e) {
|
||||
log.warn("Unable to navigate from {} : {} to[rel {} ] {} : {}", relationship.getTargetUCD(),
|
||||
relationship.getTargetID(), relationship.getRelationshipName(), current.getProfileID(),
|
||||
current.getId(), e);
|
||||
}
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,405 @@
|
|||
package org.gcube.application;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
||||
import org.gcube.application.geoportalcommon.ProjectDVBuilder;
|
||||
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
||||
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
||||
import org.gcube.application.geoportalcommon.shared.WhereClause;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||
import org.gcube.application.se.RuntimeResourceReader;
|
||||
import org.gcube.application.se.ServiceEndpointBean;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
public class ReSyncCentroidsMetadataOnDB {
|
||||
|
||||
// private static final String CONTEXT = "/gcube/devsec/devVRE";
|
||||
// private static final String TOKEN = ""; // devVRE
|
||||
|
||||
// private static final String CONTEXT = "/pred4s/preprod/preVRE";
|
||||
// private static final String TOKEN = ""; //preVRE
|
||||
|
||||
private static final String CONTEXT = "/d4science.research-infrastructures.eu/D4OS/GNA";
|
||||
private static final String TOKEN = ""; //GNA
|
||||
|
||||
// GEOPORTAL
|
||||
private static String PROFILE_ID = "profiledConcessioni";
|
||||
//private static final String PROFILE_ID = "concessioni-estere";
|
||||
private static final String JSON_KEY_DATA_FINE_PROGETTO = "dataFineProgetto";
|
||||
private static final String JSON_KEY_DATA_INIZIO_PROGETTO = "dataInizioProgetto";
|
||||
private static final String JSON_KEY_INTRODUZIONE = "introduzione";
|
||||
|
||||
// DB
|
||||
private static final String platformName = "postgis";
|
||||
private static final String category = "Database";
|
||||
//private static final String resourceName = "GNA-POSTGIS-DB"; //devVRE
|
||||
//private static final String resourceName = "Geoserver-t postgis"; //preVRE
|
||||
private static final String resourceName = "GNA-postgis"; //GNA
|
||||
|
||||
|
||||
private static final String TABLE_COLUMN_DATA_FINE_PROGETTO = "data_fine_progetto";
|
||||
private static final String TABLE_COLUMN_DATA_INIZIO_PROGETTO = "data_inizio_progetto";
|
||||
private static final String TABLE_COLUMN_DESCRIZIONE = "descrizione";
|
||||
|
||||
private static ProjectsCaller client = null;
|
||||
|
||||
public static final boolean READ_ONLY_MODE = true;
|
||||
|
||||
/**
|
||||
* Gets the client.
|
||||
*
|
||||
* @return the client
|
||||
*/
|
||||
// @Before
|
||||
public static void initGeoportalClient() {
|
||||
// assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
client = GeoportalClientCaller.projects();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.out.println("READ_ONLY_MODE ENABLED: "+READ_ONLY_MODE);
|
||||
System.out.println("CONTEXT IS: "+CONTEXT);
|
||||
System.out.println("PROFILE_ID: "+PROFILE_ID);
|
||||
|
||||
initGeoportalClient();
|
||||
|
||||
//preVRE
|
||||
// String tableName = "profiledconcessioni_internal__prevre_centroids";
|
||||
// tableName = "profiledconcessioni_prevre_centroids";
|
||||
// tableName = "concessioni_estere_prevre_centroids";
|
||||
// tableName = "concessioni_estere_internal__prevre_centroids";
|
||||
|
||||
|
||||
//GNA
|
||||
// PROFILE_ID = "concessioni-estere";
|
||||
// String tableName = "concessioni_estere_internal__gna_centroids";
|
||||
// tableName = "concessioni_estere_gna_centroids";
|
||||
PROFILE_ID = "profiledConcessioni";
|
||||
String tableName = "profiledconcessioni_internal__gna_centroids";
|
||||
tableName = "profiledconcessioni_gna_centroids";
|
||||
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
RuntimeResourceReader rrr = new RuntimeResourceReader(CONTEXT, resourceName, platformName, category, null);
|
||||
ServiceEndpointBean se = rrr.getListSE().get(0);
|
||||
AccessPoint ap = se.getListAP().get(0);
|
||||
|
||||
System.out.println(ap.address());
|
||||
System.out.println(ap.username());
|
||||
String pwdDB = RuntimeResourceReader.dectryptPassword(CONTEXT, ap);
|
||||
System.out.println(pwdDB);
|
||||
|
||||
Connection dbConnection = getDatabaseConnection(ap.address(), ap.username(), pwdDB);
|
||||
|
||||
// MUST BE DONE JUST ONCE
|
||||
try {
|
||||
renameColumnTable(dbConnection, tableName, "anno", TABLE_COLUMN_DATA_INIZIO_PROGETTO);
|
||||
renameColumnTable(dbConnection, tableName, "date_scavo", TABLE_COLUMN_DATA_FINE_PROGETTO);
|
||||
// addColumnTable(dbConnection, tableName, "gna_url", "TEXT"); //Could be a
|
||||
// VARCHAR(2048). Is it manageable by service?
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> listProjectIdsIntoDB = readTableIDs(dbConnection, tableName, "projectid");
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
// List<ResultDocumentDV> listPublishedProjectsIntoService =
|
||||
// getListProjectsDVFiltered();
|
||||
|
||||
int counter = 1;
|
||||
for (String projectId : listProjectIdsIntoDB) {
|
||||
Project project = null;
|
||||
System.out.println("\n\n################ "+counter+" of "+listProjectIdsIntoDB.size()+ ") Reading the project id: " + projectId);
|
||||
try {
|
||||
project = client.getProjectByID(PROFILE_ID, projectId);
|
||||
} catch (Exception e) {
|
||||
System.err.println("Project id not found: " + projectId);
|
||||
}
|
||||
try {
|
||||
|
||||
if (project == null)
|
||||
continue;
|
||||
|
||||
System.out.println("\n###### Trying to update Centroid TABLE for project id: " + projectId);
|
||||
|
||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||
ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder);
|
||||
|
||||
LinkedHashMap<String, Object> projectMap = projectDV.getTheDocument().getDocumentAsMap();
|
||||
|
||||
LinkedHashMap<String, String> hashMap = new LinkedHashMap<String, String>();
|
||||
hashMap.put(TABLE_COLUMN_DATA_INIZIO_PROGETTO, projectMap.get(JSON_KEY_DATA_INIZIO_PROGETTO) + "");
|
||||
hashMap.put(TABLE_COLUMN_DATA_FINE_PROGETTO, projectMap.get(JSON_KEY_DATA_FINE_PROGETTO) + "");
|
||||
hashMap.put(TABLE_COLUMN_DESCRIZIONE, projectMap.get(JSON_KEY_INTRODUZIONE) + "");
|
||||
updateTable(dbConnection, tableName, "projectId='" + projectId + "'", hashMap);
|
||||
System.out.println("###UPDATED project id: " + projectId);
|
||||
|
||||
Thread.sleep(500);
|
||||
System.out.println("################ Update completed for: " + projectId);
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error on updating the table for the project id: " + projectId);
|
||||
}
|
||||
|
||||
counter++;
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
long endTime = System.currentTimeMillis();
|
||||
System.out.println("\n\nSCRIPT END at: "+endTime);
|
||||
double toSec = (endTime-startTime)/1000;
|
||||
System.out.println("SCRIPT TERMINATED in "+toSec + "sec");
|
||||
|
||||
}
|
||||
|
||||
public static List<ResultDocumentDV> getListProjectsDVFiltered() throws Exception {
|
||||
// List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
||||
|
||||
SearchingFilter filter = new SearchingFilter();
|
||||
|
||||
// Where Clause
|
||||
List<WhereClause> conditions = new ArrayList<WhereClause>();
|
||||
Map<String, Object> searchInto = new HashMap<String, Object>();
|
||||
searchInto.put("_lifecycleInformation._phase", "Published");
|
||||
WhereClause whereClause = new WhereClause(LOGICAL_OP.OR, searchInto);
|
||||
|
||||
conditions.add(whereClause);
|
||||
filter.setConditions(conditions);
|
||||
|
||||
LinkedHashMap<String, Object> projection = new LinkedHashMap<String, Object>();
|
||||
// default
|
||||
// PROJECTION
|
||||
String theDoc = Project.THE_DOCUMENT + ".";
|
||||
projection.put(Project.ID, 1);
|
||||
projection.put(theDoc + "nome", 1);
|
||||
projection.put(theDoc + JSON_KEY_DATA_INIZIO_PROGETTO, 1);
|
||||
projection.put(theDoc + JSON_KEY_DATA_FINE_PROGETTO, 1);
|
||||
|
||||
filter.setProjection(projection);
|
||||
|
||||
Integer totalDocs = client.getTotalDocument(PROFILE_ID);
|
||||
Iterator<Project> projects = client.queryOnMongo(PROFILE_ID, totalDocs, 0, null, filter);
|
||||
|
||||
List<ResultDocumentDV> results = ConvertToDataValueObjectModel.toListResultDocument(projects);
|
||||
int i = 0;
|
||||
for (ResultDocumentDV projectDV : results) {
|
||||
System.out.println(++i + ") " + projectDV.getId() + " " + JSON_KEY_DATA_INIZIO_PROGETTO + ": "
|
||||
+ projectDV.getDocumentAsMap().get(JSON_KEY_DATA_INIZIO_PROGETTO) + " "
|
||||
+ JSON_KEY_DATA_FINE_PROGETTO + ": " + projectDV.getDocumentAsMap().get(JSON_KEY_DATA_FINE_PROGETTO)
|
||||
+ " " + JSON_KEY_INTRODUZIONE + ": " + projectDV.getDocumentAsMap().get(JSON_KEY_INTRODUZIONE));
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the database connection.
|
||||
*
|
||||
* @param dbURL the db url
|
||||
* @param user the user
|
||||
* @param pwd the pwd
|
||||
* @return the database connection
|
||||
*/
|
||||
public static Connection getDatabaseConnection(String dbURL, String user, String pwd) {
|
||||
|
||||
System.out.println("dbURL: " + dbURL);
|
||||
Connection c = null;
|
||||
try {
|
||||
Class.forName("org.postgresql.Driver");
|
||||
c = DriverManager.getConnection(dbURL, user, pwd);
|
||||
c.setAutoCommit(false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.err.println(e.getClass().getName() + ": " + e.getMessage());
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
System.out.println("Opened database successfully");
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public static void renameColumnTable(Connection con, String tableName, String oldColumn, String newColumn)
|
||||
throws SQLException {
|
||||
|
||||
String alterTableString = String.format("ALTER TABLE %s RENAME COLUMN %s TO %s", tableName, oldColumn,
|
||||
newColumn);
|
||||
|
||||
System.out.println("Executing: " + alterTableString);
|
||||
try {
|
||||
con.setAutoCommit(false);
|
||||
if (!READ_ONLY_MODE) {
|
||||
con.createStatement().execute(alterTableString);
|
||||
con.commit();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
if (con != null) {
|
||||
try {
|
||||
System.err.print("Transaction is being rolled back");
|
||||
con.rollback();
|
||||
} catch (SQLException excep) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Executed: " + alterTableString);
|
||||
}
|
||||
|
||||
public static void addColumnTable(Connection con, String tableName, String newColumn, String type)
|
||||
throws SQLException {
|
||||
|
||||
String alterTableString = String.format("ALTER TABLE %s ADD COLUMN %s %s", tableName, newColumn, type);
|
||||
|
||||
System.out.println("Executing: " + alterTableString);
|
||||
|
||||
try {
|
||||
con.setAutoCommit(false);
|
||||
if (!READ_ONLY_MODE) {
|
||||
con.createStatement().execute(alterTableString);
|
||||
con.commit();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
if (con != null) {
|
||||
try {
|
||||
System.err.print("Transaction is being rolled back");
|
||||
con.rollback();
|
||||
} catch (SQLException excep) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Executed: " + alterTableString);
|
||||
}
|
||||
|
||||
public static void updateTable(Connection con, String tableName, String whereCondition,
|
||||
LinkedHashMap<String, String> mapColumnValue) throws SQLException {
|
||||
|
||||
// String alterTableString = String.format("UPDATE TABLE %s SET COLUMN %s TO %s", tableName, oldColumn,
|
||||
// newColumn);
|
||||
//
|
||||
StringBuilder updateSQL = new StringBuilder();
|
||||
updateSQL.append("UPDATE " + tableName + " SET");
|
||||
|
||||
int i = 1;
|
||||
for (String column : mapColumnValue.keySet()) {
|
||||
updateSQL.append(" " + column + "=?");
|
||||
if (i < mapColumnValue.size())
|
||||
updateSQL.append(", ");
|
||||
i++;
|
||||
}
|
||||
|
||||
updateSQL.append(" WHERE " + whereCondition);
|
||||
|
||||
String update = updateSQL.toString();
|
||||
|
||||
// System.out.println("Executing: " + update);
|
||||
try (PreparedStatement updatePS = con.prepareStatement(update);) {
|
||||
int index = 1;
|
||||
for (String column : mapColumnValue.keySet()) {
|
||||
updatePS.setString(index, mapColumnValue.get(column));
|
||||
index++;
|
||||
}
|
||||
con.setAutoCommit(false);
|
||||
|
||||
System.out.println("Executing: " + updatePS.toString());
|
||||
if (!READ_ONLY_MODE) {
|
||||
updatePS.executeUpdate();
|
||||
con.commit();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
if (con != null) {
|
||||
try {
|
||||
System.err.print("Transaction is being rolled back");
|
||||
con.rollback();
|
||||
} catch (SQLException excep) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Step1: Main driver method
|
||||
public static List<String> readTableIDs(Connection con, String tableName, String columnNameProjectId) {
|
||||
PreparedStatement p = null;
|
||||
ResultSet resultSet = null;
|
||||
|
||||
// Try block to catch exception/s
|
||||
List<String> listProjectIds = new ArrayList<String>();
|
||||
try {
|
||||
|
||||
// SQL command data stored in String datatype
|
||||
String sql = String.format("SELECT * FROM %s", tableName);
|
||||
p = con.prepareStatement(sql);
|
||||
resultSet = p.executeQuery();
|
||||
|
||||
ResultSetMetaData rsmd = resultSet.getMetaData();
|
||||
int columnsNumber = rsmd.getColumnCount();
|
||||
int row = 1;
|
||||
System.out.println("\n####TABLE: " + tableName + " content..\n");
|
||||
while (resultSet.next()) {
|
||||
System.out.print("" + row + "] ");
|
||||
for (int i = 1; i <= columnsNumber; i++) {
|
||||
String columnValue = resultSet.getString(i);
|
||||
System.out.print("(" + rsmd.getColumnName(i) + ") " + columnValue + " | ");
|
||||
}
|
||||
row++;
|
||||
System.out.println("\n");
|
||||
|
||||
String projectId = resultSet.getString(columnNameProjectId);
|
||||
listProjectIds.add(projectId);
|
||||
}
|
||||
System.out.println("####TABLE: " + tableName + " end content\n");
|
||||
}
|
||||
|
||||
// Catch block to handle exception
|
||||
catch (SQLException e) {
|
||||
|
||||
// Print exception pop-up on screen
|
||||
System.err.println(e);
|
||||
}
|
||||
|
||||
System.out.println("returning list IDs: " + listProjectIds);
|
||||
return listProjectIds;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,175 @@
|
|||
package org.gcube.application;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
||||
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
||||
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataEntryConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
|
||||
import org.gcube.application.geoportalcommon.shared.config.RoleRights;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
public class TestGNACommon {
|
||||
|
||||
private static final String GCUBE_CONFIG_PROPERTIES_FILENAME = "gcube_config.properties";
|
||||
// APP Working Directory + /src/test/resources must be the location of
|
||||
// gcube_config.properties
|
||||
private static String gcube_config_path = String.format("%s/%s",
|
||||
System.getProperty("user.dir") + "/src/test/resources", GCUBE_CONFIG_PROPERTIES_FILENAME);
|
||||
private static String CONTEXT;
|
||||
private static String TOKEN;
|
||||
|
||||
private static UseCaseDescriptorCaller clientUCD = null;
|
||||
private static ProjectsCaller clientPrj = null;
|
||||
|
||||
private static String PROFILE_ID = "profiledConcessioni";
|
||||
private static String PROJECT_ID = "644a66e944aad51c80409a3b";
|
||||
|
||||
private static String MY_LOGIN = "francesco.mangiacrapa";
|
||||
|
||||
/**
|
||||
* Read context settings.
|
||||
*/
|
||||
public static void readContextSettings() {
|
||||
|
||||
try (InputStream input = new FileInputStream(gcube_config_path)) {
|
||||
|
||||
Properties prop = new Properties();
|
||||
|
||||
// load a properties file
|
||||
prop.load(input);
|
||||
|
||||
CONTEXT = prop.getProperty("CONTEXT");
|
||||
TOKEN = prop.getProperty("TOKEN");
|
||||
// get the property value and print it out
|
||||
System.out.println("CONTEXT: " + CONTEXT);
|
||||
System.out.println("TOKEN: " + TOKEN);
|
||||
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//@Before
|
||||
public void init() {
|
||||
readContextSettings();
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
clientPrj = GeoportalClientCaller.projects();
|
||||
clientUCD = GeoportalClientCaller.useCaseDescriptors();
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void getGeoNaDataViewProfile() throws Exception {
|
||||
System.out.println("getGeoNaDataViewProfile called");
|
||||
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
GeoportalCommon gc = new GeoportalCommon();
|
||||
GNADataViewerConfigProfile profile = gc.readGNADataViewerConfig(null);
|
||||
System.out.println("Returning profile: " + profile);
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void getLinks() throws Exception {
|
||||
System.out.println("getLinks called");
|
||||
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
GeoportalCommon gc = new GeoportalCommon();
|
||||
GeoportalItemReferences item = new GeoportalItemReferences(PROJECT_ID, PROFILE_ID);
|
||||
GeoportalItemReferences links = gc.getPublicLinksFor(CONTEXT, item, true);
|
||||
System.out.println(links);
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void queryConcessioniTest() throws Exception {
|
||||
// try {
|
||||
//
|
||||
// ScopeProvider.instance.set(CONTEXT);
|
||||
// MongoServiceCommon msc = new MongoServiceCommon();
|
||||
// SearchingFilter filter = new SearchingFilter();
|
||||
//
|
||||
// Map<String, Object> searchInto = new HashMap<String, Object>();
|
||||
// searchInto.put("nome", "san");
|
||||
// searchInto.put("authors", "silvia");
|
||||
// // searchInto.put("report.status", "PASSED");
|
||||
//
|
||||
// WhereClause where1 = new WhereClause(LOGICAL_OP.OR, searchInto);
|
||||
//
|
||||
// Map<String, Object> searchInto2 = new HashMap<String, Object>();
|
||||
// searchInto2.put("report.status", "PASSED");
|
||||
// WhereClause where2 = new WhereClause(LOGICAL_OP.AND, searchInto2);
|
||||
//
|
||||
// ArrayList<WhereClause> list = new ArrayList<WhereClause>();
|
||||
// list.add(where1);
|
||||
// // list.add(where2);
|
||||
// filter.setConditions(list);
|
||||
// ResultSetPaginatedData result = msc.queryOnMongo(30, 0, 30, filter, "concessione");
|
||||
//
|
||||
// int i = 0;
|
||||
// for (ConcessioneDV concessione : result.getData()) {
|
||||
// System.out.println(++i + ") " + concessione);
|
||||
// }
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// @Test
|
||||
public void readGNDataEntryConfigsFromIS() throws Exception {
|
||||
|
||||
Thread thread = new Thread() {
|
||||
public void run() {
|
||||
geoCommon();
|
||||
}
|
||||
};
|
||||
|
||||
Thread thread2 = new Thread() {
|
||||
public void run() {
|
||||
geoCommon();
|
||||
}
|
||||
};
|
||||
|
||||
thread.run();
|
||||
thread2.run();
|
||||
}
|
||||
|
||||
private void geoCommon() {
|
||||
GeoportalCommon r = new GeoportalCommon();
|
||||
try {
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
GNADataEntryConfigProfile configurations = r.readGNADataEntryConfig();
|
||||
|
||||
System.out.println("Permissions are:");
|
||||
int i = 0;
|
||||
for (RoleRights role : configurations.getPermissionsForRole()) {
|
||||
System.out.println(++i + " " + role);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void readGNDataViewerConfigsFromIS() throws Exception {
|
||||
|
||||
GeoportalCommon r = new GeoportalCommon();
|
||||
try {
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
GNADataViewerConfigProfile configurations = r.readGNADataViewerConfig(null);
|
||||
System.out.println(configurations.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package org.gcube.application;
|
||||
|
||||
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
public class TestGeonaReader {
|
||||
|
||||
|
||||
private static String scope ="/gcube/devsec/devVRE";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
//System.out.println(getGeoNaDataViewProfile());
|
||||
|
||||
System.out.println(getLinks());
|
||||
|
||||
}
|
||||
|
||||
public static GeoNaDataViewerProfile getGeoNaDataViewProfile() throws Exception{
|
||||
System.out.println("getGeoNaDataViewProfile called");
|
||||
|
||||
ScopeProvider.instance.set(scope);
|
||||
GeoportalCommon gc = new GeoportalCommon();
|
||||
GeoNaDataViewerProfile profile = gc.getGeoNaDataViewProfile(null);
|
||||
System.out.println("Returning profile: "+profile);
|
||||
return profile;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static GeoNaItemRef getLinks() throws Exception{
|
||||
System.out.println("getGeoNaDataViewProfile called");
|
||||
|
||||
ScopeProvider.instance.set(scope);
|
||||
GeoportalCommon gc = new GeoportalCommon();
|
||||
GeoNaItemRef item = new GeoNaItemRef(new Long(2), "concessione");
|
||||
GeoNaItemRef links = gc.getPublicLinksFor(item);
|
||||
return links;
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue