Compare commits
40 Commits
task_24166
...
master
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry including="**/*.java" kind="src" output="target/geoportal-data-entry-app-3.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry including="**/*.java" kind="src" output="target/geoportal-data-entry-app-3.2.0/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
@ -31,5 +31,5 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/geoportal-data-entry-app-3.2.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/geoportal-data-entry-app-3.2.0/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
eclipse.preferences.version=1
|
||||
jarsExcludedFromWebInfLib=
|
||||
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-3.2.0-SNAPSHOT
|
||||
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-3.2.0
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
|
@ -111,7 +111,13 @@
|
|||
|
||||
|
||||
|
||||
<wb-module deploy-name="geoportal-data-entry-app-3.2.0-SNAPSHOT">
|
||||
|
||||
|
||||
|
||||
<wb-module deploy-name="geoportal-data-entry-app-3.2.0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -316,6 +322,9 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -429,6 +438,9 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -494,6 +506,9 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -607,6 +622,9 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -720,6 +738,9 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -833,6 +854,9 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -946,6 +970,9 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -4,14 +4,22 @@
|
|||
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).
|
||||
|
||||
## [v3.2.0-SNAPSHOT] - 2022-05-11
|
||||
## [v3.2.2] - 2024-01-11
|
||||
|
||||
- Improved display of results on multiple fields (in the table) [#26372]
|
||||
|
||||
## [v3.2.1] - 2023-06-16
|
||||
|
||||
- Fixed issue in the Search facility [#25265]
|
||||
|
||||
## [v3.2.0] - 2023-05-12
|
||||
|
||||
- Implemented the Update facility [#24166]
|
||||
- Integrated with the geoportal-data-mapper library [#24244]
|
||||
- Integrated the Geoportal Data-Viewer Widget [#25015]
|
||||
- Passed to Geoportal_Resolver service [#25031]
|
||||
- Provided the "View Document" and "View As JSON" facilities
|
||||
- DELETE relation" operation allowed only in DRAFT phase [#25104]
|
||||
- DELETE relation operation allowed only in DRAFT phase [#25104]
|
||||
|
||||
## [v3.1.0] - 2023-03-06
|
||||
|
||||
|
@ -49,6 +57,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
- [#23913] Integrated with GUI presentation configurations read from IS
|
||||
- [#23926] Integrated a Post Creation Action in the UCD and manage it
|
||||
- [#24136] Integrated the temporal dimension on the front-end side
|
||||
- [#24458] Published projects cannot be edited/updated
|
||||
|
||||
|
||||
## [v2.2.1] - 2022-06-29
|
||||
|
|
34
README.md
34
README.md
|
@ -1,6 +1,6 @@
|
|||
# GeoPortal Data Entry App
|
||||
|
||||
The GeoPortal Data Entry App is an application to build the web forms for data entries needed to create projects/documents (based on UCD) in the D4Science Geoportal service
|
||||
Geoportal data-entry technology allows the actors who use it, the project management of spatio-temporal documents specified by meta-documents called "Use Case Descriptor" (UCD) which determine the document model, management, life cycle, etc. The system allows you to: (i) access and search for published projects by role for VRE, (ii) access the project publication report, view the publication status (SUCCESS, WARNING, ERROR), etc., (iii ) generate links for visualization on the map, (iv) update the contents of the registered projects through the workflow, (v) manage the relationships (quantity and quality temporal links) between the documents. In general, the technology allows the data entry of any document having spatio-temporal characteristics, whose metadata and payload are specified by one or more "gCube Profile" profiles which determine the structure of the resulting document (JSON).
|
||||
|
||||
## Built With
|
||||
|
||||
|
@ -18,14 +18,42 @@ The GeoPortal Data Entry App is an application to build the web forms for data e
|
|||
|
||||
<img src="https://gcube.wiki.gcube-system.org/images_gcube/8/8e/GeoPortalDataEntry_Architecture.png" style="max-width:800px;" alt="GeoPortal Data-Entry - Architecture" />
|
||||
|
||||
## Showcase
|
||||
|
||||
##### D4GNA instance of Geoportal D4Science
|
||||
|
||||
see at [Dataset per il Geoportale Nazionale per l’Archeologia (D4GNA)](https://gna.d4science.org/)
|
||||
|
||||
**New Project facility**
|
||||
|
||||
<img src="https://gcube.wiki.gcube-system.org/images_gcube/c/c0/D4GNA_New_Project.png" style="max-width:800px;" alt="Workspace Home" />
|
||||
|
||||
**List of Projects facility**
|
||||
|
||||
<img src="https://gcube.wiki.gcube-system.org/images_gcube/6/67/D4GNA_List_Of_Projects.png" style="max-width:800px;" alt="List of Projects" />
|
||||
|
||||
|
||||
**UnPublish facility**
|
||||
|
||||
<img src="https://gcube.wiki.gcube-system.org/images_gcube/6/6a/D4GNA_Unpublish.png" style="max-width:800px;" alt="UnPublish" />
|
||||
|
||||
|
||||
**View Relations facility**
|
||||
|
||||
<img src="https://gcube.wiki.gcube-system.org/images_gcube/7/76/D4GNA_ViewRelations.png" style="max-width:800px;" alt="View Relations" />
|
||||
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
Geoportal Service Documentation is available at [gCube CMS Suite](https://geoportal.d4science.org/geoportal-service/docs/index.html)
|
||||
|
||||
User Guide (DRAFT ITA) is available at [Guida al Sistema D4GNA (DRAFT-ITA)](https://gcube.wiki.gcube-system.org/images_gcube/b/b7/D4science_Guida_al_Sistema_D4GNA_bozza.pdf)
|
||||
|
||||
D4GNA Use Case - 3 Phase Lifecycle
|
||||
|
||||
<img src="https://gcube.wiki.gcube-system.org/images_gcube/4/46/D4GNA_Workflow_Phases_and_Operations.png" style="max-width:800px;" alt="GeoPortal Data-Entry - Workflow & Phases & Operations" />
|
||||
|
||||
Geoportal Service Documentation is available at [gCube CMS Suite](https://geoportal.d4science.org/geoportal-service/docs/index.html)
|
||||
|
||||
## Change log
|
||||
|
||||
See the [Releases](https://code-repo.d4science.org/gCubeSystem/geoportal-data-entry-app/releases)
|
||||
|
|
12
pom.xml
12
pom.xml
|
@ -7,14 +7,14 @@
|
|||
<parent>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<version>1.1.0</version>
|
||||
<version>1.2.0</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>geoportal-data-entry-app</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>3.2.0-SNAPSHOT</version>
|
||||
<version>3.2.2</version>
|
||||
<name>GeoPortal Data Entry App</name>
|
||||
<description>The GeoPortal Data Entry App is an application to build the web forms for data entries needed to create projects/documents (based on UCD) in the D4Science Geoportal service</description>
|
||||
<scm>
|
||||
|
@ -25,7 +25,7 @@
|
|||
|
||||
<properties>
|
||||
<!-- Convenience property to set the GWT version -->
|
||||
<gwt.version>2.10.0</gwt.version>
|
||||
<gwt.version>2.9.0</gwt.version>
|
||||
<!-- GWT needs at least java 1.6 -->
|
||||
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -51,7 +51,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>maven-portal-bom</artifactId>
|
||||
<version>3.8.0-SNAPSHOT</version>
|
||||
<version>3.7.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -95,14 +95,14 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>geoportal-data-viewer-widget</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<version>[1.0.1, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-data-mapper</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<version>[1.0.1, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -837,14 +837,10 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO MUST MANAGE getListOfRecordsEvent.isReloadFilteringParameters()
|
||||
|
||||
searchingFilter.setProjection(seachingFilterParameters.getProjection());
|
||||
|
||||
List<ItemFieldDV> displayFields = seachingFilterParameters.getDisplayFields();
|
||||
|
||||
grpw = new GeonaRecordsPaginatedView(appManagerBus, profileID, displayFields, searchingFilter);
|
||||
|
||||
mainTabPanel.showListOfProjectsView(grpw);
|
||||
|
||||
// The Project Type is changed
|
||||
|
|
|
@ -15,7 +15,7 @@ public class GetListOfRecordsEvent extends GwtEvent<GetListOfRecordsEventHandler
|
|||
|
||||
/** The type. */
|
||||
public static Type<GetListOfRecordsEventHandler> TYPE = new Type<GetListOfRecordsEventHandler>();
|
||||
private SearchingFilter sortFilter;
|
||||
private SearchingFilter searchingFilter;
|
||||
private String profileID;
|
||||
private String projectName;
|
||||
private Boolean reloadFilteringParameters = false;
|
||||
|
@ -26,13 +26,13 @@ public class GetListOfRecordsEvent extends GwtEvent<GetListOfRecordsEventHandler
|
|||
*
|
||||
* @param onApplicationInit the on application init
|
||||
* @param profileID the profile ID
|
||||
* @param sortFilter the sort filter
|
||||
* @param searchingFilter the searching filter
|
||||
* @param reloadFilteringParameters the reload filtering parameters
|
||||
*/
|
||||
public GetListOfRecordsEvent(boolean onApplicationInit, String profileID, SearchingFilter sortFilter,
|
||||
public GetListOfRecordsEvent(boolean onApplicationInit, String profileID, SearchingFilter searchingFilter,
|
||||
Boolean reloadFilteringParameters) {
|
||||
this.onApplicationInit = onApplicationInit;
|
||||
this.sortFilter = sortFilter;
|
||||
this.searchingFilter = searchingFilter;
|
||||
this.profileID = profileID;
|
||||
this.reloadFilteringParameters = reloadFilteringParameters;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class GetListOfRecordsEvent extends GwtEvent<GetListOfRecordsEventHandler
|
|||
* @return the searching filter
|
||||
*/
|
||||
public SearchingFilter getSearchingFilter() {
|
||||
return sortFilter;
|
||||
return searchingFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,8 +113,8 @@ public class GetListOfRecordsEvent extends GwtEvent<GetListOfRecordsEventHandler
|
|||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GetListOfRecordsEvent [sortFilter=");
|
||||
builder.append(sortFilter);
|
||||
builder.append("GetListOfRecordsEvent [searchingFilter=");
|
||||
builder.append(searchingFilter);
|
||||
builder.append(", profileID=");
|
||||
builder.append(profileID);
|
||||
builder.append(", projectName=");
|
||||
|
|
|
@ -50,7 +50,6 @@ public class GeonaRecordsPaginatedView {
|
|||
private MyCustomDataProvider<DocumentDV> dataProvider = new MyCustomDataProvider<DocumentDV>();
|
||||
protected Widget orginalLoadingIndicator = null;
|
||||
private LoaderIcon loadingPanel = new LoaderIcon("Loading data...");
|
||||
// private int serverStartIndex;
|
||||
private HandlerManager eventBus;
|
||||
private SearchingFilter currentSearchingFilter;
|
||||
private String profileID;
|
||||
|
@ -74,7 +73,6 @@ public class GeonaRecordsPaginatedView {
|
|||
|
||||
orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator();
|
||||
initPagination(ITEMS_PER_PAGE);
|
||||
// loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, false);
|
||||
loadItemsForType(profileID);
|
||||
}
|
||||
|
||||
|
@ -121,27 +119,23 @@ public class GeonaRecordsPaginatedView {
|
|||
* @param startIdx the start idx
|
||||
* @param limit the limit
|
||||
* @param resetStore the reset store
|
||||
* @param currentSortFilter the current sort filter
|
||||
* @param currentSearchFilter the current search filter
|
||||
* @param invalidCache the invalid cache
|
||||
*/
|
||||
private void loadNewPage(String profileID, final int startIdx, final int limit, final boolean resetStore,
|
||||
final SearchingFilter currentSortFilter, final boolean invalidCache) {
|
||||
// initFirstRangeChanged = resetStore;
|
||||
final SearchingFilter currentSearchFilter, final boolean invalidCache) {
|
||||
GWT.log("loadNewPage with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:"
|
||||
+ resetStore + "]");
|
||||
// showLoading(true);
|
||||
|
||||
int newStartIndex = startIdx;
|
||||
|
||||
if (resetStore) {
|
||||
GWT.log("Cleaning all data...");
|
||||
newStartIndex = 0;
|
||||
// serverStartIndex = 0;
|
||||
GWT.log("Store reset performed start index is: " + newStartIndex);
|
||||
getTableDataProvider().updateRowCount(ITEMS_PER_PAGE, false);
|
||||
}
|
||||
|
||||
loadProjects(profileID, newStartIndex, limit, currentSortFilter, invalidCache);
|
||||
loadProjects(profileID, newStartIndex, limit, currentSearchFilter, invalidCache);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -194,6 +188,16 @@ public class GeonaRecordsPaginatedView {
|
|||
}
|
||||
// initFirstRangeChanged = false;
|
||||
|
||||
//printData((List<DocumentDV>) result.getData());
|
||||
}
|
||||
|
||||
private void printData(List<DocumentDV> data) {
|
||||
GWT.log("printData");
|
||||
int i = 0;
|
||||
for (DocumentDV documentDV : data) {
|
||||
GWT.log(++i + ") json: " + documentDV.getDocumentAsJSON());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -221,17 +225,17 @@ public class GeonaRecordsPaginatedView {
|
|||
* @param theProfileID the the profile ID
|
||||
* @param newStartIndex the new start index
|
||||
* @param limit the limit
|
||||
* @param sortFilter the sort filter
|
||||
* @param searchFilter the search filter
|
||||
* @param invalidCache the invalid cache
|
||||
*/
|
||||
private <T> void loadProjects(String theProfileID, int newStartIndex, int limit, SearchingFilter sortFilter,
|
||||
private <T> void loadProjects(String theProfileID, int newStartIndex, int limit, SearchingFilter searchFilter,
|
||||
boolean invalidCache) {
|
||||
showLoading(true);
|
||||
|
||||
GWT.log("calling loadItemsForStatus with parameters [theProfileID: " + theProfileID + ", startIndex: "
|
||||
+ newStartIndex + ", limit: " + limit + ", sortFilter: " + sortFilter + "]");
|
||||
GeoPortalDataEntryApp.geoportalDataEntryService.getListProjects(theProfileID, newStartIndex, limit, sortFilter,
|
||||
invalidCache, new AsyncCallback<ResultSetPaginatedData>() {
|
||||
+ newStartIndex + ", limit: " + limit + ", searchFilter: " + searchFilter + "]");
|
||||
GeoPortalDataEntryApp.geoportalDataEntryService.getListProjects(theProfileID, newStartIndex, limit,
|
||||
searchFilter, invalidCache, new AsyncCallback<ResultSetPaginatedData>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -266,6 +270,11 @@ public class GeonaRecordsPaginatedView {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the column.
|
||||
*
|
||||
* @param columnName the column name
|
||||
*/
|
||||
public void removeColumn(DEFAULT_DISPLAYING_COLUMN_NAME columnName) {
|
||||
try {
|
||||
itemsTable.removeColumn(columnName);
|
||||
|
@ -283,9 +292,6 @@ public class GeonaRecordsPaginatedView {
|
|||
return itemsTable.getSelectedItems();
|
||||
}
|
||||
|
||||
// int latestRangeStart = -1;
|
||||
// int latestRangeLenght = -1;
|
||||
|
||||
/**
|
||||
* A custom {@link AsyncDataProvider}.
|
||||
*
|
||||
|
@ -310,15 +316,6 @@ public class GeonaRecordsPaginatedView {
|
|||
int start = range.getStart();
|
||||
int length = range.getLength();
|
||||
|
||||
// if(latestRangeStart!=start || latestRangeLenght!=length) {
|
||||
// GWT.log("ranges really changed");
|
||||
// latestRangeStart = start;
|
||||
// latestRangeLenght = length;
|
||||
// }else {
|
||||
// GWT.log("ranges DO NOT changed");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (initClassFirstRangeChanged) {
|
||||
GWT.log("initClassFirstRangeChanged is true.. returning");
|
||||
initClassFirstRangeChanged = false;
|
||||
|
@ -326,8 +323,6 @@ public class GeonaRecordsPaginatedView {
|
|||
}
|
||||
GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount());
|
||||
loadNewPage(profileID, start, length, false, currentSearchingFilter, false);
|
||||
// eventBus.fireEvent(new TableRangeViewChangedEvent<T>(start, length));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class JSONEditorWrapper extends JavaScriptObject {
|
|||
console.log("JSONEditorWrapper error: " + error)
|
||||
}
|
||||
};
|
||||
console.log("container is: " + container);
|
||||
//console.log("container is: " + container);
|
||||
return new $wnd.JSONEditor(container, options);
|
||||
}-*/;
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class JSONEditorWrapper extends JavaScriptObject {
|
|||
public final native void set(String json) /*-{
|
||||
var toJSONObject = JSON.parse(json);
|
||||
// set json
|
||||
console.log("displayng JSON: " + toJSONObject);
|
||||
//console.log("displayng JSON: " + toJSONObject);
|
||||
this.set(toJSONObject);
|
||||
this.refresh();
|
||||
}-*/;
|
||||
|
@ -58,7 +58,7 @@ public class JSONEditorWrapper extends JavaScriptObject {
|
|||
* @return the text
|
||||
*/
|
||||
public final native String getText() /*-{
|
||||
console.log("this.get(): " +this.getText());
|
||||
//console.log("this.get(): " +this.getText());
|
||||
return this.getText();
|
||||
}-*/;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.ui.projects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -346,21 +347,25 @@ public class ListOfProjectTablePanel extends Composite {
|
|||
if (searchText != null && !searchText.isEmpty()) {
|
||||
Map<String, Object> searchInto = new HashMap<String, Object>();
|
||||
|
||||
String searchForField = "";
|
||||
List<String> listOfSeachingFields = new ArrayList<String>();
|
||||
|
||||
for (ItemFieldDV recordField : cacheSearchingFilterParameters.getSearchByFields()) {
|
||||
if (recordField.getDisplayName().equals(alertSearchFor.getText())) {
|
||||
searchForField = recordField.getJsonFields().get(0);
|
||||
listOfSeachingFields = recordField.getJsonFields();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
searchInto.put(searchForField, searchText);
|
||||
|
||||
for (String fieldname : listOfSeachingFields) {
|
||||
searchInto.put(fieldname, searchText);
|
||||
}
|
||||
|
||||
WhereClause where = new WhereClause();
|
||||
where.setSearchInto(searchInto);
|
||||
where.setOperator(LOGICAL_OP.OR);
|
||||
|
||||
searchingFilter.setConditions(Arrays.asList(where));
|
||||
}
|
||||
|
||||
return searchingFilter;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.google.gwt.core.shared.GWT;
|
|||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
|
||||
import com.google.gwt.safehtml.shared.SafeHtml;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
|
||||
|
@ -102,6 +103,127 @@ public class ItemsTable<T extends DocumentDV> extends AbstractItemsCellTable<T>
|
|||
super.addItems(items);
|
||||
}
|
||||
|
||||
class CellRender {
|
||||
|
||||
String tooltip;
|
||||
String value;
|
||||
|
||||
public CellRender() {
|
||||
}
|
||||
|
||||
public String getTooltip() {
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setTooltip(String tooltip) {
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public CellRender toCellRender(ItemFieldDV itemField, DocumentDV documentDV) {
|
||||
|
||||
StringBuilder tooltipBuilder = new StringBuilder();
|
||||
StringBuilder valueBuilder = new StringBuilder();
|
||||
String newLine = "<br>";
|
||||
String newLineTxt = "\n";
|
||||
String bullet = "• "; // it is the dot. As <li> rendered in the <ul> tag
|
||||
|
||||
String newBullet = newLine + bullet;
|
||||
|
||||
List<String> listJsonFields = itemField.getJsonFields();
|
||||
|
||||
int numberOfFields = listJsonFields.size();
|
||||
|
||||
if (numberOfFields > 1) {
|
||||
valueBuilder.append(bullet);
|
||||
}
|
||||
|
||||
for (String jsonKey : listJsonFields) {
|
||||
|
||||
try {
|
||||
String objectToRender = "";
|
||||
// removing the '_theDocument.' prefix for searching in the Document Map
|
||||
String key = jsonKey.replace(ConstantsGeoPortalDataEntryApp.DEFAULT_DOCUMENT_PROJECTION_NAME + ".", "");
|
||||
Object value = documentDV.getDocumentAsMap().get(key);
|
||||
// GWT.log("key: "+key+" is instance of: "+value.getClass());
|
||||
|
||||
if (value == null)
|
||||
continue;
|
||||
|
||||
GWT.log("value instance: " + value.getClass());
|
||||
|
||||
if (value instanceof ArrayList) {
|
||||
ArrayList<Object> arrayValues = (ArrayList<Object>) value;
|
||||
String toReturn = "<ul>";
|
||||
for (Object arrayValue : arrayValues) {
|
||||
toReturn += "<li>" + arrayValue + "</li>";
|
||||
}
|
||||
toReturn += "</ul>";
|
||||
GWT.log("Array returning: " + key + " is instance of: " + value.getClass() + " to return: "
|
||||
+ toReturn);
|
||||
objectToRender = StringUtil.ellipsize(toReturn, MAX_TEXT_DIMENSION);
|
||||
} else {
|
||||
objectToRender = StringUtil.ellipsize(value.toString(), MAX_TEXT_DIMENSION);
|
||||
}
|
||||
|
||||
valueBuilder.append(objectToRender);
|
||||
valueBuilder.append(newBullet);
|
||||
|
||||
if (numberOfFields > 1) {
|
||||
tooltipBuilder.append("* " + key + newLineTxt);
|
||||
}else {
|
||||
tooltipBuilder.append(key);
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
GWT.log("Error e: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
CellRender cellRender = new CellRender();
|
||||
|
||||
String toRender = valueBuilder.toString();
|
||||
cellRender.setValue(toRender.substring(0, toRender.length() - newBullet.length()));
|
||||
|
||||
String toTooltip = tooltipBuilder.toString();
|
||||
toTooltip = numberOfFields > 1 ? toTooltip.substring(0, toTooltip.length() - newLineTxt.length())
|
||||
: toTooltip;
|
||||
cellRender.setTooltip(toTooltip);
|
||||
|
||||
return cellRender;
|
||||
|
||||
}
|
||||
|
||||
interface Templates extends SafeHtmlTemplates {
|
||||
|
||||
/**
|
||||
* Start tool tip.
|
||||
*
|
||||
* @param toolTipText the tool tip text
|
||||
* @return the safe html
|
||||
*/
|
||||
@Template("<span title=\"{0}\">")
|
||||
SafeHtml startToolTip(String toolTipText);
|
||||
|
||||
/**
|
||||
* End tool tip.
|
||||
*
|
||||
* @return the safe html
|
||||
*/
|
||||
@Template("</span>")
|
||||
SafeHtml endToolTip();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits the table.
|
||||
*
|
||||
|
@ -130,27 +252,10 @@ public class ItemsTable<T extends DocumentDV> extends AbstractItemsCellTable<T>
|
|||
String displayName = itemField.getDisplayName();
|
||||
|
||||
TextColumn<T> col = new TextColumn<T>() {
|
||||
|
||||
@Override
|
||||
public String getValue(T object) {
|
||||
|
||||
if (object == null)
|
||||
return "";
|
||||
|
||||
DocumentDV documentDV = (DocumentDV) object;
|
||||
|
||||
try {
|
||||
// removing the '_theDocument.' prefix for searching in the Document Map
|
||||
String key = itemField.getJsonFields().get(0)
|
||||
.replace(ConstantsGeoPortalDataEntryApp.DEFAULT_DOCUMENT_PROJECTION_NAME + ".", "");
|
||||
Object value = documentDV.getDocumentAsMap().get(key);
|
||||
if(value==null)
|
||||
return "";
|
||||
|
||||
return value.toString();
|
||||
} catch (Exception e) {
|
||||
GWT.log("Error e: " + e);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -158,39 +263,12 @@ public class ItemsTable<T extends DocumentDV> extends AbstractItemsCellTable<T>
|
|||
public void render(com.google.gwt.cell.client.Cell.Context context, T object, SafeHtmlBuilder sb) {
|
||||
if (object == null)
|
||||
return;
|
||||
Templates TEMPLATES = GWT.create(Templates.class);
|
||||
|
||||
DocumentDV documentDV = (DocumentDV) object;
|
||||
String objectToRender = "";
|
||||
try {
|
||||
// removing the '_theDocument.' prefix for searching in the Document Map
|
||||
String key = itemField.getJsonFields().get(0)
|
||||
.replace(ConstantsGeoPortalDataEntryApp.DEFAULT_DOCUMENT_PROJECTION_NAME + ".", "");
|
||||
Object value = documentDV.getDocumentAsMap().get(key);
|
||||
// GWT.log("key: "+key+" is instance of: "+value.getClass());
|
||||
|
||||
if(value==null)
|
||||
return;
|
||||
|
||||
if (value instanceof ArrayList) {
|
||||
ArrayList<Object> arrayValues = (ArrayList<Object>) value;
|
||||
String toReturn = "<ul>";
|
||||
for (Object arrayValue : arrayValues) {
|
||||
toReturn += "<li>" + arrayValue + "</li>";
|
||||
}
|
||||
toReturn += "</ul>";
|
||||
GWT.log("Array returning: " + key + " is instance of: " + value.getClass() + " to return: "
|
||||
+ toReturn);
|
||||
objectToRender = StringUtil.ellipsize(toReturn, MAX_TEXT_DIMENSION);
|
||||
} else {
|
||||
objectToRender = StringUtil.ellipsize(value.toString(), MAX_TEXT_DIMENSION);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
GWT.log("Error e: " + e);
|
||||
}
|
||||
sb.appendHtmlConstant(objectToRender);
|
||||
// super.render(context, object, sb);
|
||||
// sb.appendHtmlConstant("</span>");
|
||||
CellRender cellRender = toCellRender(itemField, object);
|
||||
sb.append(TEMPLATES.startToolTip(cellRender.getTooltip()));
|
||||
sb.appendHtmlConstant(cellRender.getValue());
|
||||
sb.append(TEMPLATES.endToolTip());
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue