Made the code "more robust" (adding some try/catch and checking null
value)
This commit is contained in:
parent
3c12d6a841
commit
0d4428e341
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,6 +68,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,6 +114,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,6 +160,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -202,6 +206,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -247,6 +252,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -295,6 +301,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -340,6 +347,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -385,6 +393,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -430,6 +439,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ public class GeoportalDataViewerConstants {
|
||||||
var tabCell = tr.insertCell(-1);
|
var tabCell = tr.insertCell(-1);
|
||||||
var theValue = jsonObj[j][col[i]];
|
var theValue = jsonObj[j][col[i]];
|
||||||
//console.log("the value: "+theValue);
|
//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 = "";
|
var formattedValueArray = "";
|
||||||
for (var k = 0; k < theValue.length; k++) {
|
for (var k = 0; k < theValue.length; k++) {
|
||||||
var theValueArray = theValue[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.ButtonType;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||||
import com.google.gwt.core.client.GWT;
|
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.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
@ -48,19 +50,24 @@ public class SectionViewer extends Composite {
|
||||||
sectionTitle.setTitle(sectionView.getSectionTitle());
|
sectionTitle.setTitle(sectionView.getSectionTitle());
|
||||||
sectionTitle.setText(sectionView.getSectionTitle());
|
sectionTitle.setText(sectionView.getSectionTitle());
|
||||||
|
|
||||||
|
if (subDocuments == null)
|
||||||
|
return;
|
||||||
|
|
||||||
Button goToTop = new Button("");
|
Button goToTop = new Button("");
|
||||||
goToTop.setType(ButtonType.LINK);
|
goToTop.setType(ButtonType.LINK);
|
||||||
goToTop.setIcon(IconType.DOUBLE_ANGLE_UP);
|
goToTop.setIcon(IconType.DOUBLE_ANGLE_UP);
|
||||||
goToTop.setHref("#"+topTargetId);
|
goToTop.setHref("#" + topTargetId);
|
||||||
goToTop.setTitle("Go to top");
|
goToTop.setTitle("Go to top");
|
||||||
goToTop.getElement().setClassName("go-top-right");
|
goToTop.getElement().setClassName("go-top-right");
|
||||||
|
|
||||||
sectionTitle.add(goToTop);
|
sectionTitle.add(goToTop);
|
||||||
|
|
||||||
boolean displayAsGallery = false;
|
boolean displayAsGallery = false;
|
||||||
|
|
||||||
|
try {
|
||||||
for (SubDocumentView subDocumentView : subDocuments) {
|
for (SubDocumentView subDocumentView : subDocuments) {
|
||||||
if (subDocumentView.getListImages() != null && subDocumentView.getListImages().size() > 0) {
|
if (subDocumentView.getListImages() != null && subDocumentView.getListImages().size() > 0) {
|
||||||
GWT.log("Section with images: "+subDocumentView.getListImages());
|
GWT.log("Section with images: " + subDocumentView.getListImages());
|
||||||
displayAsGallery = true;
|
displayAsGallery = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +76,7 @@ public class SectionViewer extends Composite {
|
||||||
boolean displayAsMapOfLayers = false;
|
boolean displayAsMapOfLayers = false;
|
||||||
for (SubDocumentView subDocumentView : subDocuments) {
|
for (SubDocumentView subDocumentView : subDocuments) {
|
||||||
if (subDocumentView.getListLayers() != null && subDocumentView.getListLayers().size() > 0) {
|
if (subDocumentView.getListLayers() != null && subDocumentView.getListLayers().size() > 0) {
|
||||||
GWT.log("Section with layers: "+subDocumentView.getListImages());
|
GWT.log("Section with layers: " + subDocumentView.getListImages());
|
||||||
displayAsMapOfLayers = true;
|
displayAsMapOfLayers = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -77,14 +84,22 @@ public class SectionViewer extends Composite {
|
||||||
|
|
||||||
// Displaying the whole section as a Gallery
|
// Displaying the whole section as a Gallery
|
||||||
if (displayAsGallery) {
|
if (displayAsGallery) {
|
||||||
GWT.log("displayAsGallery the: "+sectionView);
|
GWT.log("displayAsGallery the: " + sectionView);
|
||||||
ImagesSectionGallery sectionGallery = new ImagesSectionGallery(sectionView);
|
ImagesSectionGallery sectionGallery = new ImagesSectionGallery(sectionView);
|
||||||
sectionPanelContainer.add(sectionGallery.getGalleryPanel());
|
sectionPanelContainer.add(sectionGallery.getGalleryPanel());
|
||||||
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
sectionGallery.fillGallery();
|
sectionGallery.fillGallery();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
// Displaying the whole section as a Map of Layers
|
// Displaying the whole section as a Map of Layers
|
||||||
} else if (displayAsMapOfLayers) {
|
} else if (displayAsMapOfLayers) {
|
||||||
GWT.log("displayAsMapOfLayers the: "+sectionView);
|
GWT.log("displayAsMapOfLayers the: " + sectionView);
|
||||||
for (SubDocumentView subDocumentView : subDocuments) {
|
for (SubDocumentView subDocumentView : subDocuments) {
|
||||||
// String table = GeoportalDataViewerConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON());
|
// String table = GeoportalDataViewerConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON());
|
||||||
// sectionPanelContainer.add(new HTML(table));
|
// sectionPanelContainer.add(new HTML(table));
|
||||||
|
@ -92,15 +107,16 @@ public class SectionViewer extends Composite {
|
||||||
List<GCubeSDIViewerLayerDV> layers = subDocumentView.getListLayers();
|
List<GCubeSDIViewerLayerDV> layers = subDocumentView.getListLayers();
|
||||||
if (layers != null) {
|
if (layers != null) {
|
||||||
for (GCubeSDIViewerLayerDV gCubeLayer : layers) {
|
for (GCubeSDIViewerLayerDV gCubeLayer : layers) {
|
||||||
LayersSectionViewer layerSectionViewer = new LayersSectionViewer(gCubeLayer, subDocumentView);
|
LayersSectionViewer layerSectionViewer = new LayersSectionViewer(gCubeLayer,
|
||||||
|
subDocumentView);
|
||||||
sectionPanelContainer.add(layerSectionViewer);
|
sectionPanelContainer.add(layerSectionViewer);
|
||||||
//showLinkToDownloadWsContent(fileset.getName(), fileset.getListPayload());
|
// showLinkToDownloadWsContent(fileset.getName(), fileset.getListPayload());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}else {
|
} else {
|
||||||
GWT.log("displaying default the: "+sectionView);
|
GWT.log("displaying default the: " + sectionView);
|
||||||
for (SubDocumentView subDocumentView : subDocuments) {
|
for (SubDocumentView subDocumentView : subDocuments) {
|
||||||
String table = GeoportalDataViewerConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON());
|
String table = GeoportalDataViewerConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON());
|
||||||
sectionPanelContainer.add(new HTML(table));
|
sectionPanelContainer.add(new HTML(table));
|
||||||
|
@ -113,6 +129,9 @@ public class SectionViewer extends Composite {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} 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) {
|
if (theObjectFieldValue instanceof String) {
|
||||||
String toString = (String) theObjectFieldValue;
|
String toString = (String) theObjectFieldValue;
|
||||||
if (toString != null && !toString.isEmpty()) {
|
if (toString != null && !toString.isEmpty()) {
|
||||||
toDoc.append(fieldLabel, theObjectFieldValue);
|
toDoc.append(fieldLabel, toString.trim());
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("Skipping String field " + fieldLabel + " its value is null or empty");
|
LOG.debug("Skipping String field " + fieldLabel + " its value is null or empty");
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
|
|
||||||
return [ year, month, day ].join('-');
|
return [ year, month, day ].join('-');
|
||||||
}
|
}
|
||||||
return "";
|
return date + "";
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return date + "";
|
return date + "";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue