Integrated with ValidationReport bean
This commit is contained in:
parent
717d4b8a5f
commit
18838d0ce6
|
@ -5,12 +5,13 @@ 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).
|
||||
|
||||
|
||||
## [v1.1.0-SNAPSHOT] - 2021-09-09
|
||||
## [v1.1.0-SNAPSHOT] - 2021-09-13
|
||||
|
||||
#### Enhancements
|
||||
|
||||
[#20595] Porting common model
|
||||
[#21890] Passed to mongoID
|
||||
[#22002] Integrated with ValidationReport bean
|
||||
Passed to gcube-bom 2.0.1
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.application.geoportalcommon;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
|
@ -14,6 +15,7 @@ import org.gcube.application.geoportal.common.model.legacy.PersistedContent;
|
|||
import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo;
|
||||
import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
|
||||
import org.gcube.application.geoportal.common.model.legacy.WorkspaceContent;
|
||||
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport;
|
||||
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
|
||||
import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
|
@ -23,6 +25,8 @@ import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelaz
|
|||
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV.ValidationStatus;
|
||||
import org.gcube.application.geoportalcommon.util.DateUtils;
|
||||
import org.gcube.application.geoportalcommon.util.URLParserUtil;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -121,15 +125,17 @@ public class ConvertToDataViewModel {
|
|||
List<LayerConcessioneDV> piantaScavoDV = new ArrayList<LayerConcessioneDV>(
|
||||
concessione.getPianteFineScavo().size());
|
||||
for (LayerConcessione lc : concessione.getPianteFineScavo()) {
|
||||
//TODO CHECK WHY I HAVE TO PASS theConcessione = null IN ORDER TO AVOID GWT serialization error
|
||||
// TODO CHECK WHY I HAVE TO PASS theConcessione = null IN ORDER TO AVOID GWT
|
||||
// serialization error
|
||||
piantaScavoDV.add(toLayerConcessione(lc, null));
|
||||
}
|
||||
theConcessione.setPianteFineScavo(piantaScavoDV);
|
||||
}
|
||||
|
||||
if (concessione.getPosizionamentoScavo() != null) {
|
||||
//TODO CHECK WHY I HAVE TO PASS theConcessione = null IN ORDER TO AVOID GWT serialization error
|
||||
LayerConcessioneDV thePosizScavo = toLayerConcessione(concessione.getPosizionamentoScavo(),null);
|
||||
// TODO CHECK WHY I HAVE TO PASS theConcessione = null IN ORDER TO AVOID GWT
|
||||
// serialization error
|
||||
LayerConcessioneDV thePosizScavo = toLayerConcessione(concessione.getPosizionamentoScavo(), null);
|
||||
theConcessione.setPosizionamentoScavo(thePosizScavo);
|
||||
}
|
||||
|
||||
|
@ -146,10 +152,11 @@ public class ConvertToDataViewModel {
|
|||
* To metadata concessione.
|
||||
*
|
||||
* @param concessione the concessione
|
||||
* @param includeValidationReport the include validation report
|
||||
* @return the concessione DV
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static ConcessioneDV toMetadataConcessione(Concessione concessione) throws Exception {
|
||||
public static ConcessioneDV toMetadataConcessione(Concessione concessione, boolean includeValidationReport) throws Exception {
|
||||
LOG.debug("called toConcessione for: " + concessione);
|
||||
|
||||
if (concessione == null)
|
||||
|
@ -185,6 +192,9 @@ public class ConvertToDataViewModel {
|
|||
theConcessione.setTitolariCopyright(concessione.getTitolareCopyright());
|
||||
theConcessione.setTitolariLicenza(concessione.getTitolareLicenza());
|
||||
theConcessione.setTitolari(concessione.getTitolari());
|
||||
|
||||
if(includeValidationReport)
|
||||
theConcessione.setValidationReport(toValidationReport(concessione.getReport()));
|
||||
|
||||
LOG.debug("Returning base concessione: " + theConcessione);
|
||||
return theConcessione;
|
||||
|
@ -195,6 +205,21 @@ public class ConvertToDataViewModel {
|
|||
|
||||
}
|
||||
|
||||
public static ValidationReportDV toValidationReport(ValidationReport validationReport) throws Exception {
|
||||
LOG.debug("called toValidationReport for: " + validationReport);
|
||||
|
||||
if (validationReport == null)
|
||||
return null;
|
||||
|
||||
ValidationReportDV theVR = new ValidationReportDV();
|
||||
theVR.setErrorMessages(validationReport.getErrorMessages());
|
||||
theVR.setObjectName(validationReport.getObjectName());
|
||||
theVR.setStatus(ValidationStatus.valueOf(validationReport.getStatus().name()));
|
||||
theVR.setWarningMessages(validationReport.getWarningMessages());
|
||||
theVR.setAsJSONString(toJSON(validationReport));
|
||||
return theVR;
|
||||
}
|
||||
|
||||
/**
|
||||
* To base concessione.
|
||||
*
|
||||
|
@ -441,7 +466,7 @@ public class ConvertToDataViewModel {
|
|||
* @return the layer concessione data view
|
||||
*/
|
||||
public static LayerConcessioneDV toLayerConcessione(LayerConcessione layerConcessione,
|
||||
BaseConcessioneDV refersToBaseConcessione) {
|
||||
BaseConcessioneDV refersToBaseConcessione) {
|
||||
|
||||
if (layerConcessione == null)
|
||||
return null;
|
||||
|
@ -585,4 +610,26 @@ public class ConvertToDataViewModel {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To JSON.
|
||||
*
|
||||
* @param <T> the generic type
|
||||
* @param report the report
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelaz
|
|||
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV;
|
||||
|
||||
/**
|
||||
* The Class ConcessioneDV.
|
||||
|
@ -91,6 +92,8 @@ public class ConcessioneDV extends BaseConcessioneDV implements Serializable {
|
|||
/** The generic content. */
|
||||
private List<OtherContentDV> genericContent = new ArrayList<OtherContentDV>();
|
||||
|
||||
private ValidationReportDV validationReport = null;
|
||||
|
||||
/**
|
||||
* Instantiates a new concessione.
|
||||
*/
|
||||
|
@ -494,6 +497,29 @@ public class ConcessioneDV extends BaseConcessioneDV implements Serializable {
|
|||
this.abstractRelazioneScavo = abstractRelazioneScavo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the validation report.
|
||||
*
|
||||
* @return the validation report
|
||||
*/
|
||||
public ValidationReportDV getValidationReport() {
|
||||
return validationReport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the validation report.
|
||||
*
|
||||
* @param validationReport the new validation report
|
||||
*/
|
||||
public void setValidationReport(ValidationReportDV validationReport) {
|
||||
this.validationReport = validationReport;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
|
Loading…
Reference in New Issue