Made the code "more robust" (adding some try/catch and checking null
value)
This commit is contained in:
parent
3c12d6a841
commit
0d4428e341
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -44,7 +45,8 @@
|
|||
|
||||
|
||||
<wb-module deploy-name="geoportal-data-viewer-app-3.1.0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -89,7 +91,8 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -134,7 +137,8 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -179,7 +183,8 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -224,7 +229,8 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -272,7 +278,8 @@
|
|||
<dependent-module archiveName="geoportal-data-common-2.0.1.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -317,7 +324,8 @@
|
|||
|
||||
|
||||
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -362,7 +370,8 @@
|
|||
|
||||
|
||||
<property name="context-root" value="geoportal-data-viewer-app"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -407,7 +416,8 @@
|
|||
|
||||
|
||||
</wb-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ public class GeoportalDataViewerConstants {
|
|||
var tabCell = tr.insertCell(-1);
|
||||
var theValue = jsonObj[j][col[i]];
|
||||
//console.log("the value: "+theValue);
|
||||
if (Object.prototype.toString.call(theValue) === '[object Array]') {
|
||||
if (theValue !== null && Object.prototype.toString.call(theValue) === '[object Array]') {
|
||||
var formattedValueArray = "";
|
||||
for (var k = 0; k < theValue.length; k++) {
|
||||
var theValueArray = theValue[k];
|
||||
|
|
|
@ -17,6 +17,8 @@ import com.github.gwtbootstrap.client.ui.PageHeader;
|
|||
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.Scheduler;
|
||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
|
@ -42,76 +44,93 @@ public class SectionViewer extends Composite {
|
|||
public SectionViewer(SectionView sectionView, String topTargetId) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.sectionView = sectionView;
|
||||
|
||||
|
||||
List<SubDocumentView> subDocuments = sectionView.getListSubDocuments();
|
||||
|
||||
sectionTitle.setTitle(sectionView.getSectionTitle());
|
||||
sectionTitle.setText(sectionView.getSectionTitle());
|
||||
|
||||
|
||||
if (subDocuments == null)
|
||||
return;
|
||||
|
||||
Button goToTop = new Button("");
|
||||
goToTop.setType(ButtonType.LINK);
|
||||
goToTop.setIcon(IconType.DOUBLE_ANGLE_UP);
|
||||
goToTop.setHref("#"+topTargetId);
|
||||
goToTop.setHref("#" + topTargetId);
|
||||
goToTop.setTitle("Go to top");
|
||||
goToTop.getElement().setClassName("go-top-right");
|
||||
|
||||
|
||||
sectionTitle.add(goToTop);
|
||||
|
||||
boolean displayAsGallery = false;
|
||||
for (SubDocumentView subDocumentView : subDocuments) {
|
||||
if (subDocumentView.getListImages() != null && subDocumentView.getListImages().size() > 0) {
|
||||
GWT.log("Section with images: "+subDocumentView.getListImages());
|
||||
displayAsGallery = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
boolean displayAsMapOfLayers = false;
|
||||
for (SubDocumentView subDocumentView : subDocuments) {
|
||||
if (subDocumentView.getListLayers() != null && subDocumentView.getListLayers().size() > 0) {
|
||||
GWT.log("Section with layers: "+subDocumentView.getListImages());
|
||||
displayAsMapOfLayers = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Displaying the whole section as a Gallery
|
||||
if (displayAsGallery) {
|
||||
GWT.log("displayAsGallery the: "+sectionView);
|
||||
ImagesSectionGallery sectionGallery = new ImagesSectionGallery(sectionView);
|
||||
sectionPanelContainer.add(sectionGallery.getGalleryPanel());
|
||||
sectionGallery.fillGallery();
|
||||
|
||||
// Displaying the whole section as a Map of Layers
|
||||
} else if (displayAsMapOfLayers) {
|
||||
GWT.log("displayAsMapOfLayers the: "+sectionView);
|
||||
try {
|
||||
for (SubDocumentView subDocumentView : subDocuments) {
|
||||
if (subDocumentView.getListImages() != null && subDocumentView.getListImages().size() > 0) {
|
||||
GWT.log("Section with images: " + subDocumentView.getListImages());
|
||||
displayAsGallery = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
boolean displayAsMapOfLayers = false;
|
||||
for (SubDocumentView subDocumentView : subDocuments) {
|
||||
if (subDocumentView.getListLayers() != null && subDocumentView.getListLayers().size() > 0) {
|
||||
GWT.log("Section with layers: " + subDocumentView.getListImages());
|
||||
displayAsMapOfLayers = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Displaying the whole section as a Gallery
|
||||
if (displayAsGallery) {
|
||||
GWT.log("displayAsGallery the: " + sectionView);
|
||||
ImagesSectionGallery sectionGallery = new ImagesSectionGallery(sectionView);
|
||||
sectionPanelContainer.add(sectionGallery.getGalleryPanel());
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
sectionGallery.fillGallery();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Displaying the whole section as a Map of Layers
|
||||
} else if (displayAsMapOfLayers) {
|
||||
GWT.log("displayAsMapOfLayers the: " + sectionView);
|
||||
for (SubDocumentView subDocumentView : subDocuments) {
|
||||
// String table = GeoportalDataViewerConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON());
|
||||
// sectionPanelContainer.add(new HTML(table));
|
||||
|
||||
List<GCubeSDIViewerLayerDV> layers = subDocumentView.getListLayers();
|
||||
if (layers != null) {
|
||||
for (GCubeSDIViewerLayerDV gCubeLayer : layers) {
|
||||
LayersSectionViewer layerSectionViewer = new LayersSectionViewer(gCubeLayer, subDocumentView);
|
||||
sectionPanelContainer.add(layerSectionViewer);
|
||||
//showLinkToDownloadWsContent(fileset.getName(), fileset.getListPayload());
|
||||
List<GCubeSDIViewerLayerDV> layers = subDocumentView.getListLayers();
|
||||
if (layers != null) {
|
||||
for (GCubeSDIViewerLayerDV gCubeLayer : layers) {
|
||||
LayersSectionViewer layerSectionViewer = new LayersSectionViewer(gCubeLayer,
|
||||
subDocumentView);
|
||||
sectionPanelContainer.add(layerSectionViewer);
|
||||
// showLinkToDownloadWsContent(fileset.getName(), fileset.getListPayload());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
GWT.log("displaying default the: "+sectionView);
|
||||
for (SubDocumentView subDocumentView : subDocuments) {
|
||||
String table = GeoportalDataViewerConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON());
|
||||
sectionPanelContainer.add(new HTML(table));
|
||||
|
||||
List<FilesetDV> files = subDocumentView.getListFiles();
|
||||
if (files != null) {
|
||||
for (FilesetDV fileset : files) {
|
||||
showLinkToDownloadWsContent(fileset.getName(), fileset.getListPayload());
|
||||
} else {
|
||||
GWT.log("displaying default the: " + sectionView);
|
||||
for (SubDocumentView subDocumentView : subDocuments) {
|
||||
String table = GeoportalDataViewerConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON());
|
||||
sectionPanelContainer.add(new HTML(table));
|
||||
|
||||
List<FilesetDV> files = subDocumentView.getListFiles();
|
||||
if (files != null) {
|
||||
for (FilesetDV fileset : files) {
|
||||
showLinkToDownloadWsContent(fileset.getName(), fileset.getListPayload());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
GWT.log("Error on rendering the section: "+e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -919,7 +919,7 @@ public class Geoportal_JSON_Mapper {
|
|||
if (theObjectFieldValue instanceof String) {
|
||||
String toString = (String) theObjectFieldValue;
|
||||
if (toString != null && !toString.isEmpty()) {
|
||||
toDoc.append(fieldLabel, theObjectFieldValue);
|
||||
toDoc.append(fieldLabel, toString.trim());
|
||||
} else {
|
||||
LOG.debug("Skipping String field " + fieldLabel + " its value is null or empty");
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
|
||||
return [ year, month, day ].join('-');
|
||||
}
|
||||
return "";
|
||||
return date + "";
|
||||
} catch (err) {
|
||||
return date + "";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue