Compare commits

...

41 Commits

Author SHA1 Message Date
Francesco Mangiacrapa 6dea686eca added comments. Fixed toString 2024-05-16 10:34:46 +02:00
Francesco Mangiacrapa 5ac20c21c0 removed -SNAPSHOT to be released 2024-03-19 10:19:26 +01:00
Francesco Mangiacrapa e34c151337 Merge pull request 'edit_facility_26115' (!3) from edit_facility_26115 into master
Reviewed-on: #3
2024-03-19 10:17:18 +01:00
Francesco Mangiacrapa 78f7a97385 Merge branch 'master' into edit_facility_26115 2024-03-19 10:17:04 +01:00
Francesco Mangiacrapa 51102c195d Added final to some properties. 2024-02-20 15:18:24 +01:00
Francesco Mangiacrapa 4829f5b959 Updated LoaderIcon 2024-02-16 10:15:52 +01:00
Francesco Mangiacrapa 16c2e98f90 updated the beans 2024-02-15 16:46:36 +01:00
Francesco Mangiacrapa 06b8f1d8d3 removed unused code 2024-02-15 16:27:39 +01:00
Francesco Mangiacrapa 4a25ddf5e4 Removed unused imports 2024-02-14 11:25:47 +01:00
Francesco Mangiacrapa 506df65613 removed catalogue package. Refactored Resource Events 2024-02-12 12:01:59 +01:00
Francesco Mangiacrapa cb9629d85a Updated. Managing addTagElement to Vocabulary 2024-02-08 12:32:20 +01:00
Francesco Mangiacrapa 67591125e6 refactored to CustomFieldEntryProfile 2024-02-05 14:10:57 +01:00
Francesco Mangiacrapa 845a8c4ece refactored beans 2024-02-02 17:00:07 +01:00
Francesco Mangiacrapa 471c1f373c Aligned to ckan-metadata-publisher-widget 2024-02-02 16:52:40 +01:00
Roberto Cirillo 69f0f0e7f7 Update 'pom.xml'
remove SNAPSHOT from maven-portal-bom declaration
2023-09-14 16:28:10 +02:00
Francesco Mangiacrapa f772818288 moved to maven-parent.1.2.0 2023-09-14 15:31:47 +02:00
Francesco Mangiacrapa 898695beea removed -SNAPSHOT to be released 2023-09-14 15:18:50 +02:00
Francesco Mangiacrapa 78c3c06d89 Merge pull request 'task_24166' (!2) from task_24166 into master
Reviewed-on: #2
2023-09-14 15:17:43 +02:00
Francesco Mangiacrapa 669dbb34e8 improved MetadataFieldWrapper by adding current values (as list) 2023-04-21 15:24:08 +02:00
Francesco Mangiacrapa ca51fc0543 in progress on Update Facility 2023-04-21 10:54:57 +02:00
Francesco Mangiacrapa a352933b68 managing the files already uploaded [#24515] 2023-03-28 16:13:21 +02:00
Francesco Mangiacrapa 77c41f2af2 #24515 First version implemented 2023-03-15 11:59:25 +01:00
Francesco Mangiacrapa c1802685b8 Added maven-portal-bom 3.6.4 2022-11-15 11:09:27 +01:00
Francesco Mangiacrapa dc0e6501e6 removed -SNAPSHOT to be released 2022-11-14 15:53:24 +01:00
Francesco Mangiacrapa 03412ae0a4 Merge pull request 'task_22890' (!1) from task_22890 into master
Reviewed-on: #1
2022-11-14 15:52:28 +01:00
Francesco Mangiacrapa 55a63b3d3f Only updated some description 2022-11-14 15:49:12 +01:00
Francesco Mangiacrapa bf1959af7b Updated dependency as reported at #24111#note-1 2022-11-11 10:10:54 +01:00
Francesco Mangiacrapa d88bb99829 #24111 Added dependencies required for building with JDK_11 2022-11-10 10:03:17 +01:00
Francesco Mangiacrapa bc8852dd61 moved to gwt 2.9.0 2022-11-10 10:00:29 +01:00
Francesco Mangiacrapa c89ca1ede6 moved to source java 1.8 e gwt 2.8.2 2022-11-10 09:42:32 +01:00
Francesco Mangiacrapa a2b23ce59f reverted to gwt 2.7.0 and java source 1.7 2022-11-10 09:32:35 +01:00
Francesco Mangiacrapa c8f39f7163 - Moved to GWT 2.9
- Moed to maven-portal-bom 3.6.4
2022-11-09 15:51:53 +01:00
Francesco Mangiacrapa f8367e7c2e Updated CSS 2022-09-08 12:06:47 +02:00
Francesco Mangiacrapa fc23e553f7 #23544 Integrated with the fieldId 2022-07-07 17:49:22 +02:00
Francesco Mangiacrapa 0710f44269 #23188 enhancement implemented 2022-04-20 15:42:03 +02:00
Francesco Mangiacrapa 1b79e7bf74 Added the parameter "FIELD_NAME" (as hidden parameter) in the form
uploader
2022-03-21 16:31:43 +01:00
Francesco Mangiacrapa 0887144f9c passed to LinkedHashMap 2022-03-07 16:46:41 +01:00
Francesco Mangiacrapa 70b4d02a5d Moved to LinkedHashMap 2022-03-07 16:42:24 +01:00
Francesco Mangiacrapa f83312dbf3 in progress on update 2022-03-03 18:42:59 +01:00
Francesco Mangiacrapa 731cac1e95 Moved to 1.1.0-SNAPSHOT. Added getProfilesInTheScopeForName 2022-03-02 13:24:58 +01:00
Francesco Mangiacrapa 465c0b4db7 bug fixing the issue reported at #20446 2021-02-08 14:40:14 +01:00
67 changed files with 2278 additions and 4369 deletions

View File

@ -28,11 +28,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -1,4 +1,5 @@
eclipse.preferences.version=1
lastWarOutDir=/home/francesco-mangiacrapa/git/metadata-profile-form-builder-widget/target/metadata-profile-form-builder-widget-0.1.0-SNAPSHOT
warSrcDir=src/main/webapp
jarsExcludedFromWebInfLib=
lastWarOutDir=/home/francesco-mangiacrapa/git/metadata-profile-form-builder-widget/target/metadata-profile-form-builder-widget-2.0.0
warSrcDir=
warSrcDirIsOutput=false

View File

@ -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

View File

@ -1,62 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="2.0.0">
<wb-module deploy-name="metadata-profile-form-builder-widget-0.1.0-SNAPSHOT">
<wb-module deploy-name="metadata-profile-form-builder-widget-2.0.0">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
<property name="context-root" value="metadata-profile-form-builder-widget"/>
<property name="java-output-path" value="/metadata-profile-form-builder-widget/target/classes"/>
</wb-module>

View File

@ -0,0 +1,7 @@
<root>
<facet id="jst.jaxrs">
<node name="libprov">
<attribute name="provider-id" value="jaxrs-no-op-library-provider"/>
</node>
</facet>
</root>

View File

@ -2,7 +2,7 @@
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.7"/>
<installed facet="jst.web" version="2.3"/>
<installed facet="com.gwtplugins.gwt.facet" version="1.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="jst.jaxrs" version="2.0"/>
</faceted-project>

View File

@ -4,10 +4,43 @@
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.1.1] - 2024-03-19
#### Enhancements
- [#26656] Aligned the data-model to ckan-metadata-publisher-widget
## [v2.1.0] - 2023-02-01
#### Enhancements
- [#23188] Improved Legend "is required field"
- [#24515] Managed the files already uploaded
## [v2.0.0] - 2022-11-14
#### Enhancements
- [#23188] Overloaded the method getProfilesInTheScope(forName)
- [#22890] Including the set/get currentValue for the "Update" facility
- [#23188] Advanced the MultipleDilaogUpload with a more complex object
- [#23544] Integrated with the fieldId added to gCube Metadata Profile
- [#24111] Added dependency required for building with JDK_11
- Moved to GWT 2.9
- Moved to maven-portal-bom 3.6.4
## [v1.0.1-SNAPSHOT] - 2020-10-08
#### Bug fixes
- [#20446] Catalogue Publishing Widget: field value unexpectedly added in case of optional field
## [v1.0.0] - 2020-10-08
#### First release
[#19884] Create widget to build a data-entry form by using metadata-profile-discovery
- [#19884] Create widget to build a data-entry form by using metadata-profile-discovery
[#19878] Create a data entry facility to get (meta)data object defined by "gCube Metada Profile"
- [#19878] Create a data entry facility to get (meta)data object defined by "gCube Metada Profile"

22
pom.xml
View File

@ -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.widgets</groupId>
<artifactId>metadata-profile-form-builder-widget</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
<version>2.1.1</version>
<name>Metadata Profile Form Builder</name>
<description>
The Metadata Profile Form Builder is a widget able to build dynamically a web form by reading "gCube Metadata Profile/s"
@ -28,10 +28,10 @@
<properties>
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.7.0</gwtVersion>
<gwtVersion>2.9.0</gwtVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<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>
@ -53,7 +53,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>3.6.0</version>
<version>3.7.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -98,6 +98,18 @@
</dependency>
<!-- END FWS -->
<!-- REQUIRED FOR JDK_11 -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
<scope>provided</scope>
</dependency>
<!-- END REQUIRED FOR JDK_11 -->
<!-- JSON PARSER -->
<dependency>
<groupId>org.json</groupId>

View File

@ -10,6 +10,7 @@ public class ConstantsMPFormBuilder {
//public static final String CURR_USER_ID = "currUserId";
public static final String IS_OVERWRITE = "isOverwrite";
public static final String UPLOAD_TYPE = "uploadType";
public static enum THE_UPLOAD_TYPE {File, Archive};
public static final String ID_FOLDER = "idFolder";
public static final String UPLOAD_FORM_ELEMENT = "uploadFormElement";
@ -17,6 +18,9 @@ public class ConstantsMPFormBuilder {
public static final String CLIENT_UPLOAD_KEYS = "client_upload_keys";
public static final String CANCEL_UPLOAD = "cancel_upload";
public static final String JSON_CLIENT_KEYS = "ClientKeys";
public static final String UPL_FILENAME = "filename";
public static final String UPL_CLIENT_KEY = "client_key";
public static final String UPL_FIELD_NAME_FILEPATH = "fieldname_filepath";
public static final int LIMIT_UPLOADS = 50;

View File

@ -8,7 +8,6 @@ import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadingState
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
// TODO: Auto-generated Javadoc
/**
* The client side stub for the RPC service.
*
@ -54,4 +53,15 @@ public interface MetadataProfileFormBuilderService extends RemoteService {
* @throws Exception the exception
*/
Integer purgeFilesUploaded() throws Exception;
/**
* Gets the profiles in the scope.
*
* @param scope the scope
* @param genericResourceSecondaryType the generic resource secondary type
* @param resourceName the resource name
* @return the profiles in the scope
* @throws Exception the exception
*/
List<MetaDataProfileBean> getProfilesInTheScopeForName(String scope,String genericResourceSecondaryType, String resourceName) throws Exception;
}

View File

@ -10,17 +10,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
public interface MetadataProfileFormBuilderServiceAsync {
/**
* GWT-RPC service asynchronous (client-side) interface
*
* @see org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderService
*/
void getProfilesInTheScope(String scope, String genericResourceSecondaryType, AsyncCallback<List<MetaDataProfileBean>> callback);
void getProfileForMetadata(String metadata,
AsyncCallback<MetaDataProfileBean> callback);
/**
* Utility class to get the RPC Async interface from client-side code
*/
@ -39,7 +28,21 @@ public interface MetadataProfileFormBuilderServiceAsync {
}
}
/**
* GWT-RPC service asynchronous (client-side) interface
*
* @see org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderService
*/
void getProfilesInTheScope(String scope, String genericResourceSecondaryType,
AsyncCallback<List<MetaDataProfileBean>> callback);
void getProfileForMetadata(String metadata, AsyncCallback<MetaDataProfileBean> callback);
void getUploadStatus(String clientUploadKey, AsyncCallback<FileUploadingState> asyncCallback);
void purgeFilesUploaded(AsyncCallback<Integer> callback);
void getProfilesInTheScopeForName(String scope, String genericResourceSecondaryType, String resourceName,
AsyncCallback<List<MetaDataProfileBean>> callback);
}

View File

@ -1,33 +0,0 @@
package org.gcube.portlets.widgets.mpformbuilder.client.events;
import org.gcube.portlets.widgets.mpformbuilder.shared.catalogue.ResourceElementBean;
import com.google.gwt.event.shared.GwtEvent;
/**
* Added resource event
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class AddResourceEvent extends GwtEvent<AddResourceEventHandler> {
public static Type<AddResourceEventHandler> TYPE = new Type<AddResourceEventHandler>();
private ResourceElementBean resource;
public AddResourceEvent(ResourceElementBean resource) {
this.resource = resource;
}
public ResourceElementBean getResource() {
return resource;
}
@Override
public Type<AddResourceEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(AddResourceEventHandler handler) {
handler.onAddedResource(this);
}
}

View File

@ -1,11 +0,0 @@
package org.gcube.portlets.widgets.mpformbuilder.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* Added resource handler interface
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public interface AddResourceEventHandler extends EventHandler {
void onAddedResource(AddResourceEvent addResourceEvent);
}

View File

@ -0,0 +1,33 @@
package org.gcube.portlets.widgets.mpformbuilder.client.events;
import org.gcube.portlets.widgets.mpformbuilder.shared.catalogue.ResourceElementBeanProfile;
import com.google.gwt.event.shared.GwtEvent;
/**
* Added resource event
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class AddResourceEventProfile extends GwtEvent<AddResourceEventProfileHandler> {
public static Type<AddResourceEventProfileHandler> TYPE = new Type<AddResourceEventProfileHandler>();
private ResourceElementBeanProfile resource;
public AddResourceEventProfile(ResourceElementBeanProfile resource) {
this.resource = resource;
}
public ResourceElementBeanProfile getResource() {
return resource;
}
@Override
public Type<AddResourceEventProfileHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(AddResourceEventProfileHandler handler) {
handler.onAddedResource(this);
}
}

View File

@ -0,0 +1,21 @@
package org.gcube.portlets.widgets.mpformbuilder.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface AddResourceEventProfileHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Feb 12, 2024
*/
public interface AddResourceEventProfileHandler extends EventHandler {
/**
* On added resource.
*
* @param addResourceEvent the add resource event
*/
void onAddedResource(AddResourceEventProfile addResourceEvent);
}

View File

@ -1,27 +0,0 @@
package org.gcube.portlets.widgets.mpformbuilder.client.events;
import com.google.gwt.event.shared.GwtEvent;
/**
* Called on close form.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class CloseCreationFormEvent extends GwtEvent<CloseCreationFormEventHandler>{
public static Type<CloseCreationFormEventHandler> TYPE = new Type<CloseCreationFormEventHandler>();
public CloseCreationFormEvent() {
super();
}
@Override
public Type<CloseCreationFormEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(CloseCreationFormEventHandler handler) {
handler.onClose(this);
}
}

View File

@ -1,13 +0,0 @@
package org.gcube.portlets.widgets.mpformbuilder.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* Close event handler interface
* @author Costantino Perciante at ISTI-CNR
* (costantino.perciante@isti.cnr.it)
*
*/
public interface CloseCreationFormEventHandler extends EventHandler {
void onClose(CloseCreationFormEvent event);
}

View File

@ -0,0 +1,44 @@
package org.gcube.portlets.widgets.mpformbuilder.client.events;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class CloseCreationFormProfileEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Feb 12, 2024
*/
public class CloseCreationFormProfileEvent extends GwtEvent<CloseCreationFormProfileEventHandler>{
public static Type<CloseCreationFormProfileEventHandler> TYPE = new Type<CloseCreationFormProfileEventHandler>();
/**
* Instantiates a new close creation form profile event.
*/
public CloseCreationFormProfileEvent() {
super();
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<CloseCreationFormProfileEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(CloseCreationFormProfileEventHandler handler) {
handler.onClose(this);
}
}

View File

@ -0,0 +1,20 @@
package org.gcube.portlets.widgets.mpformbuilder.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface CloseCreationFormProfileEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Feb 12, 2024
*/
public interface CloseCreationFormProfileEventHandler extends EventHandler {
/**
* On close.
*
* @param event the event
*/
void onClose(CloseCreationFormProfileEvent event);
}

View File

@ -1,32 +0,0 @@
package org.gcube.portlets.widgets.mpformbuilder.client.events;
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.CustomFieldEntry;
import com.google.gwt.event.shared.GwtEvent;
/**
* Delete custom field event.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class DeleteCustomFieldEvent extends GwtEvent<DeleteCustomFieldEventHandler> {
public static Type<DeleteCustomFieldEventHandler> TYPE = new Type<DeleteCustomFieldEventHandler>();
private CustomFieldEntry removedEntry;
public DeleteCustomFieldEvent(CustomFieldEntry removedEntry) {
this.removedEntry = removedEntry;
}
public CustomFieldEntry getRemovedEntry() {
return removedEntry;
}
@Override
public Type<DeleteCustomFieldEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(DeleteCustomFieldEventHandler handler) {
handler.onRemoveEntry(this);
}
}

View File

@ -0,0 +1,32 @@
package org.gcube.portlets.widgets.mpformbuilder.client.events;
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.CustomFieldEntryProfile;
import com.google.gwt.event.shared.GwtEvent;
/**
* Delete custom field event.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class DeleteCustomFieldProfileEvent extends GwtEvent<DeleteCustomFieldProfileEventHandler> {
public static Type<DeleteCustomFieldProfileEventHandler> TYPE = new Type<DeleteCustomFieldProfileEventHandler>();
private CustomFieldEntryProfile removedEntry;
public DeleteCustomFieldProfileEvent(CustomFieldEntryProfile removedEntry) {
this.removedEntry = removedEntry;
}
public CustomFieldEntryProfile getRemovedEntry() {
return removedEntry;
}
@Override
public Type<DeleteCustomFieldProfileEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(DeleteCustomFieldProfileEventHandler handler) {
handler.onRemoveEntry(this);
}
}

View File

@ -3,9 +3,9 @@ package org.gcube.portlets.widgets.mpformbuilder.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* Handler associated to the DeleteCustomFieldEvent
* Handler associated to the DeleteCustomFieldProfileEvent
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public interface DeleteCustomFieldEventHandler extends EventHandler {
void onRemoveEntry(DeleteCustomFieldEvent event);
public interface DeleteCustomFieldProfileEventHandler extends EventHandler {
void onRemoveEntry(DeleteCustomFieldProfileEvent event);
}

View File

@ -1,34 +0,0 @@
package org.gcube.portlets.widgets.mpformbuilder.client.events;
import org.gcube.portlets.widgets.mpformbuilder.shared.catalogue.ResourceElementBean;
import com.google.gwt.event.shared.GwtEvent;
/**
* Deleted resource event.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class DeleteResourceEvent extends GwtEvent<DeleteResourceEventHandler> {
public static Type<DeleteResourceEventHandler> TYPE = new Type<DeleteResourceEventHandler>();
private ResourceElementBean resource;
public DeleteResourceEvent(ResourceElementBean resource) {
this.resource = resource;
}
public ResourceElementBean getResource() {
return resource;
}
@Override
public Type<DeleteResourceEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(DeleteResourceEventHandler handler) {
handler.onDeletedResource(this);
}
}

View File

@ -0,0 +1,34 @@
package org.gcube.portlets.widgets.mpformbuilder.client.events;
import org.gcube.portlets.widgets.mpformbuilder.shared.catalogue.ResourceElementBeanProfile;
import com.google.gwt.event.shared.GwtEvent;
/**
* Deleted resource event.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class DeleteResourceProfileEvent extends GwtEvent<DeleteResourceProfileEventHandler> {
public static Type<DeleteResourceProfileEventHandler> TYPE = new Type<DeleteResourceProfileEventHandler>();
private ResourceElementBeanProfile resource;
public DeleteResourceProfileEvent(ResourceElementBeanProfile resource) {
this.resource = resource;
}
public ResourceElementBeanProfile getResource() {
return resource;
}
@Override
public Type<DeleteResourceProfileEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(DeleteResourceProfileEventHandler handler) {
handler.onDeletedResource(this);
}
}

View File

@ -6,6 +6,6 @@ import com.google.gwt.event.shared.EventHandler;
* The delete event handler
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public interface DeleteResourceEventHandler extends EventHandler{
void onDeletedResource(DeleteResourceEvent deleteResourceEvent);
public interface DeleteResourceProfileEventHandler extends EventHandler{
void onDeletedResource(DeleteResourceProfileEvent deleteResourceEvent);
}

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.widgets.mpformbuilder.client.form;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION;
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
@ -34,8 +35,6 @@ public class MetaDataField extends Composite {
@UiField VerticalPanel panelMetaDataFieldsSkeleton;
@UiField Label repeatabilityLabel;
//@UiField ControlGroup cgMetaDataFieldSkeletonFields;
@UiField Button addFieldButton;
@ -47,6 +46,8 @@ public class MetaDataField extends Composite {
private HandlerManager eventBus;
private OPERATION operation;
/**
* The Interface MetaDataFieldUiBinder.
*
@ -65,10 +66,11 @@ public class MetaDataField extends Composite {
* @param eventBus the event bus
* @throws Exception the exception
*/
public MetaDataField(final MetadataFieldWrapper field, HandlerManager eventBus) throws Exception {
public MetaDataField(final MetadataFieldWrapper field, HandlerManager eventBus, OPERATION operation) throws Exception {
initWidget(uiBinder.createAndBindUi(this));
this.fieldWrapper = field;
this.eventBus = eventBus;
this.operation = operation;
addNewOccurrenceOfField();
checkAllowedAddField();
checkAllowedRemoveField();
@ -143,7 +145,7 @@ public class MetaDataField extends Composite {
*/
private void addNewOccurrenceOfField() {
try {
MetaDataFieldSkeleton fieldWidget = new MetaDataFieldSkeleton(fieldWrapper, eventBus);
MetaDataFieldSkeleton fieldWidget = new MetaDataFieldSkeleton(fieldWrapper, eventBus, operation);
listOfMetadataFields.add(fieldWidget);
panelMetaDataFieldsSkeleton.add(fieldWidget);
} catch (Exception e) {

View File

@ -1,410 +0,0 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
xmlns:m="urn:import:org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.tags">
<ui:style>
.form-main-style {
margin-left: 10px;
}
.fieldset-border-style {
border: 1px groove #444;
-webkit-box-shadow: 0px 0px 0px 0px #000;
box-shadow: 0px 0px 0px 0px #000;
padding: 10px;
}
.legend-style {
width: auto;
padding: 10px;
margin-bottom: 0px;
}
@external .form-horizontal .input-large;
.form-horizontal .input-large .input-prepend {
width: 95%;
}
.block-alert-style {
margin-top: 10px;
padding: 10px;
margin-bottom: 10px;
}
.tagsPanelStyle {
display: inline-block;
}
.selected-profile {
font-weight: bold;
}
.label-go-to-product {
display: inline-block;
vertical-align: middle;
font-weight: bold;
}
.the-margin-left{
margin-left: 5px;
}
</ui:style>
<g:HTMLPanel ui:field="createDatasetMainPanel">
<b:Form type="HORIZONTAL" styleName="{style.form-main-style}"
ui:field="formFirstStep" visible="true">
<b:Fieldset styleName="{style.fieldset-border-style}">
<b:Legend styleName="{style.legend-style}">
Insert Item Information
<small>
<span style="color:red;">*</span>
is required
</small>
</b:Legend>
<!-- Alert blocks for info/errors -->
<b:AlertBlock type="INFO" close="false" animation="true"
visible="false" ui:field="infoBlock" styleName="{style.block-alert-style}"></b:AlertBlock>
<b:ControlGroup ui:field="productTitleGroup">
<b:ControlLabel for="title" title="Item title">
<font color="red">*</font>
Title :
</b:ControlLabel>
<b:Controls>
<b:TextBox alternateSize="LARGE" placeholder="Item title"
width="90%" b:id="title" title="Item title" ui:field="titleTextBox" />
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverTitle" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelTitle">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconTitle" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
<b:ControlLabel for="description" title="Item description">
Description:
</b:ControlLabel>
<b:Controls>
<b:TextArea placeholder="eg. Some useful notes about the item"
width="90%" alternateSize="LARGE" b:id="description" title="Item description"
ui:field="descriptionTextarea"></b:TextArea>
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverDescription" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelDescription">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconDescription" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
<!-- TAGS Panel -->
<m:TagsPanel ui:field="tagsPanel"></m:TagsPanel>
<b:ControlGroup>
<b:ControlLabel for="licenses" title="License">License:</b:ControlLabel>
<b:Controls>
<b:ListBox b:id="licenses" title="Item license"
width="91%" ui:field="licenseListbox">
</b:ListBox>
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverLicenses" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelLicenses">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconLicenses" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
<b:ControlLabel for="licenseUrl" title="Selected License'url">Selected
License Url:</b:ControlLabel>
<b:Controls>
<b:Paragraph ui:field="unavailableUrl" visible="true">
<b>Unavailable</b>
</b:Paragraph>
<g:Anchor ui:field="licenseUrlAnchor" target="_blank"
visible="false"></g:Anchor>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
<b:ControlLabel for="visibility" title="Visibility of the item">Visibility:</b:ControlLabel>
<b:Controls>
<b:ListBox b:id="visibility" title="Item visibility"
width="91%" ui:field="visibilityListbox">
<g:item title="restricted">Restricted</g:item>
<g:item enabled="true" title="public">Public</g:item>
</b:ListBox>
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverVisibility" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelVisibility">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconVisibility" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="organizationsGroup">
<b:ControlLabel for="organization"
title="Select the organizations in which you want
to publish the item">Publish in:</b:ControlLabel>
<b:Controls>
<b:ListBox b:id="organization" alternateSize="LARGE"
width="91%" title="Publish in this organization" ui:field="organizationsListbox">
</b:ListBox>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="versionControlGroup">
<b:ControlLabel for="version"
title="Item version expressed as positive integer number">
Version:
</b:ControlLabel>
<b:Controls>
<b:TextBox alternateSize="LARGE" placeholder="1.0" b:id="version"
width="90%" title="Item version" ui:field="versionTextbox" />
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
<b:ControlLabel for="author" title="Item author">
<font color="red">*</font>
Author:
</b:ControlLabel>
<b:Controls>
<b:TextBox alternateSize="LARGE" width="90%"
placeholder="Joe Bloggs" enabled="false" b:id="author" title="Item author"
ui:field="authorTextbox" />
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverAuthor" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelAuthor">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconAuthor" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="authorEmailControlGroup">
<b:ControlLabel for="email" title="Item author's email">
<font color="red">*</font>
Author Email:
</b:ControlLabel>
<b:Controls>
<b:TextBox alternateSize="LARGE" width="90%"
placeholder="joe.bloggs@example.com" enabled="false" b:id="email"
title="Item author" ui:field="authorEmailTextbox" />
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverAuthorEmail" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelAuthorEmail">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconAuthorEmail" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
<b:ControlLabel for="maintainer" title="Item maintainer">
Maintainer:
</b:ControlLabel>
<b:Controls>
<b:TextBox alternateSize="LARGE" placeholder="Joe Bloggs"
width="90%" b:id="maintainer" title="Item maintainer"
ui:field="maintainerTextbox" />
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverMaintainer" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelMaintainer">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconMaintainer" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="maintainerControlGroup">
<b:ControlLabel for="emailMaintaner" title="Item author's email">
Maintainer Email:
</b:ControlLabel>
<b:Controls>
<b:TextBox alternateSize="LARGE" placeholder="maintainer@example.com"
width="90%" b:id="emailMaintaner" title="Item author"
ui:field="maintainerEmailTextbox" />
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverMaintainerEmail" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelMaintainerEmail">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconMaintainerEmail" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="metadataTypesControlGroup">
<b:ControlLabel for="metadataTypes" title="Item profile types">Types:</b:ControlLabel>
<b:Controls>
<b:ListBox b:id="metadataTypes" alternateSize="LARGE"
width="91%" title="The item type to be used"
ui:field="metadataTypeListbox">
<g:item enabled="true" title="None">none</g:item>
</b:ListBox>
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverTypes" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelTypes">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconTypes" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="groupsControlGroup"
visible="false">
<b:ControlLabel for="groups" title="The groups for this item">Item Groups:</b:ControlLabel>
<b:Controls>
<b:ListBox b:id="groups" alternateSize="LARGE" width="91%"
multipleSelect="true"
title="The groups for this item (Hold CTRL or Command button for multiple selection)"
ui:field="groupsListbox">
</b:ListBox>
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverGroups" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelGroups">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconGroups" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
<!-- Alert block on continue -->
<b:AlertBlock animation="true" visible="false"
ui:field="alertNoResources"
text="Please note that the item you are going to publish will not have resources.">
</b:AlertBlock>
<!-- Alert block on continue -->
<b:AlertBlock type="INFO" close="false" animation="true"
visible="false" ui:field="onContinueAlertBlock">
</b:AlertBlock>
<b:Button title="Continue" ui:field="continueButton" type="PRIMARY"
block="true">Continue</b:Button>
<b:Button title="Reset" ui:field="resetButton" block="true">Reset</b:Button>
</b:Fieldset>
</b:Form>
<b:Form type="HORIZONTAL" styleName="{style.form-main-style}"
ui:field="formSecondStep" visible="false">
<b:Fieldset styleName="{style.fieldset-border-style}">
<b:Legend styleName="{style.legend-style}">
Manage Resources
</b:Legend>
<b:ControlGroup>
<b:Controls>
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverResources" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelResources">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconResources" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
<g:SimplePanel ui:field="workspaceResourcesContainer"
width="100%" visible="true">
</g:SimplePanel>
<b:Button title="Continue" ui:field="continueThirdStep"
type="PRIMARY" block="true">Continue</b:Button>
<b:Button title="Go Back" ui:field="goBackButtonFirstStep"
block="true">Go
Back</b:Button>
</b:Fieldset>
</b:Form>
<b:Form type="HORIZONTAL" styleName="{style.form-main-style}"
ui:field="formThirdStep" visible="false">
<b:Fieldset styleName="{style.fieldset-border-style}">
<b:Legend styleName="{style.legend-style}">
Insert Item Profile Information
<small>
<span style="color:red;">*</span>
is required
</small>
</b:Legend>
<b:Paragraph ui:field="selectedProfile" styleName="{style.selected-profile}"></b:Paragraph>
<!-- Here will be placed the metadata fields formats -->
<g:VerticalPanel ui:field="metadataFieldsPanel"
visible="false" width="100%"></g:VerticalPanel>
<!-- Custom fields can be dinamically added -->
<b:ControlGroup ui:field="customFields">
<b:ControlLabel>Custom Field(s):</b:ControlLabel>
</b:ControlGroup>
<b:ControlGroup>
<b:Controls>
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverCustomFields" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelCustomFields">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconCustomFields" />
</g:FocusPanel>
</b:Popover>
</span>
<b:Button icon="PLUS_SIGN" title="Add Custom Field"
ui:field="addCustomFieldButton"></b:Button>
</b:Controls>
</b:ControlGroup>
<!-- Alert block on create -->
<b:AlertBlock type="INFO" close="false" animation="true"
visible="false" ui:field="onCreateAlertBlock" styleName="{style.block-alert-style}">
</b:AlertBlock>
<g:HorizontalPanel ui:field="goToDatasetButtonPanel" visible="false">
<g:Label>Go to the Item</g:Label>
<b:Button title="Go to the Item" ui:field="goToDatasetButton"
type="LINK" visible="false" styleName="{style.the-margin-left}"></b:Button>
</g:HorizontalPanel>
<b:Button title="Add resources to the just created item"
block="true" type="PRIMARY" visible="false" ui:field="addResourcesButton">Add Resources</b:Button>
<b:Button title="Create Item" ui:field="createButton"
type="PRIMARY" block="true">Create</b:Button>
<b:Button title="Go Back" ui:field="goBackButtonSecondStep"
block="true">Go
Back</b:Button>
</b:Fieldset>
</b:Form>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -59,10 +59,6 @@
<b:Fieldset styleName="{style.fieldset-border-style}">
<b:Legend styleName="{style.legend-style}">
Choose a Profile
<!-- <small> -->
<!-- <span style="color:red;">*</span> -->
<!-- is required -->
<!-- </small> -->
</b:Legend>
<!-- Alert blocks for info/errors -->
@ -91,18 +87,11 @@
</b:Controls>
</b:ControlGroup>
<!-- TAGS Panel -->
<!-- <m:TagsPanel ui:field="tagsPanel"></m:TagsPanel> -->
<!-- Alert block on continue -->
<b:AlertBlock type="INFO" close="false"
animation="true" visible="false" ui:field="onContinueAlertBlock">
</b:AlertBlock>
<!-- <b:Button title="Continue" ui:field="continueButton" type="PRIMARY" -->
<!-- block="true">Continue</b:Button> -->
<!-- <b:Button title="Reset" ui:field="resetButton" block="true">Reset</b:Button> -->
</b:Fieldset>
</b:Form>
@ -112,14 +101,6 @@
<b:Form type="HORIZONTAL" styleName="{style.form-main-style}"
ui:field="formThirdStep" visible="false">
<b:Fieldset styleName="{style.fieldset-border-style}">
<!-- <b:Legend styleName="{style.legend-style}" -->
<!-- ui:field="legendInsertInformation"> -->
<!-- Insert Information -->
<!-- <small> -->
<!-- <span style="color:red;">*</span> -->
<!-- is required -->
<!-- </small> -->
<!-- </b:Legend> -->
<u:CustomLegend ui:field="customLegend">
Insert Information
@ -135,6 +116,9 @@
<!-- Here will be placed the metadata fields formats -->
<g:VerticalPanel ui:field="metadataFieldsPanel"
visible="false" width="100%"></g:VerticalPanel>
<g:VerticalPanel ui:field="filesUploadedPanel"
visible="false" width="100%"></g:VerticalPanel>
<!-- Custom fields can be dinamically added -->
<b:ControlGroup ui:field="customFields"
@ -165,27 +149,12 @@
styleName="{style.block-alert-style}">
</b:AlertBlock>
<!-- <g:HorizontalPanel ui:field="goToDatasetButtonPanel" visible="false"> -->
<!-- <g:Label>Go to the Item</g:Label> -->
<!-- <b:Button title="Go to the Item" ui:field="goToDatasetButton" -->
<!-- type="LINK" visible="false" styleName="{style.the-margin-left}"></b:Button> -->
<!-- </g:HorizontalPanel> -->
<!-- <b:Button title="Add resources to the just created item" -->
<!-- block="true" type="PRIMARY" visible="false" ui:field="addResourcesButton">Add
Resources</b:Button> -->
<b:Button title="Create Item" ui:field="createButton"
type="PRIMARY" block="true">Create</b:Button>
<b:Button title="Edit Item" ui:field="editButton"
type="PRIMARY" block="true" visible="false">Edit</b:Button>
<!-- <b:Button title="Go Back" ui:field="goBackButtonSecondStep" -->
<!-- block="true">Go -->
<!-- Back</b:Button> -->
</b:Fieldset>
</b:Form>
</g:HTMLPanel>

View File

@ -0,0 +1,130 @@
package org.gcube.portlets.widgets.mpformbuilder.client.form.generic;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadedRemote;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
public class UploadedFilesBrowse<T extends FileUploaded> extends Composite {
private static UploadedFilesBrowseUiBinder uiBinder = GWT.create(UploadedFilesBrowseUiBinder.class);
interface UploadedFilesBrowseUiBinder extends UiBinder<Widget, UploadedFilesBrowse> {
}
private List<T> listFileUploaded;
@UiField
HTMLPanel uploadFileContainer;
private FlexTable table = new FlexTable();
private List<Button> listButtonRemove = new ArrayList<Button>();
private HashMap<Integer, T> mapPositionalFU = new HashMap<Integer, T>();
public UploadedFilesBrowse(List<T> fileUploaded) {
initWidget(uiBinder.createAndBindUi(this));
this.listFileUploaded = fileUploaded;
// Filling map of files uploaded
int i = 0;
for (T file : listFileUploaded) {
mapPositionalFU.put(i, file);
i++;
}
showFileBrowseInteraction();
}
private void showFileBrowseInteraction() {
uploadFileContainer.clear();
// pathIndex = pathContentIndex;
// GWT.log("showing pathContentIndex: "+pathContentIndex);
GWT.log("showing files: " + listFileUploaded);
table.clear();
if (listFileUploaded.size() > 0) {
table.addStyleName("table-current-content");
table.setHTML(0, 0, "<span style='color:rgb(155, 80, 78); font-weight:bold;'>Current content:</span>");
table.setHTML(1, 0, "<span style='color:rgb(155, 80, 78);'>Filename</span>");
table.setHTML(1, 1, "<span style='color:rgb(155, 80, 78);'>MimeType<span>");
table.setHTML(1, 2, "<span style='color:rgb(155, 80, 78);'>Field Label</span>");
table.setHTML(1, 3, "<span style='color:rgb(155, 80, 78);'>Link</span>");
int i = 2;
int index = 0;
for (final FileUploaded file : listFileUploaded) {
final int filePointer = index;
int columnIndex = 0;
table.setHTML(i, columnIndex, file.getFileName());
if (file instanceof FileUploadedRemote) {
FileUploadedRemote fur = (FileUploadedRemote) file;
table.setHTML(i, ++columnIndex, fur.getMimeType());
String fieldLabel = file.getFilePath().getFormFieldLabel();
table.setHTML(i, ++columnIndex, fieldLabel);
String link = "<a target=\"_blank\" href=" + fur.getUrl() + ">View</a>";
table.setHTML(i, ++columnIndex, link);
}
final int rowIndexToRem = i;
Button buttonRemoveFile = new Button();
buttonRemoveFile.setIcon(IconType.TRASH);
buttonRemoveFile.setTitle("Remove this file");
buttonRemoveFile.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
mapPositionalFU.remove(filePointer);
table.getRowFormatter().getElement(rowIndexToRem).setAttribute("hidden", "hidden");
}
});
listButtonRemove.add(buttonRemoveFile);
table.setWidget(i, ++columnIndex, buttonRemoveFile);
i++;
index++;
}
uploadFileContainer.add(table);
}
}
public void enableManageOfContent(boolean bool) {
for (Button button : listButtonRemove) {
button.setEnabled(bool);
}
double opacity = bool ? 1 : 0.8;
uploadFileContainer.getElement().getStyle().setOpacity(opacity);
}
public List<T> getListRemainingFileUploaded() {
Collection<T> collFileUplaoded = mapPositionalFU.values();
if (collFileUplaoded != null)
return new ArrayList<T>(collFileUplaoded);
return null;
}
}

View File

@ -0,0 +1,20 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
.padding-panel {
padding-left: 30px;
padding-right: 30px;
padding-bottom: 30px;
}
</ui:style>
<g:HTMLPanel>
<g:HTMLPanel ui:field="uploadFileContainer"
addStyleNames="{style.padding-panel}"></g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata;
import org.gcube.portlets.widgets.mpformbuilder.client.events.DeleteCustomFieldEvent;
import org.gcube.portlets.widgets.mpformbuilder.client.events.DeleteCustomFieldProfileEvent;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.InputAddOn;
@ -18,13 +18,13 @@ import com.google.gwt.user.client.ui.Widget;
* A custom field entry that has two textboxes, one for the key value and the other for the value.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class CustomFieldEntry extends Composite {
public class CustomFieldEntryProfile extends Composite {
private static CustomFieldEntryUiBinder uiBinder = GWT
.create(CustomFieldEntryUiBinder.class);
interface CustomFieldEntryUiBinder extends
UiBinder<Widget, CustomFieldEntry> {
UiBinder<Widget, CustomFieldEntryProfile> {
}
@UiField InputAddOn keyFieldPrepend;
@ -39,7 +39,7 @@ public class CustomFieldEntry extends Composite {
// event bus
private HandlerManager eventBus;
public CustomFieldEntry(HandlerManager eventBus, String key, String value, boolean isCustomCreatedByUser) {
public CustomFieldEntryProfile(HandlerManager eventBus, String key, String value, boolean isCustomCreatedByUser) {
initWidget(uiBinder.createAndBindUi(this));
// save information
@ -91,7 +91,7 @@ public class CustomFieldEntry extends Composite {
void onRemoveCustomField(ClickEvent e){
// fire event
eventBus.fireEvent(new DeleteCustomFieldEvent(this));
eventBus.fireEvent(new DeleteCustomFieldProfileEvent(this));
}

View File

@ -3,8 +3,9 @@ package org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.widgets.mpformbuilder.client.events.CloseCreationFormEvent;
import org.gcube.portlets.widgets.mpformbuilder.client.events.CloseCreationFormEventHandler;
import org.gcube.portlets.widgets.mpformbuilder.client.events.CloseCreationFormProfileEvent;
import org.gcube.portlets.widgets.mpformbuilder.client.events.CloseCreationFormProfileEventHandler;
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION;
import org.gcube.portlets.widgets.mpformbuilder.client.openlayerwidget.GeoJsonAreaSelectionDialog;
import org.gcube.portlets.widgets.mpformbuilder.client.ui.timeandranges.DataTimeBox;
import org.gcube.portlets.widgets.mpformbuilder.client.ui.upload.DialogUpload;
@ -118,10 +119,11 @@ public class MetaDataFieldSkeleton extends Composite {
// time range separator
public static final String RANGE_SEPARATOR = ",";
private static final String TOOLTIP_MULTISELECTION = "Hold down the Control (CTRL) or Command (CMD) button to select multiple options";
private static final String UPLOAD_MISSING_FILE = "You must upload a file";
public MetaDataFieldSkeleton(final MetadataFieldWrapper field, HandlerManager eventBus) throws Exception {
public MetaDataFieldSkeleton(final MetadataFieldWrapper field, HandlerManager eventBus, OPERATION operation)
throws Exception {
initWidget(uiBinder.createAndBindUi(this));
// prepare information
@ -133,6 +135,9 @@ public class MetaDataFieldSkeleton extends Composite {
// bind
bind();
if (operation == null)
operation = OPERATION.NEW;
switch (field.getType()) {
case Boolean:
@ -141,6 +146,16 @@ public class MetaDataFieldSkeleton extends Composite {
holder = new CheckBox();
if (field.getDefaultValue() != null)
((CheckBox) holder).setValue(Boolean.valueOf(field.getDefaultValue()));
if (operation.equals(OPERATION.UPDATE)) {
try {
if (field.getCurrentSingleValue() != null)
((CheckBox) holder).setValue(Boolean.valueOf(field.getDefaultValue()));
} catch (Exception e) {
// TODO: handle exception
}
}
break;
case GeoJSON:
@ -154,6 +169,15 @@ public class MetaDataFieldSkeleton extends Composite {
if (field.getDefaultValue() != null)
textArea.setText(field.getDefaultValue());
if (operation.equals(OPERATION.UPDATE)) {
try {
if (field.getCurrentSingleValue() != null)
textArea.setText((String) field.getCurrentSingleValue());
} catch (Exception e) {
// TODO: handle exception
}
}
containerGeoJSON.add(textArea);
HorizontalPanel hp = new HorizontalPanel();
@ -216,6 +240,16 @@ public class MetaDataFieldSkeleton extends Composite {
if (field.getDefaultValue() != null)
((TextArea) holder).setText(field.getDefaultValue());
if (operation.equals(OPERATION.UPDATE)) {
try {
if (field.getCurrentSingleValue() != null)
((TextArea) holder).setText((String) field.getCurrentSingleValue());
} catch (Exception e) {
// TODO: handle exception
}
}
break;
case Time:
@ -230,6 +264,22 @@ public class MetaDataFieldSkeleton extends Composite {
ref.setStartDate(dateAndTime[0], dateAndTime.length > 1 ? dateAndTime[1] : null);
}
}
if (operation.equals(OPERATION.UPDATE)) {
// set time, if present
try {
if (field.getCurrentSingleValue() != null) {
String currentValue = (String) field.getCurrentSingleValue();
String[] dateAndTime = currentValue.split(" ");
if (dateAndTime.length > 0) {
ref.setStartDate(dateAndTime[0], dateAndTime.length > 1 ? dateAndTime[1] : null);
}
}
} catch (Exception e) {
// TODO: handle exception
}
}
break;
case Time_Interval:
@ -237,6 +287,15 @@ public class MetaDataFieldSkeleton extends Composite {
DataTimeBox rangeBox;
holder = rangeBox = new DataTimeBox(true);
setRangeTimeInTimeBox(field.getDefaultValue(), rangeBox);
if (operation.equals(OPERATION.UPDATE)) {
// set time, if present
try {
setRangeTimeInTimeBox((String) field.getCurrentSingleValue(), rangeBox);
} catch (Exception e) {
// TODO: handle exception
}
}
rangesList.add(rangeBox);
break;
@ -251,6 +310,15 @@ public class MetaDataFieldSkeleton extends Composite {
SimplePanel panelFirstRange = new SimplePanel();
DataTimeBox rangeBoxFirst = new DataTimeBox(true);
setRangeTimeInTimeBox(field.getDefaultValue(), rangeBoxFirst);
if (operation.equals(OPERATION.UPDATE)) {
try {
setRangeTimeInTimeBox((String) field.getCurrentSingleValue(), rangeBoxFirst);
} catch (Exception e) {
// TODO: handle exception
}
}
panelFirstRange.add(rangeBoxFirst);
rangesList.add(rangeBoxFirst);
@ -303,11 +371,20 @@ public class MetaDataFieldSkeleton extends Composite {
if (field.getDefaultValue() != null)
((TextBox) holder).setText(field.getDefaultValue());
if (operation.equals(OPERATION.UPDATE)) {
try {
if (field.getCurrentSingleValue() != null)
((TextBox) holder).setText((String) field.getCurrentSingleValue());
} catch (Exception e) {
// TODO: handle exception
}
}
break;
case File:
holder = new MultipleDilaogUpload();
holder = new MultipleDilaogUpload(field.getFieldName());
break;
@ -322,6 +399,15 @@ public class MetaDataFieldSkeleton extends Composite {
if (field.getDefaultValue() != null)
((TextBox) holder).setText(field.getDefaultValue());
if (operation.equals(OPERATION.UPDATE)) {
try {
if (field.getCurrentSingleValue() != null)
((TextBox) holder).setText((String) field.getCurrentSingleValue());
} catch (Exception e) {
// TODO: handle exception
}
}
} else {
// listbox
@ -331,25 +417,50 @@ public class MetaDataFieldSkeleton extends Composite {
if (field.isMultiSelection())
tempListBox.setTitle(TOOLTIP_MULTISELECTION);
// if it is not mandatory, add a disabled option
if (!field.getMandatory()) {
// if it is not mandatory and not multi-selection, add a disabled option
// (placeholder)
if (!field.getMandatory() && !field.isMultiSelection()) {
tempListBox.addItem("Select " + field.getFieldName());
tempListBox.setSelectedValue("Select " + field.getFieldName());
tempListBox.setValue(0, "");
tempListBox.getElement().getElementsByTagName("option").getItem(0).setAttribute("disabled",
"disabled");
tempListBox.setSelectedValue("Select " + field.getFieldName());
}
// get vocabulary fields
List<String> vocabulary = field.getVocabulary();
for (String term : vocabulary) {
tempListBox.addItem(term);
tempListBox.addItem(term, term);
}
// set default value
if (field.getDefaultValue() != null)
tempListBox.setSelectedValue(field.getDefaultValue());
//to be sure
tempListBox.setMultipleSelect(field.isMultiSelection());
if (operation.equals(OPERATION.UPDATE)) {
try {
if (field.getCurrentValues() != null) {
if (field.isMultiSelection()) {
//Buggy in Bootstrap
for (String value : field.getCurrentValues()) {
GWT.log("Multiple Selecting: "+value);
tempListBox.setSelectedValue((String) value);
}
}else {
GWT.log("Selecting: "+field.getCurrentSingleValue());
tempListBox.setSelectedValue((String) field.getCurrentSingleValue());
}
}
} catch (Exception e) {
// TODO: handle exception
}
}
}
break;
@ -358,24 +469,22 @@ public class MetaDataFieldSkeleton extends Composite {
return;
}
try {
ChangeHandler handler = new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
GWT.log("Fired is field value");
removeError();
isFieldValueValid();
}
};
holder.addDomHandler(handler, ChangeEvent.getType());
}catch (Exception e) {
} catch (Exception e) {
// TODO: handle exception
}
// add custom css properties
controls.addStyleName("form-controls-custom");
@ -421,8 +530,7 @@ public class MetaDataFieldSkeleton extends Composite {
});
}
/**
* Gets the holder.
*
@ -438,10 +546,10 @@ public class MetaDataFieldSkeleton extends Composite {
private void bind() {
// on close form
eventBus.addHandler(CloseCreationFormEvent.TYPE, new CloseCreationFormEventHandler() {
eventBus.addHandler(CloseCreationFormProfileEvent.TYPE, new CloseCreationFormProfileEventHandler() {
@Override
public void onClose(CloseCreationFormEvent event) {
public void onClose(CloseCreationFormProfileEvent event) {
if (dialog != null)
dialog.hide();
@ -631,22 +739,24 @@ public class MetaDataFieldSkeleton extends Composite {
}
return null;
case File:
GWT.log("Checking is valid File");
if (field.getMandatory()) {
if (holder.getClass().equals(DialogUpload.class) || holder.getClass().equals(MultipleDilaogUpload.class)) {
if (holder.getClass().equals(DialogUpload.class)
|| holder.getClass().equals(MultipleDilaogUpload.class)) {
DialogUpload dUpload = (DialogUpload) holder;
if(dUpload.getFileUploadingState()!=null && dUpload.getFileUploadingState().getFile()!=null) {
return dUpload.getFileUploadingState().getFile().getTempSystemPath()!=null?null:UPLOAD_MISSING_FILE;
if (dUpload.getFileUploadingState() != null && dUpload.getFileUploadingState().getFile() != null) {
return dUpload.getFileUploadingState().getFile().getTempSystemPath() != null ? null
: UPLOAD_MISSING_FILE;
}
}
return UPLOAD_MISSING_FILE;
}
return null;
default:
return null;
@ -772,25 +882,31 @@ public class MetaDataFieldSkeleton extends Composite {
}
// if it was not mandatory but there was no choice, returning empty string
if (!field.getMandatory())
if (toReturn.equals("Select " + field.getFieldName())) {
toReturn.clear();
toReturn.add("");
if (!field.getMandatory()) {
// Task #20446 - bug fix. Ignoring the placeholder
if (toReturn.size() == 1) {
String placeholder = "Select " + field.getFieldName();
if (toReturn.get(0).equals(placeholder)) {
GWT.log("Skipping placeholder: " + placeholder);
toReturn.clear();
// toReturn.add("");
}
}
}
}
break;
case File:
if (holder.getClass().equals(MultipleDilaogUpload.class) || holder.getClass().equals(DialogUpload.class)) {
DialogUpload dUpload = (DialogUpload) holder;
if(dUpload.getFileUploadingState()!=null) {
if (dUpload.getFileUploadingState() != null) {
String filePath = dUpload.getFileUploadingState().getFile().getTempSystemPath();
toReturn.add(filePath);
}else
} else
toReturn.add(null);
}
break;
default:
@ -819,8 +935,16 @@ public class MetaDataFieldSkeleton extends Composite {
*/
public String getFieldNameQualified() {
if (field.getFieldNameFromCategory() != null)
//see https://support.d4science.org/issues/23544
if (field.getFieldId() != null) {
return field.getFieldId();
}
//Using the getFieldNameFromCategory if the category is present in the model as cateogory:fieldName
if (field.getFieldNameFromCategory() != null && field.getFieldNameFromCategory().compareTo(field.getFieldName())!=0) {
return field.getFieldNameFromCategory();
}
return field.getFieldName();
}
@ -874,7 +998,7 @@ public class MetaDataFieldSkeleton extends Composite {
break;
case File:
GWT.log("here");
if (holder.getClass().equals(MultipleDilaogUpload.class) || holder.getClass().equals(DialogUpload.class)) {
DialogUpload dUpload = (DialogUpload) holder;
dUpload.enableUpload(!bool);

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.widgets.mpformbuilder.client.ui.resources;
import com.github.gwtbootstrap.client.ui.TabPanel;
import com.github.gwtbootstrap.client.ui.base.StackedNav;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
@ -31,7 +31,7 @@ public class AddResourceContainer extends Composite{
* Add the form to this panel
* @param w
*/
public void add(TabPanel w){
public void add(StackedNav w){
resourcesPanel.add(w);
}
}

View File

@ -112,8 +112,8 @@ public class AddResourceToDataset extends Composite{
// collect data and build up the bean
/*//TODO MUST BE DONE IN ANOTHER POINT
*
* final ResourceElementBean resource =
new ResourceElementBean(
* final ResourceElementBeanProfile resource =
new ResourceElementBeanProfile(
resourceNameTextBox.getText(),
true,
false,
@ -130,14 +130,14 @@ public class AddResourceToDataset extends Composite{
addResourceButton.setEnabled(false);
// try to create
ckanServices.addResourceToDataset(resource, datasetId, new AsyncCallback<ResourceElementBean>() {
ckanServices.addResourceToDataset(resource, datasetId, new AsyncCallback<ResourceElementBeanProfile>() {
@Override
public void onSuccess(ResourceElementBean result) {
public void onSuccess(ResourceElementBeanProfile result) {
if(result != null){
showAlert("Resource created correctly", AlertType.SUCCESS);
eventBus.fireEvent(new AddResourceEvent(result));
eventBus.fireEvent(new AddResourceEventProfile(result));
// remove data
resourceUrlTextBox.setText("");

View File

@ -3,11 +3,11 @@ package org.gcube.portlets.widgets.mpformbuilder.client.ui.resources;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.widgets.mpformbuilder.client.events.AddResourceEvent;
import org.gcube.portlets.widgets.mpformbuilder.client.events.AddResourceEventHandler;
import org.gcube.portlets.widgets.mpformbuilder.client.events.DeleteResourceEvent;
import org.gcube.portlets.widgets.mpformbuilder.client.events.DeleteResourceEventHandler;
import org.gcube.portlets.widgets.mpformbuilder.shared.catalogue.ResourceElementBean;
import org.gcube.portlets.widgets.mpformbuilder.client.events.AddResourceEventProfile;
import org.gcube.portlets.widgets.mpformbuilder.client.events.AddResourceEventProfileHandler;
import org.gcube.portlets.widgets.mpformbuilder.client.events.DeleteResourceProfileEvent;
import org.gcube.portlets.widgets.mpformbuilder.client.events.DeleteResourceProfileEventHandler;
import org.gcube.portlets.widgets.mpformbuilder.shared.catalogue.ResourceElementBeanProfile;
import com.github.gwtbootstrap.client.ui.Accordion;
import com.github.gwtbootstrap.client.ui.AccordionGroup;
@ -19,6 +19,7 @@ import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
@ -27,34 +28,31 @@ import com.google.gwt.user.client.ui.Widget;
* A summary of the resources added by the user.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class AddedResourcesSummary extends Composite{
public class AddedResourcesSummaryProfile extends Composite{
private static AddedResourcesSummaryUiBinder uiBinder = GWT
.create(AddedResourcesSummaryUiBinder.class);
interface AddedResourcesSummaryUiBinder extends
UiBinder<Widget, AddedResourcesSummary> {
UiBinder<Widget, AddedResourcesSummaryProfile> {
}
// Event bus
private HandlerManager eventBus;
// list of added resources (beans)
List<ResourceElementBean> addedResources;
List<ResourceElementBeanProfile> addedResources;
@UiField VerticalPanel addResourcesPanel;
public AddedResourcesSummary(HandlerManager eventBus) {
public AddedResourcesSummaryProfile(HandlerManager eventBus) {
initWidget(uiBinder.createAndBindUi(this));
// save bus
this.eventBus = eventBus;
// bind on add resource event
bind();
// init list
addedResources = new ArrayList<ResourceElementBean>();
addedResources = new ArrayList<ResourceElementBeanProfile>();
}
/**
@ -63,13 +61,14 @@ public class AddedResourcesSummary extends Composite{
private void bind() {
// when a new resource is added
eventBus.addHandler(AddResourceEvent.TYPE, new AddResourceEventHandler() {
eventBus.addHandler(AddResourceEventProfile.TYPE, new AddResourceEventProfileHandler() {
@Override
public void onAddedResource(AddResourceEvent addResourceEvent) {
public void onAddedResource(AddResourceEventProfile addResourceEvent) {
GWT.log("Added resource event: "+addResourceEvent);
// get the resource
final ResourceElementBean justAddedResource = addResourceEvent.getResource();
final ResourceElementBeanProfile justAddedResource = addResourceEvent.getResource();
// Build an accordion to show resource info
Accordion accordion = new Accordion();
@ -91,7 +90,7 @@ public class AddedResourcesSummary extends Composite{
@Override
public void onClick(ClickEvent event) {
eventBus.fireEvent(new DeleteResourceEvent(justAddedResource));
eventBus.fireEvent(new DeleteResourceProfileEvent(justAddedResource));
}
});
@ -110,29 +109,24 @@ public class AddedResourcesSummary extends Composite{
});
// when the user wants to delete a resource
eventBus.addHandler(DeleteResourceEvent.TYPE, new DeleteResourceEventHandler() {
eventBus.addHandler(DeleteResourceProfileEvent.TYPE, new DeleteResourceProfileEventHandler() {
@Override
public void onDeletedResource(DeleteResourceEvent deleteResourceEvent) {
public void onDeletedResource(DeleteResourceProfileEvent deleteResourceEvent) {
// to delete
ResourceElementBean toDelete = deleteResourceEvent.getResource();
// find it
ResourceElementBeanProfile toDelete = deleteResourceEvent.getResource();
Window.alert("DELETE RESOURCE MUST BE IMPLEMENTED");
/*
* MUST ME MANAGED IN ANOTHER POINT
*
* for(int i = 0; i < addedResources.size(); i++){
for(int i = 0; i < addedResources.size(); i++){
if(addedResources.get(i).getOriginalIdInWorkspace().equals(toDelete.getOriginalIdInWorkspace())){
if(addedResources.get(i).equals(toDelete)){
// get the associated widget and remove it
final Widget widget = addResourcesPanel.getWidget(i);
// remote call to remove it from the dataset
ckanServices.deleteResourceFromDataset(toDelete, new AsyncCallback<Boolean>() {
MetadataProfileFormBuilderServiceAsync.Util.getInstance().deleteResourceFromDataset(toDelete, new AsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
@ -149,11 +143,15 @@ public class AddedResourcesSummary extends Composite{
break;
}
}*/
}
*/
// remove from the list
addedResources.remove(toDelete);
}
});
}
public HandlerManager getEventBus() {
return eventBus;
}
}

View File

@ -176,6 +176,12 @@ public class TagsPanel extends Composite{
if(tagsList.contains(tag))
return;
//selecting the item of the vocabulary
if(vocabulary!= null && vocabulary.size()>0) {
tagsEnterListBox.setSelectedValue(tag);
return;
}
// ckan accepts only alphanumeric values
String[] subTags = tag.trim().split(" ");

View File

@ -1,46 +0,0 @@
package org.gcube.portlets.widgets.mpformbuilder.client.ui.twincolumnselection;
import org.gcube.portlets.widgets.mpformbuilder.client.ui.icons.Images;
import org.gcube.portlets.widgets.mpformbuilder.shared.catalogue.ResourceElementBean;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.core.client.GWT;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.ui.Image;
/**
* Cell that renders left side panel objects
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class ResourceCellLeft extends AbstractCell<ResourceElementBean>{
private static final Images image = GWT.create(Images.class);
private static final String tipFile = "Hold down the Control (ctrl) or Command button to select multiple options";
private static final String tipFolder = "Click on the folder to navigate it";
@Override
public void render(com.google.gwt.cell.client.Cell.Context context,
ResourceElementBean value, SafeHtmlBuilder sb) {
if (value == null || value.isToBeAdded()) {
return;
}
Image file = new Image(image.fileIcon());
Image folder = new Image(image.folderIcon());
file.setWidth("15px");
file.setHeight("15px");
folder.setWidth("15px");
folder.setHeight("15px");
String whichTip = value.isFolder() ? tipFolder : tipFile;
sb.appendHtmlConstant("<div title='" + value.getName() + "( " + whichTip + " )" + "' style='overflow-x:hidden;white-space:nowrap;text-overflow:ellipsis;max-width:240px; min-height:30px; padding-top:5px;'>");
sb.appendHtmlConstant("<span style='margin-left:5px;'>");
sb.appendHtmlConstant(value.isFolder() ? folder.toString() : file.toString());
sb.appendHtmlConstant("</span>");
sb.appendHtmlConstant("<span style='margin-left:10px;'>");
sb.appendHtmlConstant("<b>");
sb.appendEscaped(value.getName());
sb.appendHtmlConstant("</b>");
sb.appendHtmlConstant("</span>");
sb.appendHtmlConstant("</div>");
}
}

View File

@ -1,65 +0,0 @@
package org.gcube.portlets.widgets.mpformbuilder.client.ui.twincolumnselection;
import org.gcube.portlets.widgets.mpformbuilder.client.ui.icons.Images;
import org.gcube.portlets.widgets.mpformbuilder.shared.catalogue.ResourceElementBean;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.cell.client.ValueUpdater;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.ui.Image;
/**
* Cell that renders right side panel objects
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class ResourceCellRight extends AbstractCell<ResourceElementBean>{
private static final Images image = GWT.create(Images.class);
private static final String tip = "Hold down the Control (CTRL) or Command button to select multiple options. Double click to access "
+ "this resource information";
public ResourceCellRight() {
super("keydown", "dblclick");
}
@Override
public void render(com.google.gwt.cell.client.Cell.Context context,
ResourceElementBean value, SafeHtmlBuilder sb) {
if (value == null || !value.isToBeAdded() || value.isFolder()) {
return;
}
Image file = new Image(image.fileIcon());
file.setWidth("15px");
file.setHeight("15px");
sb.appendHtmlConstant("<div title='" + value.getName() + "( " + tip + " )" + "' style='overflow-x:hidden;white-space:nowrap;text-overflow:ellipsis;max-width:240px; min-height:30px; padding-top:5px;'>");
sb.appendHtmlConstant("<span style='margin-left:5px'>");
sb.appendHtmlConstant(file.toString());
sb.appendHtmlConstant("</span>");
sb.appendHtmlConstant("<span style='margin-left:10px'>");
sb.appendHtmlConstant("<b>");
sb.appendEscaped(value.getEditableName());
sb.appendHtmlConstant("</b>");
sb.appendHtmlConstant("</span>");
sb.appendHtmlConstant("</div>");
}
@Override
public void onBrowserEvent(com.google.gwt.cell.client.Cell.Context context,
Element parent, ResourceElementBean value, NativeEvent event,
ValueUpdater<ResourceElementBean> valueUpdater) {
if(value == null || TwinColumnSelectionMainPanel.isFroozen())
return;
super.onBrowserEvent(context, parent, value, event, valueUpdater);
ResourceInfoForm info = new ResourceInfoForm(value, valueUpdater);
if(TwinColumnSelectionMainPanel.detailContainer.getWidget() != null)
TwinColumnSelectionMainPanel.detailContainer.clear();
TwinColumnSelectionMainPanel.detailContainer.add(info);
TwinColumnSelectionMainPanel.detailContainer.setVisible(true);
}
}

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.widgets.mpformbuilder.client.ui.twincolumnselection;
import org.gcube.portlets.widgets.mpformbuilder.shared.catalogue.ResourceElementBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.catalogue.ResourceElementBeanProfile;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.ControlGroup;
@ -44,7 +44,7 @@ public class ResourceInfoForm extends Composite{
@UiField
ControlGroup controlName;
private ResourceElementBean resourceBean;
private ResourceElementBeanProfile resourceBean;
private static ResourceInfoFormUiBinder uiBinder = GWT
.create(ResourceInfoFormUiBinder.class);
@ -57,7 +57,7 @@ public class ResourceInfoForm extends Composite{
initWidget(uiBinder.createAndBindUi(this));
}
public ResourceInfoForm(final ResourceElementBean resource, final ValueUpdater<ResourceElementBean> valueUpdater) {
public ResourceInfoForm(final ResourceElementBeanProfile resource, final ValueUpdater<ResourceElementBeanProfile> valueUpdater) {
initWidget(uiBinder.createAndBindUi(this));
resourceBean = resource;

View File

@ -1,571 +0,0 @@
package org.gcube.portlets.widgets.mpformbuilder.client.ui.twincolumnselection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.gcube.portlets.widgets.mpformbuilder.shared.catalogue.ResourceElementBean;
import com.github.gwtbootstrap.client.ui.Breadcrumbs;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.FluidContainer;
import com.github.gwtbootstrap.client.ui.NavLink;
import com.google.gwt.cell.client.ValueUpdater;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.BorderStyle;
import com.google.gwt.dom.client.Style.FontWeight;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.cellview.client.CellList;
import com.google.gwt.user.cellview.client.HasKeyboardPagingPolicy.KeyboardPagingPolicy;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.MultiSelectionModel;
import com.google.gwt.view.client.SelectionChangeEvent;
/**
* The twin column panels for selection of the files to attach to the catalague product.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
* @author Francesco Mangiacrapa at ISTI-CNR
*/
public class TwinColumnSelectionMainPanel extends Composite{
@UiField
VerticalPanel leftContainer;
@UiField
VerticalPanel rightContainer;
@UiField
VerticalPanel buttonsPanel;
@UiField
Button allToRightButton;
@UiField
Button toRightButton;
@UiField
Button toLeftButton;
@UiField
Button allToLeftButton;
// @UiField
// Popover popoverResourceSelection;
// @UiField
// Button resourceInfoButton;
@UiField
Breadcrumbs breadcrumbs;
@UiField
FluidContainer mainContainerResourcesSelection;
// @UiField
// Button getResources;
@UiField
public static SimplePanel detailContainer;
/**
* The breadcrumb subpath with the linked folder
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
private class PathBean{
NavLink link;
ResourceElementBean resourceFolder;
PathBean(NavLink link, ResourceElementBean resourceFolder){
this.link = link;
this.resourceFolder = resourceFolder;
}
}
private static boolean frozen = false;
private List<PathBean> pathListBeans = new ArrayList<PathBean>();
private static final String PANEL_BORDER_COLOR = "#8899a6";
private static final String PANEL_HEIGHT = "400px";
private ShowMorePagerPanel showMorePanelLeft = new ShowMorePagerPanel();
private ShowMorePagerPanel showMorePanelRight = new ShowMorePagerPanel();
private CellList<ResourceElementBean> cellListLeft;
private CellList<ResourceElementBean> cellListRight;
private ListDataProvider<ResourceElementBean> dataProviderLeft = new ListDataProvider<ResourceElementBean>();
private ListDataProvider<ResourceElementBean> dataProviderRight = new ListDataProvider<ResourceElementBean>();
private MultiSelectionModel<ResourceElementBean> selectionModelRight;
private MultiSelectionModel<ResourceElementBean> selectionModelLeft;
private final ResourceElementBean initialBean;
// private final static HTML aboutHeader = new HTML("<b>Resource Manager</b>");
// private final static HTML aboutBody = new HTML("<p style='text-align:justify;'>Move the files you want to attach to the product on the right panel below."
// + " Please consider that any complex hierarchy structure you may have will be flatten.</p>");
// private static final short PATH_THRESHOLD = 1; // TODO
private static TwinColumnSelectionMainPanelUiBinder uiBinder = GWT
.create(TwinColumnSelectionMainPanelUiBinder.class);
interface TwinColumnSelectionMainPanelUiBinder extends
UiBinder<Widget, TwinColumnSelectionMainPanel> {
}
public TwinColumnSelectionMainPanel(ResourceElementBean initialBean) {
initWidget(uiBinder.createAndBindUi(this));
frozen = false;
GWT.log(initialBean.toString());
this.initialBean = initialBean;
buttonsPanel.getElement().getStyle().setMarginTop(50, Unit.PCT);
allToRightButton.getElement().getStyle().setMarginBottom(4, Unit.PX);
toRightButton.getElement().getStyle().setMarginBottom(4, Unit.PX);
toLeftButton.getElement().getStyle().setMarginBottom(4, Unit.PX);
allToLeftButton.getElement().getStyle().setMarginBottom(4, Unit.PX);
buttonsPanel.getElement().setAttribute("align", "center");
// popoverResourceSelection.setPlacement(Placement.LEFT);
// popoverResourceSelection.setHeading(aboutHeader.getHTML());
// popoverResourceSelection.setText(aboutBody.getHTML());
// resourceInfoButton.getElement().getStyle().setFloat(Float.RIGHT);
// resourceInfoButton.getElement().getStyle().setPaddingRight(0, Unit.PX);
mainContainerResourcesSelection.getElement().getStyle().setPadding(10, Unit.PX);
breadcrumbs.getElement().getStyle().setBackgroundColor("white");
breadcrumbs.getElement().getStyle().setFontWeight(FontWeight.BOLD);
breadcrumbs.getElement().getStyle().setMarginLeft(0, Unit.PX);
mainContainerResourcesSelection.getElement().getStyle().setMarginLeft(10, Unit.PX);
mainContainerResourcesSelection.getElement().getStyle().setMarginBottom(20, Unit.PX);
mainContainerResourcesSelection.getElement().getStyle().setMarginTop(0, Unit.PX);
prepareHandlers();
initLeftSidePanel(initialBean);
initRightSidePanel();
}
/**
* Initialize the left side panel
*/
private void initLeftSidePanel(final ResourceElementBean initialBean) {
// initialize the left side list
ResourceCellLeft cell = new ResourceCellLeft();
// Set a key provider that provides a unique key for each object.
cellListLeft = new CellList<ResourceElementBean>(cell, ResourceElementBean.KEY_PROVIDER);
cellListLeft.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE);
// set page size
int size = initialBean.isFolder() ? initialBean.getChildren().size() : 1;
cellListLeft.setPageSize(size);
// Add a selection model so we can select cells.
selectionModelLeft = new MultiSelectionModel<ResourceElementBean>(ResourceElementBean.KEY_PROVIDER);
cellListLeft.setSelectionModel(selectionModelLeft);
// perform an action on selection
selectionModelLeft.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
public void onSelectionChange(SelectionChangeEvent event) {
if(frozen)
return;
Iterator<ResourceElementBean> selectedObjectsIterator = selectionModelLeft.getSelectedSet().iterator();
while (selectedObjectsIterator.hasNext()) {
ResourceElementBean selectedBean = selectedObjectsIterator.next();
if(selectedBean.isFolder()){
// a single folder selected
if(selectionModelLeft.getSelectedSet().size() == 1){
// update path
final NavLink navElem = new NavLink(selectedBean.getName());
navElem.getElement().getStyle().setFontWeight(FontWeight.BOLD);
final PathBean pathBean = new PathBean(navElem, selectedBean);
navElem.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
removeStartingFromBreadcrumbs(navElem, pathBean);
GWT.log("Clicked on element " + pathBean.resourceFolder.getName());
//breadcrumbsUpdater();
ResourceElementBean folder = pathBean.resourceFolder;
Collections.sort(folder.getChildren());
dataProviderLeft.setList(folder.getChildren());
dataProviderLeft.refresh();
}
});
pathListBeans.add(pathBean);
breadcrumbs.add(navElem);
//breadcrumbsUpdater();
Collections.sort(selectedBean.getChildren());
GWT.log("Children " + selectedBean.getChildren());
dataProviderLeft.setList(selectedBean.getChildren());
cellListLeft.setPageSize(selectedBean.getChildren().size());
dataProviderLeft.refresh();
}
selectionModelLeft.setSelected(selectedBean, false);
}
}
// enable the buttons that allows to move the objects to the right
enableMoveToRightButtons(selectionModelLeft.getSelectedSet());
}
});
// set the list into the provider
if(initialBean.isFolder()){
Collections.sort(this.initialBean.getChildren());
dataProviderLeft.setList(this.initialBean.getChildren());
}else
dataProviderLeft.setList(Arrays.asList(this.initialBean));
// add root to breadcrumb
final NavLink root = new NavLink(initialBean.getName());
final PathBean pathBean = new PathBean(root, initialBean);
root.getElement().getStyle().setFontWeight(FontWeight.BOLD);
pathListBeans.add(pathBean);
breadcrumbs.add(root);
root.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
removeStartingFromBreadcrumbs(root, pathBean);
//breadcrumbsUpdater();
// set back the root content list
dataProviderLeft.setList(initialBean.getChildren());
cellListLeft.setPageSize(initialBean.getChildren().size());
dataProviderLeft.refresh();
}
});
// set the cell list into the provider
dataProviderLeft.addDataDisplay(cellListLeft);
// manage showMorePanelLeft
showMorePanelLeft.setDisplay(cellListLeft);
showMorePanelLeft.setHeight(PANEL_HEIGHT);
showMorePanelLeft.getElement().getStyle().setBorderStyle(BorderStyle.SOLID);
showMorePanelLeft.getElement().getStyle().setBorderWidth(2, Unit.PX);
showMorePanelLeft.getElement().getStyle().setBorderColor(PANEL_BORDER_COLOR);
// add the list to the leftContainerPanel
leftContainer.add(showMorePanelLeft);
}
/**
* Update the path
* @param navElem
* @param pathBean
*/
public void removeStartingFromBreadcrumbs(NavLink navElem, PathBean pathBean){
// remove data after
Iterator<Widget> iteratorBreadcrumb = breadcrumbs.iterator();
Iterator<PathBean> iteratorListPath = pathListBeans.iterator();
boolean delete = false;
while(iteratorBreadcrumb.hasNext()){
Widget current = iteratorBreadcrumb.next();
if(delete){
current.removeFromParent();
iteratorBreadcrumb.remove();
}
if(!delete && navElem.equals(current))
delete = true;
}
delete = false;
while(iteratorListPath.hasNext()){
PathBean current = iteratorListPath.next();
if(delete)
iteratorListPath.remove();
if(!delete && pathBean.equals(current))
delete = true;
}
}
/**
* Initialize the left side panel
*/
private void initRightSidePanel() {
// initialize the left side list
ResourceCellRight cell = new ResourceCellRight();
// Set a key provider that provides a unique key for each object.
cellListRight = new CellList<ResourceElementBean>(cell, ResourceElementBean.KEY_PROVIDER);
cellListRight.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE);
cellListRight.setValueUpdater(new ValueUpdater<ResourceElementBean>() {
@Override
public void update(ResourceElementBean value) {
// just redraw the list
cellListRight.redraw();
}
});
// Add a selection model so we can select cells.
selectionModelRight = new MultiSelectionModel<ResourceElementBean>(ResourceElementBean.KEY_PROVIDER);
cellListRight.setSelectionModel(selectionModelRight);
// perform an action on selection
selectionModelRight.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
public void onSelectionChange(SelectionChangeEvent event) {
if(frozen)
return;
enableMoveToLeftButtons(selectionModelRight.getSelectedSet());
}
});
// set the cell list into the provider
dataProviderRight.addDataDisplay(cellListRight);
// manage showMorePanelRight
showMorePanelRight.setDisplay(cellListRight);
showMorePanelRight.setHeight(PANEL_HEIGHT);
showMorePanelRight.getElement().getStyle().setBorderStyle(BorderStyle.SOLID);
showMorePanelRight.getElement().getStyle().setBorderWidth(2, Unit.PX);
showMorePanelRight.getElement().getStyle().setBorderColor(PANEL_BORDER_COLOR);
// add the list to the leftContainerPanel
rightContainer.add(showMorePanelRight);
}
/**
* Enable/disable the buttons to move objects from left to right properly.
* @param setselectedItemsLeft
*/
private void enableMoveToRightButtons(Set<ResourceElementBean> setselectedItemsLeft){
if(setselectedItemsLeft == null || setselectedItemsLeft.isEmpty()){
allToRightButton.setEnabled(false);
toRightButton.setEnabled(false);
}
else if(setselectedItemsLeft.size() > 1){
allToRightButton.setEnabled(true);
toRightButton.setEnabled(false);
}
else{
allToRightButton.setEnabled(false);
toRightButton.setEnabled(true);
}
}
/**
* Enable/disable the buttons to move objects from right to left properly.
* @param setselectedItemsRight
*/
private void enableMoveToLeftButtons(Set<ResourceElementBean> setselectedItemsRight){
if(setselectedItemsRight == null || setselectedItemsRight.isEmpty()){
allToLeftButton.setEnabled(false);
allToLeftButton.setEnabled(false);
}
else if(setselectedItemsRight.size() > 1){
allToLeftButton.setEnabled(true);
toLeftButton.setEnabled(false);
}
else{
allToLeftButton.setEnabled(false);
toLeftButton.setEnabled(true);
}
}
/**
* Prepare the buttons' handlers
*/
private void prepareHandlers() {
allToRightButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
moveToRight(selectionModelLeft.getSelectedSet());
}
});
toRightButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
moveToRight(selectionModelLeft.getSelectedSet());
}
});
allToLeftButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
moveToLeft(selectionModelRight.getSelectedSet());
}
});
toLeftButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
moveToLeft(selectionModelRight.getSelectedSet());
}
});
}
/**
* Move to right elements
* @param set the elements to move
*/
private void moveToRight(Set<ResourceElementBean> setSelected){
if(setSelected == null || setSelected.isEmpty())
return;
Iterator<ResourceElementBean> iterator = setSelected.iterator();
while (iterator.hasNext()) {
ResourceElementBean resourceElementBean = iterator
.next();
resourceElementBean.setToBeAdded(true);
int indexRight = dataProviderRight.getList().indexOf(resourceElementBean);
if(indexRight >= 0)
dataProviderRight.getList().set(indexRight, resourceElementBean);
else{
dataProviderRight.getList().add(resourceElementBean);
Collections.sort(dataProviderRight.getList());
dataProviderRight.refresh();
}
int indexLeft = dataProviderLeft.getList().indexOf(resourceElementBean);
dataProviderLeft.getList().set(indexLeft, resourceElementBean);
}
}
/**
* Move to left elements
* @param setSelected the elements to move
*/
private void moveToLeft(Set<ResourceElementBean> setSelected){
if(setSelected == null || setSelected.isEmpty())
return;
Iterator<ResourceElementBean> iterator = setSelected.iterator();
while (iterator.hasNext()) {
ResourceElementBean resourceElementBean = iterator.next();
resourceElementBean.setToBeAdded(false);
}
Collections.sort(dataProviderLeft.getList());
dataProviderLeft.refresh();
dataProviderRight.refresh();
}
/**
* Freeze the panel
*/
public void freeze(boolean bool) {
frozen = bool;
Iterator<Widget> iteratorOverPath = breadcrumbs.iterator();
while (iteratorOverPath.hasNext()) {
Widget widget = iteratorOverPath.next();
if(widget instanceof NavLink)
((NavLink)widget).setActive(!bool);
}
allToRightButton.setEnabled(!bool);
toRightButton.setEnabled(!bool);
allToLeftButton.setEnabled(!bool);
toLeftButton.setEnabled(!bool);
}
/**
* Returns the root parent with the children as files to save
* @return the resources to save
*/
public ResourceElementBean getResourcesToPublish(){
List<ResourceElementBean> current = dataProviderRight.getList();
ResourceElementBean toReturn = new ResourceElementBean();
List<ResourceElementBean> children = new ArrayList<ResourceElementBean>();
for (ResourceElementBean resource : current) {
if(resource.isToBeAdded() && !resource.isFolder()){ // be sure ...
ResourceElementBean beanWithoutChildren = new ResourceElementBean(resource);
beanWithoutChildren.setName(resource.getEditableName());
children.add(beanWithoutChildren);
}
}
toReturn.setChildren(children);
return toReturn;
}
/**
* @return the freezed
*/
public static boolean isFroozen() {
return frozen;
}
// @UiHandler("getResources")
// void getResources(ClickEvent ce){
// getResourcesToPublish();
// }
//
// /**
// * Short the current path if needed
// */
// private void breadcrumbsUpdater(){
//
// // ignore first and last elem
// boolean reduce = (pathListBeans.size() - 2) > PATH_THRESHOLD;
//
// GWT.log("Is to reduce? " + reduce);
//
// GWT.log("Full size is " + pathListBeans.size());
//
// if(!reduce){
// GWT.log("Restore");
// for(int i = 0; i < pathListBeans.size(); i++){
// PathBean bean = pathListBeans.get(i);
// GWT.log("Elem is " + bean.resourceFolder);
// bean.link.setText(bean.resourceFolder.getName());
// bean.link.setVisible(true);
// }
// }else{
// for(int i = 1; i < pathListBeans.size(); i++){
// PathBean bean = pathListBeans.get(i);
//
// if(i == (pathListBeans.size() - 1)){
// bean.link.setText(bean.resourceFolder.getName());
// bean.link.setVisible(true);
// }else if(i == (pathListBeans.size() - 2)){
// GWT.log("The last to modify ****" + bean.resourceFolder.getName());
// bean.link.setText("...");
// bean.link.setVisible(true);
// }else{
// bean.link.setText(bean.resourceFolder.getName());
// bean.link.setVisible(false);
// }
// }
// }
// GWT.log("Updated list is " + pathListBeans.toString());
// }
}

View File

@ -1,58 +0,0 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
xmlns:m="urn:import:org.gcube.portlets.widgets.mpformbuilder.client.ui.twincolumnselection">
<ui:style>
</ui:style>
<g:HTMLPanel>
<b:FluidContainer ui:field="mainContainerResourcesSelection">
<!-- <b:FluidRow> -->
<!-- <b:Column offset="6" size="1"> -->
<!-- <b:Popover ui:field="popoverResourceSelection" html="true"> -->
<!-- <b:Button ui:field="resourceInfoButton" type="LINK" icon="INFO_SIGN" -->
<!-- size="LARGE"></b:Button> -->
<!-- </b:Popover> -->
<!-- </b:Column> -->
<!-- </b:FluidRow> -->
<b:FluidRow>
<b:Column size="11">
<b:Breadcrumbs ui:field="breadcrumbs" divider=">"
title="Current path">
</b:Breadcrumbs>
</b:Column>
</b:FluidRow>
<b:FluidRow>
<b:Column size="3" ui:field="leftColumn">
<!-- <b:Button enabled="true" type="LINK" ui:field="goRootButton">Root
level</b:Button> -->
<!-- <b:Button enabled="true" type="LINK" ui:field="goUpButton">Go up</b:Button> -->
<g:VerticalPanel ui:field="leftContainer" width="100%">
</g:VerticalPanel>
</b:Column>
<b:Column size="1" ui:field="centralPanel">
<g:VerticalPanel ui:field="buttonsPanel">
<b:Button ui:field="allToRightButton" name="toRight"
enabled="false" title="Add selected files" text=">>" />
<b:Button ui:field="toRightButton" name="toRight"
enabled="false" title="Add selected file" text=">" />
<b:Button ui:field="toLeftButton" name="toLeft" enabled="false"
title="Remove selected file" text="&lt;" />
<b:Button ui:field="allToLeftButton" name="toRight"
enabled="false" title="Remove selected files" text="&lt;&lt;" />
</g:VerticalPanel>
</b:Column>
<b:Column size="3" ui:field="rightColumn">
<g:VerticalPanel ui:field="rightContainer" width="100%"></g:VerticalPanel>
</b:Column>
<b:Column size="3" ui:field="detailColumn">
<g:SimplePanel ui:field="detailContainer" width="100%"></g:SimplePanel>
</b:Column>
<!-- <b:Column size="2"> -->
<!-- <m:ResourceInfoForm ui:field="resourceInfoForm"></m:ResourceInfoForm> -->
<!-- </b:Column> -->
</b:FluidRow>
</b:FluidContainer>
<!-- <b:Button ui:field="getResources">Get Resources</b:Button> -->
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -1,6 +1,5 @@
package org.gcube.portlets.widgets.mpformbuilder.client.ui.upload;
import java.util.ArrayList;
import java.util.List;
@ -25,58 +24,56 @@ import com.google.gwt.user.client.ui.Hidden;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
// TODO: Auto-generated Javadoc
/**
* The Class DialogUploadStream.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Sep 24, 2015
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Sep 24, 2015
*/
public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotificationListener{
public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotificationListener {
/** The file upload. */
//protected final FormPanel formPanel = new FormPanel();
// protected final FormPanel formPanel = new FormPanel();
protected FileUpload fileUpload;
/** The json client keys. */
protected Hidden jsonClientKeys;
/** The fake uploaders. */
protected List<FileUploadingState> fakeUploaders = new ArrayList<FileUploadingState>();
/** The controller. */
protected WorkspaceUploaderListenerController controller = new WorkspaceUploaderListenerController();
/** The timer. */
protected TimerUpload timer;
protected String fieldName;
/**
* The Enum UPLOAD_TYPE.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Sep 11, 2015
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Sep 11, 2015
*/
private HTML UPLOADING = new HTML("Uploading...");
/** The vertical main panel. */
protected VerticalPanel verticalMainPanel;
// private MonitorPanel monitorPanel;
//protected String clientUploadKey;
// protected String clientUploadKey;
/** The purged uploading file name. */
private String purgedUploadingFileName;
/** The upv. */
private UploaderProgressView upv;
/**
* Instantiates a new dialog upload stream.
*/
public DialogUpload(){
//setWidth("400px");
public DialogUpload() {
fileUpload = new FileUpload();
//fileUpload.getElement().setAttribute("multiple", "multiple");
// fileUpload.getElement().setAttribute("multiple", "multiple");
setAction(ConstantsMPFormBuilder.METADATA_FORM_BUILDER_UPLOADING_SERVLET);
setEncoding(FormPanel.ENCODING_MULTIPART);
setMethod(FormPanel.METHOD_POST);
@ -89,8 +86,12 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
fileUpload.setName(ConstantsMPFormBuilder.UPLOAD_FORM_ELEMENT);
// Add hidden parameters
verticalMainPanel.add(new Hidden(ConstantsMPFormBuilder.CURR_GROUP_ID, GCubeClientContext.getCurrentContextId()));
verticalMainPanel.add(new Hidden(ConstantsMPFormBuilder.UPLOAD_TYPE, ConstantsMPFormBuilder.THE_UPLOAD_TYPE.File.name()));
verticalMainPanel
.add(new Hidden(ConstantsMPFormBuilder.CURR_GROUP_ID, GCubeClientContext.getCurrentContextId()));
verticalMainPanel.add(
new Hidden(ConstantsMPFormBuilder.UPLOAD_TYPE, ConstantsMPFormBuilder.THE_UPLOAD_TYPE.File.name()));
verticalMainPanel.add(new Hidden(ConstantsMPFormBuilder.UPL_FIELD_NAME_FILEPATH, fieldName));
initJsonClientKeys();
verticalMainPanel.add(jsonClientKeys);
@ -105,6 +106,24 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
verticalMainPanel.add(hp);
}
/**
* Sets the field name.
*
* @param fieldName the new field name
*/
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
/**
* Gets the field name.
*
* @return the field name
*/
public String getFieldName() {
return fieldName;
}
/**
* Gets the panel.
*
@ -117,14 +136,14 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
/**
* Inits the json client keys.
*/
protected void initJsonClientKeys(){
jsonClientKeys = new Hidden(ConstantsMPFormBuilder.CLIENT_UPLOAD_KEYS,"");
protected void initJsonClientKeys() {
jsonClientKeys = new Hidden(ConstantsMPFormBuilder.CLIENT_UPLOAD_KEYS, "");
}
/**
* Bind events.
*/
public void bindEvents(){
public void bindEvents() {
this.addHandlers();
// this.addListeners();
}
@ -143,10 +162,11 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
// isStatusCompleted = true;
String result = event.getResults();
if (result == null) {
if (result == null) {
removeLoading();
Window.alert("An error occurred during file upload");
//new DialogResult(null, "Error during upload", "An error occurred during file upload.").center();
// new DialogResult(null, "Error during upload", "An error occurred during file
// upload.").center();
return;
}
String strippedResult = new HTML(result).getText();
@ -155,25 +175,25 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
switch (resultMessage.getStatus()) {
case ERROR:
removeLoading();
//timer.cancel();
GWT.log("Error during upload "+resultMessage.getMessage());
// timer.cancel();
GWT.log("Error during upload " + resultMessage.getMessage());
break;
case UNKNOWN:
removeLoading();
//timer.cancel();
GWT.log("Error during upload "+resultMessage.getMessage());
// timer.cancel();
GWT.log("Error during upload " + resultMessage.getMessage());
break;
case WARN: {
GWT.log("Upload completed with warnings "+resultMessage.getMessage());
GWT.log("Upload completed with warnings " + resultMessage.getMessage());
removeLoading();
//timer.cancel();
// timer.cancel();
break;
}
case SESSION_EXPIRED:{
GWT.log("Upload aborted due to session expired: "+ resultMessage.getMessage());
case SESSION_EXPIRED: {
GWT.log("Upload aborted due to session expired: " + resultMessage.getMessage());
Window.alert("Session expired, please reload the page");
removeLoading();
//timer.cancel();
// timer.cancel();
break;
}
case OK: {
@ -193,7 +213,7 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
}
});
//TODO NEVER USED, WE ARE USING MULTIPLE DIALOG UPLOAD
// TODO NEVER USED, WE ARE USING MULTIPLE DIALOG UPLOAD
addSubmitHandler(new SubmitHandler() {
@Override
@ -209,41 +229,45 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
public void onChange(ChangeEvent event) {
GWT.log("btnSubmit click");
if (fileUpload.getFilename()==null || !(fileUpload.getFilename().length()>2)) {
if (fileUpload.getFilename() == null || !(fileUpload.getFilename().length() > 2)) {
GWT.log("No file specified ");
return;
}
GWT.log("fileUpload.getFilename() "+fileUpload.getFilename());
GWT.log("fileUpload.getFilename() " + fileUpload.getFilename());
/*
* TODO: recall: Some browser would write in fileUploadField.getValue() C:\fakepath\$fileName
* TODO: recall: Some browser would write in fileUploadField.getValue()
* C:\fakepath\$fileName
*/
String normalizedFileName = fileUpload.getFilename();
if (normalizedFileName.contains("\\")) {
normalizedFileName = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\")+1); //remove C:\fakepath\ if exists
normalizedFileName = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\") + 1); // remove
// C:\fakepath\
// if
// exists
}
purgedUploadingFileName = normalizedFileName;
submitForm();
}
});
}
/**
* On submit action.
*/
protected void onSubmitAction() {
GWT.log("SubmitEvent");
try {
if(upv!=null)
if (upv != null)
verticalMainPanel.remove(upv.getPanel());
}catch (Exception e) {
} catch (Exception e) {
// TODO: handle exception
}
addLoading();
enableButtons(false);
//Only the first, just to manage single uploading
FileUploadingState workspaceUploaderItem = fakeUploaders.get(0);
// Only the first, just to manage single uploading
FileUploadingState workspaceUploaderItem = fakeUploaders.get(0);
upv = new UploaderProgressView(workspaceUploaderItem, workspaceUploaderItem.getFile().getFileName(), null);
verticalMainPanel.add(upv.getPanel());
removeLoading();
@ -252,33 +276,32 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
fakeUploaders.clear();
}
/**
* Gets the file uploading state.
*
* @return the file uploading state
*/
public FileUploadingState getFileUploadingState() {
if(timer!=null)
if (timer != null)
return timer.getLastWorkspaceUploader();
return null;
}
/**
* Adds the loading.
*/
protected void addLoading(){
protected void addLoading() {
verticalMainPanel.add(UPLOADING);
}
/**
* Removes the loading.
*/
protected void removeLoading(){
try{
protected void removeLoading() {
try {
verticalMainPanel.remove(UPLOADING);
}catch(Exception e){
} catch (Exception e) {
}
}
@ -288,7 +311,7 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
*
* @param bool the bool
*/
protected void enableButtons(boolean bool){
protected void enableButtons(boolean bool) {
// btnUpload.setEnabled(bool);
// btnCancel.setEnabled(bool);
// upload.setEnabled(bool);
@ -297,37 +320,33 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
/**
* Submit form.
*/
public void submitForm(){
public void submitForm() {
submit();
}
/**
* Removes the item and submit form.
*
* @param itemId the item id
*/
protected void removeItemAndSubmitForm(String itemId){
protected void removeItemAndSubmitForm(String itemId) {
/*
AppControllerExplorer.rpcWorkspaceService.removeItem(itemId, new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
Info.display("Error", caught.getMessage());
}
@Override
public void onSuccess(Boolean result) {
if(result){
hiddenOverwrite.setValue("true");
submitForm();
}
}
});*/
* AppControllerExplorer.rpcWorkspaceService.removeItem(itemId, new
* AsyncCallback<Boolean>() {
*
* @Override public void onFailure(Throwable caught) { Info.display("Error",
* caught.getMessage());
*
*
* }
*
* @Override public void onSuccess(Boolean result) { if(result){
* hiddenOverwrite.setValue("true"); submitForm(); }
*
* }
*
* });
*/
}
/**
@ -335,8 +354,8 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
*
* @param itemId the item id
*/
protected void updateItemSubmitForm(String itemId){
//hiddenOverwrite.setValue("true");
protected void updateItemSubmitForm(String itemId) {
// hiddenOverwrite.setValue("true");
submitForm();
}
@ -345,8 +364,14 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
*
* @param handler the handler
*/
/* (non-Javadoc)
* @see org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.HasWorskpaceUploadNotificationListener#addWorkspaceUploadNotificationListener(org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener)
/*
* (non-Javadoc)
*
* @see org.gcube.portlets.widgets.workspaceuploader.client.
* WorkspaceUploadNotification.HasWorskpaceUploadNotificationListener#
* addWorkspaceUploadNotificationListener(org.gcube.portlets.widgets.
* workspaceuploader.client.WorkspaceUploadNotification.
* WorskpaceUploadNotificationListener)
*/
@Override
public void addWorkspaceUploadNotificationListener(WorskpaceUploadNotificationListener handler) {
@ -358,22 +383,26 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
*
* @param handler the handler
*/
/* (non-Javadoc)
* @see org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.HasWorskpaceUploadNotificationListener#removeWorkspaceUploadNotificationListener(org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener)
/*
* (non-Javadoc)
*
* @see org.gcube.portlets.widgets.workspaceuploader.client.
* WorkspaceUploadNotification.HasWorskpaceUploadNotificationListener#
* removeWorkspaceUploadNotificationListener(org.gcube.portlets.widgets.
* workspaceuploader.client.WorkspaceUploadNotification.
* WorskpaceUploadNotificationListener)
*/
@Override
public void removeWorkspaceUploadNotificationListener(WorskpaceUploadNotificationListener handler) {
controller.removeWorkspaceUploadListener(handler);
}
/**
* Enable upload.
*
* @param bool the bool
*/
public void enableUpload(boolean bool){
public void enableUpload(boolean bool) {
fileUpload.setEnabled(bool);
}
}

View File

@ -16,9 +16,9 @@ public class FileUpload extends Composite {
@UiField HTMLPanel fileUploadPanel;
public FileUpload() {
public FileUpload(String fielName) {
initWidget(uiBinder.createAndBindUi(this));
fileUploadPanel.add(new MultipleDilaogUpload());
fileUploadPanel.add(new MultipleDilaogUpload(fielName));
}
}

View File

@ -7,6 +7,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import org.gcube.portlets.widgets.mpformbuilder.client.ConstantsMPFormBuilder;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FilePath;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadingState;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadingState.UPLOAD_STATUS;
@ -21,7 +22,6 @@ import com.google.gwt.json.client.JSONString;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HTML;
// TODO: Auto-generated Javadoc
/**
* The Class MultipleDilaogUploadStream.
*
@ -31,27 +31,30 @@ public class MultipleDilaogUpload extends DialogUpload {
/** The Constant FILE_DELEMITER. */
public static final String FILE_DELEMITER = ";";
/** The file upload ID. */
private String fileUploadID;
/** The instance. */
//private MultipleDNDUpload dnd;
// private MultipleDNDUpload dnd;
public MultipleDilaogUpload instance = this;
/** The json keys. */
private String jsonKeys;
/** The id folder. */
private String idFolder;
/**
* Instantiates a new multiple dilaog upload.
*
* @param fieldName the field name used in the web form
*/
public MultipleDilaogUpload() {
fileUploadID = GenerateUUID.get(10, 16); // is tagID
fileUpload.getElement().setId(fileUploadID);
public MultipleDilaogUpload(String fieldName) {
this.fileUploadID = GenerateUUID.get(10, 16); // is tagID
this.fileUpload.getElement().setId(fileUploadID);
super.setFieldName(fieldName);
this.addHandlers();
}
@ -63,7 +66,7 @@ public class MultipleDilaogUpload extends DialogUpload {
*/
public void generateFakeUploaders(String filesSelected) {
if(filesSelected==null || filesSelected.isEmpty())
if (filesSelected == null || filesSelected.isEmpty())
return;
String[] files = filesSelected.split(FILE_DELEMITER);
@ -72,11 +75,12 @@ public class MultipleDilaogUpload extends DialogUpload {
for (int i = 0; i < files.length; i++) {
String normalizedFileName = files[i];
if (normalizedFileName.contains("\\")) {
files[i] = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\") + 1); // remove C:\fakepath if exists
files[i] = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\") + 1); // remove C:\fakepath
// if exists
}
}
GWT.log("generating fake uploaders on: "+Arrays.asList(files.toString()));
GWT.log("generating fake uploaders on: " + Arrays.asList(files.toString()));
fakeUploaders = new ArrayList<FileUploadingState>(files.length);
for (int i = 0; i < files.length; i++) {
FileUploadingState fakeItem = new FileUploadingState();
@ -85,10 +89,12 @@ public class MultipleDilaogUpload extends DialogUpload {
FileUploaded fakeFile = new FileUploaded();
fakeFile.setFileName(files[i]);
fakeItem.setFile(fakeFile);
fakeFile.setFilePath(new FilePath(getFieldName())); // The Form Field Label is unique for single-multiple
// upload
fakeUploaders.add(fakeItem);
}
GWT.log("fakeUploaders generated: "+fakeUploaders.toString());
GWT.log("fakeUploaders generated: " + fakeUploaders.toString());
}
/**
@ -103,7 +109,7 @@ public class MultipleDilaogUpload extends DialogUpload {
@Override
public void onSubmitComplete(SubmitCompleteEvent event) {
GWT.log("onSubmitComplete in multipleupload");
// isStatusCompleted = true;
String result = event.getResults();
@ -115,31 +121,30 @@ public class MultipleDilaogUpload extends DialogUpload {
return;
}
String strippedResult = new HTML(result).getText();
final HandlerResultMessage resultMessage = HandlerResultMessage
.parseResult(strippedResult);
final HandlerResultMessage resultMessage = HandlerResultMessage.parseResult(strippedResult);
switch (resultMessage.getStatus()) {
case ERROR:
removeLoading();
//timer.cancel();
// timer.cancel();
GWT.log("Error during upload " + resultMessage.getMessage());
break;
case UNKNOWN:
removeLoading();
//timer.cancel();
// timer.cancel();
GWT.log("Error during upload " + resultMessage.getMessage());
break;
case WARN: {
GWT.log("Upload completed with warnings "+ resultMessage.getMessage());
GWT.log("Upload completed with warnings " + resultMessage.getMessage());
removeLoading();
//timer.cancel();
// timer.cancel();
break;
}
case SESSION_EXPIRED:{
GWT.log("Upload aborted due to session expired: "+ resultMessage.getMessage());
case SESSION_EXPIRED: {
GWT.log("Upload aborted due to session expired: " + resultMessage.getMessage());
Window.alert("Session expired, please reload the page");
removeLoading();
//timer.cancel();
// timer.cancel();
break;
}
case OK: {
@ -165,20 +170,20 @@ public class MultipleDilaogUpload extends DialogUpload {
@Override
public void onChange(ChangeEvent event) {
GWT.log("file upload change handler, browse return...");
GWT.log("file upload change handler, browse returns...");
if (fileUpload.getFilename() == null || fileUpload.getFilename().isEmpty()) {
GWT.log("No file specified ");
//MultipleDilaogUpload.this.hide();
// MultipleDilaogUpload.this.hide();
return;
}
String[] files = null;
GWT.log("Current Uploader has id: "+fileUploadID);
GWT.log("Current Uploader has id: " + fileUploadID);
String filesSelected = getFilesSelected(fileUploadID, FILE_DELEMITER);
GWT.log("getFilesSelected: " + filesSelected);
files = filesSelected.split(FILE_DELEMITER);
if(isLimitExceeded(files.length))
if (isLimitExceeded(files.length))
return;
// GENERATE NEW UPLOADERS
@ -199,24 +204,19 @@ public class MultipleDilaogUpload extends DialogUpload {
}
});
}
/**
* Checks if is limit exceeded.
*
* @param numbOfFiles the numb of files
* @return true, if is limit exceeded
*/
public boolean isLimitExceeded(int numbOfFiles){
public boolean isLimitExceeded(int numbOfFiles) {
if (numbOfFiles > ConstantsMPFormBuilder.LIMIT_UPLOADS) {
Window.alert("Multiple upload limit is "
+ ConstantsMPFormBuilder.LIMIT_UPLOADS
+ " files");
//MultipleDilaogUpload.this.hide();
Window.alert("Multiple upload limit is " + ConstantsMPFormBuilder.LIMIT_UPLOADS + " files");
// MultipleDilaogUpload.this.hide();
return true;
}
@ -226,21 +226,22 @@ public class MultipleDilaogUpload extends DialogUpload {
/**
* Adds the new submit to monitor.
*/
public void addNewSubmitToMonitor(){
public void addNewSubmitToMonitor() {
GWT.log("addNewSubmitToMonitor...");
/*int queueIndex = UploaderMonitor.getInstance().newQueue();
for (final WorkspaceUploaderItem workspaceUploaderItem : fakeUploaders) {
UploaderMonitor.getInstance().addNewUploaderToMonitorPanel(workspaceUploaderItem, workspaceUploaderItem.getFile().getFileName());
setVisible(false);
removeLoading();
UploaderMonitor.getInstance().addNewUploaderToQueue(queueIndex, workspaceUploaderItem);
// UploaderMonitor.getInstance().pollWorkspaceUploader(workspaceUploaderItem);
}
UploaderMonitor.getInstance().doStartPollingQueue(queueIndex);*/
/*
* int queueIndex = UploaderMonitor.getInstance().newQueue(); for (final
* WorkspaceUploaderItem workspaceUploaderItem : fakeUploaders) {
* UploaderMonitor.getInstance().addNewUploaderToMonitorPanel(
* workspaceUploaderItem, workspaceUploaderItem.getFile().getFileName());
* setVisible(false); removeLoading();
* UploaderMonitor.getInstance().addNewUploaderToQueue(queueIndex,
* workspaceUploaderItem); //
* UploaderMonitor.getInstance().pollWorkspaceUploader(workspaceUploaderItem); }
*
* UploaderMonitor.getInstance().doStartPollingQueue(queueIndex);
*/
}
/**
* Creates the json key for files.
*
@ -257,12 +258,17 @@ public class MultipleDilaogUpload extends DialogUpload {
for (int i = 0; i < fakeUploaders.size(); i++) {
FileUploadingState file = fakeUploaders.get(i);
JSONObject obj = new JSONObject();
obj.put(file.getClientUploadKey(), new JSONString(file.getFile().getFileName()));
// JSONObject innerObj = new JSONObject();
obj.put(ConstantsMPFormBuilder.UPL_CLIENT_KEY, new JSONString(file.getClientUploadKey()));
obj.put(ConstantsMPFormBuilder.UPL_FILENAME, new JSONString(file.getFile().getFileName()));
obj.put(ConstantsMPFormBuilder.UPL_FIELD_NAME_FILEPATH, new JSONString(file.getFile().getFilePath().getFormFieldLabel()));
// obj.put(file.getClientUploadKey(), new
// JSONString(file.getFile().getFileName()));
jsonArray.set(i, obj);
}
jsonKeys = productObj.toString();
GWT.log("updated jsonKeys: "+jsonKeys);
GWT.log("updated jsonKeys: " + jsonKeys);
} catch (Exception e) {
GWT.log("error " + e.getMessage());
jsonKeys = null;
@ -305,14 +311,11 @@ public class MultipleDilaogUpload extends DialogUpload {
}-*/;
/**
* Gets the files selected.
*
* @param tagId
* the tag id
* @param fileDelimiter
* the file delimiter
* @param tagId the tag id
* @param fileDelimiter the file delimiter
* @return the files selected
*/
public static native String getFilesSelected(final String tagId, final String fileDelimiter) /*-{

View File

@ -46,7 +46,7 @@ public class CustomLegend extends Legend {
String htmlToAdd = text;
if (addIsRequiredTxt)
htmlToAdd += "<small><span style='color:red;'>&nbsp*</span> is required</small>";
htmlToAdd += "<small><span style='color:red;'>&nbsp*</span> is required field</small>";
HTML toHMTL = new HTML(htmlToAdd);

View File

@ -4,11 +4,11 @@
package org.gcube.portlets.widgets.mpformbuilder.client.ui.utils;
import org.gcube.portlets.widgets.mpformbuilder.client.ui.icons.Images;
import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
/**
* The Class LoaderIcon.
@ -19,8 +19,10 @@ import com.google.gwt.user.client.ui.Image;
public class LoaderIcon extends HorizontalPanel{
private Image imgLoading = new Image(Images.ICONS.loading());
//private Image imgLoading = new Image(Images.ICONS.loading());
private HTML txtLoading = new HTML("");
private Icon iconSpinner = new Icon(IconType.SPINNER);
/**
* Instantiates a new loader icon.
@ -37,8 +39,11 @@ public class LoaderIcon extends HorizontalPanel{
*/
public LoaderIcon() {
setStyleName("marginTop20");
add(imgLoading);
add(txtLoading);
iconSpinner.setSpin(true);
iconSpinner.getElement().getStyle().setProperty("animation", "spin 1s infinite linear");
iconSpinner.getElement().getStyle().setMarginLeft(5, Unit.PX);
add(iconSpinner);
}
/**

View File

@ -3,6 +3,13 @@
.legend-style {
width: auto;
padding: 10px;
padding-left: 10px;
margin-bottom: 0px;
border-bottom: 0px;
padding-right: 10px;
}
.legend-style small {
display: block;
font-size: 12px !important;
}

View File

@ -0,0 +1,48 @@
package org.gcube.portlets.widgets.mpformbuilder.server;
import org.gcube.portlets.widgets.mpformbuilder.client.ConstantsMPFormBuilder;
import com.fasterxml.jackson.annotation.JsonProperty;
public class JSONFileUploaded {
@JsonProperty(value = ConstantsMPFormBuilder.UPL_CLIENT_KEY)
protected String clienKey;
@JsonProperty(value = ConstantsMPFormBuilder.UPL_FILENAME)
protected String fileName;
// THIS IS THE FIELD LABEL USED IN THE WEB-FORM
// AND DECLARED IN THE FIELDNAME OF THE GCUBE METADATA PROFILE
@JsonProperty(value = ConstantsMPFormBuilder.UPL_FIELD_NAME_FILEPATH)
protected String fieldNameFilePath;
public JSONFileUploaded() {
super();
}
public String getClienKey() {
return clienKey;
}
public String getFileName() {
return fileName;
}
public String getFieldNameFilePath() {
return fieldNameFilePath;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("JSONFileUploaded [clienKey=");
builder.append(clienKey);
builder.append(", fileName=");
builder.append(fileName);
builder.append(", fieldNameFilePath=");
builder.append(fieldNameFilePath);
builder.append("]");
return builder.toString();
}
}

View File

@ -6,6 +6,8 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import javax.xml.bind.JAXBException;
@ -75,6 +77,90 @@ public class MetadataDiscovery {
}
/**
* Gets the metadata profiles list.
*
* @param scope the scope
* @param gRSecondaryType the g R secondary type
* @param resourceName the resource name
* @return the metadata profiles list
* @throws Exception the exception
*/
public static List<MetaDataProfileBean> getMetadataProfilesList(String scope, String gRSecondaryType, String resourceName)
throws Exception {
List<MetaDataProfileBean> beans = new ArrayList<MetaDataProfileBean>();
LOG.debug("Discovering into scope " + scope);
String currentContext = ScopeProvider.instance.get();
try {
ScopeProvider.instance.set(scope);
// TODO two reset methods could be added to force the reader to read again these
// information (after a while)
MetadataProfileReader reader = new MetadataProfileReader(gRSecondaryType, resourceName);
List<MetadataProfile> profiles = reader.getListOfMetadataProfiles();
prettyPrintProfiles(profiles);
LOG.info("Profiles are " + profiles.size());
List<NamespaceCategory> categories = reader.getListOfNamespaceCategories();
if (categories == null)
categories = new ArrayList<NamespaceCategory>();
LOG.debug("All Categories are " + categories);
for (MetadataProfile profile : profiles) {
LOG.debug("Wrapping profile with name " + profile.getName() + " and type " + profile.getMetadataType());
MetadataFormat metadata = reader.getMetadataFormatForMetadataProfile(profile);
MetaDataProfileBean bean = toMetaDataProfileBean(metadata, categories, profile.getName());
beans.add(bean);
// if(!WsUtil.isWithinPortal()) {
// LOG.info("DEV MODE ENABLED - Out of portal!");
// randomizeCurrentValues(bean.getMetadataFields());
// }
}
prettyPrintList(beans);
LOG.info("Returning " + beans.size() + " profile/s");
} catch (Exception e) {
LOG.error("Error while retrieving metadata beans ", e);
throw new Exception("Failed to parse Types: " + e.getMessage());
} finally {
ScopeProvider.instance.set(currentContext);
}
return beans;
}
private static void randomizeCurrentValues(List<MetadataFieldWrapper> listFields) {
LOG.info("DEV MODE ENABLED - Generationg random current value");
for (MetadataFieldWrapper metadataFieldWrapper : listFields) {
DataTypeWrapper dtw = metadataFieldWrapper.getType();
switch (dtw) {
case Boolean:
metadataFieldWrapper.setCurrentValues(Boolean.FALSE.toString());
break;
case Number:
metadataFieldWrapper.setCurrentValues(new Random().nextInt()+"");
break;
case String:
case Text:
metadataFieldWrapper.setCurrentValues("Text "+UUID.randomUUID());
break;
default:
break;
}
}
}
/**
* Gets the metadata profiles list.
*
@ -211,6 +297,7 @@ public class MetadataDiscovery {
wrapperObj.setType(DataTypeWrapper.String);
}
wrapperObj.setDefaultValue(metadataField.getDefaultValue());
wrapperObj.setFieldId(metadataField.getFieldId());
wrapperObj.setFieldName(metadataField.getFieldName());
wrapperObj.setMandatory(metadataField.getMandatory());
wrapperObj.setNote(metadataField.getNote());

View File

@ -66,6 +66,40 @@ public class MetadataProfileFormBuilderServiceImpl extends RemoteServiceServlet
return toReturn;
}
/**
* Gets the profiles in the scope.
*
* @param scope the scope
* @param genericResourceSecondaryType the generic resource secondary type
* @param resourceName the resource name
* @return the profiles in the scope
* @throws Exception the exception
*/
@Override
public List<MetaDataProfileBean> getProfilesInTheScopeForName(String scope,String genericResourceSecondaryType, String resourceName) throws Exception {
LOG.info("Called getProfilesInTheScope with parameter scope: " +scope+ ", genericResourceSecondaryType: "+genericResourceSecondaryType, "resourceName: "+resourceName);
if(genericResourceSecondaryType==null || genericResourceSecondaryType.isEmpty())
throw new Exception("The input parameter 'genericResourceSecondaryType' is not valid");
if(resourceName==null || resourceName.isEmpty())
throw new Exception("The input parameter 'resourceName' is not valid");
List<MetaDataProfileBean> toReturn = new ArrayList<MetaDataProfileBean>();
try {
String evaluatedScope = scope == null || scope.isEmpty()?ScopeProvider.instance.get():scope;
LOG.debug("Evaluated scope is " + scope);
toReturn = MetadataDiscovery.getMetadataProfilesList(evaluatedScope, genericResourceSecondaryType, resourceName);
} catch (Exception e) {
LOG.error("Failed to retrieve profiles for scope " +scope, e);
throw e;
}
return toReturn;
}
/**
* Gets the profile for metadata.
*
@ -132,7 +166,7 @@ public class MetadataProfileFormBuilderServiceImpl extends RemoteServiceServlet
/**
* Purge files uploaded in the current session
* Purge files uploaded in the current session.
*
* @return number of files deleted. Null otherwise.
* @throws Exception the exception

View File

@ -10,6 +10,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import javax.servlet.Servlet;
@ -33,6 +34,7 @@ import org.gcube.common.portal.PortalContext;
import org.gcube.portlets.widgets.mpformbuilder.client.ConstantsMPFormBuilder;
import org.gcube.portlets.widgets.mpformbuilder.server.util.WsUtil;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.AbstractUploadProgressListener;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FilePath;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadingState;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadingState.UPLOAD_STATUS;
@ -49,14 +51,16 @@ import org.json.JSONTokener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* The Class MetadataProfileBuilderUploadServlet.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it at ISTI-CNR
*
* Oct 5, 2020
* Oct 5, 2020
*/
public class MetadataProfileFormBuilderUploadServlet extends HttpServlet implements Servlet{
public class MetadataProfileFormBuilderUploadServlet extends HttpServlet implements Servlet {
/** The Constant UNKNOWN_UNKNOWN. */
public static final String UNKNOWN_UNKNOWN = "unknown/unknown";
@ -69,11 +73,12 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
/** The Constant VRE_ID_ATTR_NAME. */
public static final String VRE_ID_ATTR_NAME = "gcube-vreid";
/** The Constant CURR_GROUP_ID. */
public static final String CURR_GROUP_ID = ConstantsMPFormBuilder.CURR_GROUP_ID;
//public static final String CURR_USER_ID = ConstantsWorkspaceUploader.CURR_USER_ID;
// public static final String CURR_USER_ID =
// ConstantsWorkspaceUploader.CURR_USER_ID;
/** The Constant UPLOAD_FORM_ELEMENT. */
public static final String UPLOAD_FORM_ELEMENT = ConstantsMPFormBuilder.UPLOAD_FORM_ELEMENT;
@ -90,12 +95,18 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
/** The Constant UPLOAD_TYPE. */
public static final String UPLOAD_TYPE = ConstantsMPFormBuilder.UPLOAD_TYPE;
public static final String FIELD_NAME_FILEPATH = ConstantsMPFormBuilder.UPL_FIELD_NAME_FILEPATH;
public static final String FILENAME = ConstantsMPFormBuilder.UPL_FILENAME;
public static final String JSON_CLIENT_KEY = ConstantsMPFormBuilder.UPL_CLIENT_KEY;
/** The logger. */
public static Logger logger = LoggerFactory.getLogger(MetadataProfileFormBuilderUploadServlet.class);
/** The app engine. */
private static boolean appEngine = false;
public static final String JAVA_IO_TMPDIR = System.getProperty("java.io.tmpdir");
/**
@ -119,7 +130,7 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
appEngine = isAppEngine();
}
logger.debug("init: appEngine is "+appEngine);
logger.debug("init: appEngine is " + appEngine);
}
/**
@ -127,32 +138,32 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
*/
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
logger.debug("GET method in "+MetadataProfileFormBuilderUploadServlet.class.getName()+" is running");
logger.debug("GET method in " + MetadataProfileFormBuilderUploadServlet.class.getName() + " is running");
String clientUploadKey = request.getParameter(CLIENT_UPLOAD_KEYS);
if (clientUploadKey == null){
sendError(response, "Internal error: UPLOAD KEY NOT FOUND");
return;
}
logger.debug("GET method CLIENT_UPLOAD_KEY "+clientUploadKey);
if (clientUploadKey == null) {
sendError(response, "Internal error: UPLOAD KEY NOT FOUND");
return;
}
logger.debug("GET method CLIENT_UPLOAD_KEY " + clientUploadKey);
boolean cancelUpload = Boolean.parseBoolean(request.getParameter(CANCEL_UPLOAD));
logger.debug("GET method CANCEL_UPLOAD "+cancelUpload);
if (cancelUpload) {
boolean cancelled = cancelUpload(request.getSession(), clientUploadKey);
if(cancelled){
sendMessage(response, "Upload aborted "+clientUploadKey);
boolean cancelUpload = Boolean.parseBoolean(request.getParameter(CANCEL_UPLOAD));
logger.debug("GET method CANCEL_UPLOAD " + cancelUpload);
if (cancelUpload) {
boolean cancelled = cancelUpload(request.getSession(), clientUploadKey);
if (cancelled) {
sendMessage(response, "Upload aborted " + clientUploadKey);
// try {
//// removeCurrentListener(request.getSession(), clientUploadKey);
// WsUtil.eraseWorkspaceUploaderInSession(request.getSession(), clientUploadKey);
// }catch (Exception e) {
// logger.warn("An error occurred during removing cancelled upload from session ");
// }
}
else
sendWarnMessage(response, "Upload aborted for id: "+clientUploadKey +" has skipped, already aborted or completed?");
}else
logger.debug(CANCEL_UPLOAD + " param not found");
return;
} else
sendWarnMessage(response,
"Upload aborted for id: " + clientUploadKey + " has skipped, already aborted or completed?");
} else
logger.debug(CANCEL_UPLOAD + " param not found");
return;
}
/**
@ -160,8 +171,9 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
*/
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
logger.info("POST on UploadServlet");
boolean requestIsNull = request==null;
logger.trace("[1] HttpServletRequest is: null? "+requestIsNull+", URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
boolean requestIsNull = request == null;
logger.trace("[1] HttpServletRequest is: null? " + requestIsNull + ", URI: " + request.getRequestURI()
+ ", ServerName: " + request.getServerName());
if (!ServletFileUpload.isMultipartContent(request)) {
logger.error("ERROR: multipart request not found");
@ -172,41 +184,46 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
try {
logger.info("UPLOAD-SERVLET starting");
HttpSession session = request.getSession();
logger.info("UPLOAD-SERVLET session: "+session);
logger.debug("UPLOAD-SERVLET (" + session.getId() + ") new upload request received.");
HttpSession session = request.getSession();
logger.info("UPLOAD-SERVLET session: " + session);
logger.debug("UPLOAD-SERVLET (" + session.getId() + ") new upload request received.");
if(WsUtil.isSessionExpired(request)){
logger.error("SESSION_EXPIRED: session is expired");
sendSessionExpired(response, "SESSION_EXPIRED: session is expired");
return;
}
if (WsUtil.isSessionExpired(request)) {
logger.error("SESSION_EXPIRED: session is expired");
sendSessionExpired(response, "SESSION_EXPIRED: session is expired");
return;
}
String uploadType = null;
// String clientUploadKey = null;
String fieldName = null;
// String clientUploadKey = null;
FileItemStream uploadItem = null;
ArrayList<String> listClientUploadKeys = null;
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(request);
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload servletFileUpload = new ServletFileUpload(factory);
/**
* An iterator to instances of <code>FileItemStream</code>
* parsed from the request, in the order that they were
*transmitted.
* An iterator to instances of <code>FileItemStream</code> parsed from the
* request, in the order that they were transmitted.
*/
FileItemIterator fileItemIterator = servletFileUpload.getItemIterator(request);
int uploadItemsCnt = 0;
String scopeGroupId = "";
//GET FILE STREAM
// GET FILE STREAM
while (fileItemIterator.hasNext()) {
FileItemStream item = fileItemIterator.next();
if (item.isFormField() && UPLOAD_TYPE.equals(item.getFieldName())){
if (item.isFormField() && UPLOAD_TYPE.equals(item.getFieldName())) {
uploadType = Streams.asString(item.openStream());
logger.debug("UPLOAD_TYPE OK " +uploadType);
logger.debug(UPLOAD_TYPE + " OK " + uploadType);
}
if (item.isFormField() && FIELD_NAME_FILEPATH.equals(item.getFieldName())) {
fieldName = Streams.asString(item.openStream());
logger.debug(FIELD_NAME_FILEPATH + " OK " + fieldName);
}
// if (item.isFormField() && IS_OVERWRITE.equals(item.getFieldName())){
@ -218,24 +235,32 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
// }
// }
if(item.isFormField() && CLIENT_UPLOAD_KEYS.equals(item.getFieldName())){
if (item.isFormField() && CLIENT_UPLOAD_KEYS.equals(item.getFieldName())) {
String jsonClientUploadKey = Streams.asString(item.openStream());
logger.debug("CLIENT_UPLOAD_KEY OK "+jsonClientUploadKey);
LinkedHashMap<String, String> mapKeys = parseJSONClientUploadKeys(jsonClientUploadKey);
logger.debug(CLIENT_UPLOAD_KEYS + " OK " + jsonClientUploadKey);
LinkedHashMap<String, JSONFileUploaded> mapKeys = parseJSONClientUploadKeys(jsonClientUploadKey);
listClientUploadKeys = new ArrayList<String>(mapKeys.keySet());
removeListenersIfDone(session, listClientUploadKeys);
for (String clientUploadKey : listClientUploadKeys) {
String fileName = mapKeys.get(clientUploadKey);
FileUploadingState workspaceUploader = createNewWorkspaceUploader(clientUploadKey,fileName, user.getUsername());
logger.debug("created "+workspaceUploader);
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.WAIT, "Uploading "+fileName+" at 0%", request.getSession());
JSONFileUploaded fileUploaded = mapKeys.get(clientUploadKey);
logger.debug("Read file: " + fileUploaded);
String fileName = fileUploaded.getFileName() != null ? fileUploaded.getFileName()
: "No filename " + new Random().nextInt();
fieldName = fileUploaded.getFieldNameFilePath() != null ? fileUploaded.getFieldNameFilePath()
: fieldName;
FileUploadingState workspaceUploader = createNewWorkspaceUploader(clientUploadKey, fileName,
user.getUsername(), fieldName);
logger.debug("created " + workspaceUploader);
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.WAIT,
"Uploading " + fileName + " at 0%", request.getSession());
}
}
if (item.isFormField() && CURR_GROUP_ID.equals(item.getFieldName())){
if (item.isFormField() && CURR_GROUP_ID.equals(item.getFieldName())) {
scopeGroupId = Streams.asString(item.openStream());
logger.debug("currentGroupId passed as parameter = " + scopeGroupId);
logger.debug("currentGroupId into PortalContext scope= " + PortalContext.getConfiguration().getCurrentScope(scopeGroupId));
logger.debug("currentGroupId into PortalContext scope= "
+ PortalContext.getConfiguration().getCurrentScope(scopeGroupId));
}
// if (item.isFormField() && CURR_USER_ID.equals(item.getFieldName())){
@ -244,12 +269,13 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
// logger.debug("currUserinto PortalContext = " + PortalContext.getConfiguration().getCurrentUser(request));
// }
//MUST BE THE LAST PARAMETER TRASMITTED
if (UPLOAD_FORM_ELEMENT.equals(item.getFieldName())){
// MUST BE THE LAST PARAMETER TRASMITTED
if (UPLOAD_FORM_ELEMENT.equals(item.getFieldName())) {
uploadItem = item;
logger.debug("UPLOAD_FORM_ELEMENT OK "+uploadItem.getName() + " scopeGroupId="+scopeGroupId);
logger.debug("UPLOAD_FORM_ELEMENT OK " + uploadItem.getName() + " scopeGroupId=" + scopeGroupId);
// break;
uploadData(user, scopeGroupId, request, response, uploadItem, uploadType, listClientUploadKeys.get(uploadItemsCnt));
uploadData(user, scopeGroupId, request, response, uploadItem, uploadType,
listClientUploadKeys.get(uploadItemsCnt));
uploadItemsCnt++;
}
}
@ -265,26 +291,25 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
}
}
/**
* Removes the listener if done.
*
* @param session the session
* @param keys the keys
* @param keys the keys
*/
private void removeListenersIfDone(HttpSession session, List<String> keys){
private void removeListenersIfDone(HttpSession session, List<String> keys) {
for (String key : keys) {
AbstractUploadProgressListener listener = getCurrentListener(session, key);
if (listener != null) {
logger.debug("Listener found");
if (listener.isCanceled() || listener.getPercentage() >= 100){
logger.debug("Listener isCanceled or 100%, removing");
removeCurrentListener(session, key);
}
}else
logger.debug("Session id: "+session.getId() +" - "+key+" - Listener not found");
AbstractUploadProgressListener listener = getCurrentListener(session, key);
if (listener != null) {
logger.debug("Listener found");
if (listener.isCanceled() || listener.getPercentage() >= 100) {
logger.debug("Listener isCanceled or 100%, removing");
removeCurrentListener(session, key);
}
} else
logger.debug("Session id: " + session.getId() + " - " + key + " - Listener not found");
}
}
@ -297,156 +322,170 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
* @throws FileUploadException the file upload exception
*/
@SuppressWarnings("rawtypes")
private static LinkedHashMap<String, String> parseJSONClientUploadKeys(final String jsonClientUploadKeys) throws FileUploadException{
private static LinkedHashMap<String, JSONFileUploaded> parseJSONClientUploadKeys(final String jsonClientUploadKeys)
throws FileUploadException {
JSONTokener tokener = new JSONTokener(jsonClientUploadKeys);
JSONObject root;
LinkedHashMap<String, String> keyFiles = null;
LinkedHashMap<String, JSONFileUploaded> keyFiles = null;
try {
root = new JSONObject(tokener);
JSONArray jsonArray = root.getJSONArray(JSON_CLIENT_KEYS);
keyFiles = new LinkedHashMap<String, String>(jsonArray.length());
logger.debug("jsonArray :"+jsonArray.toString());
for (int i=0; i<jsonArray.length(); i++) {
JSONObject object = jsonArray.getJSONObject(i);
logger.debug("object :"+object);
String key = (String) object.keys().next();
String value = object.getString(key);
logger.debug("key :"+key+", value: "+value);
keyFiles.put(key, value);
keyFiles = new LinkedHashMap<String, JSONFileUploaded>(jsonArray.length());
logger.debug("jsonArray :" + jsonArray.toString());
for (int i = 0; i < jsonArray.length(); i++) {
String objectString = jsonArray.getString(i);
ObjectMapper om = new ObjectMapper();
JSONFileUploaded jfu = om.readValue(objectString, JSONFileUploaded.class);
keyFiles.put(jfu.clienKey, jfu);
/*
* JSONObject object = jsonArray.getJSONObject(i); logger.debug("object :" +
* object); String key = (String) object.keys().next(); String value =
* object.getString(key); logger.debug("key :" + key + ", value: " + value);
* keyFiles.put(key, value);
*/
}
} catch (JSONException e) {
logger.error("An error occurred during parsing file names: "+keyFiles, e);
} catch (JSONException | IOException e) {
logger.error("An error occurred during parsing file names: " + keyFiles, e);
throw new FileUploadException("An error occurred during parsing file names");
}
logger.debug("keyFiles: "+keyFiles);
logger.debug("keyFiles: " + keyFiles);
return keyFiles;
}
/**
* Upload data.
*
* @param user the user
* @param scopeGroupId the scope group id
* @param request the request
* @param response the response
* @param uploadItem the upload item
* @param uploadType the upload type
* @param user the user
* @param scopeGroupId the scope group id
* @param request the request
* @param response the response
* @param uploadItem the upload item
* @param uploadType the upload type
* @param clientUploadKey the client upload key
* @throws ServletException the servlet exception
* @throws IOException Signals that an I/O exception has occurred.
* @throws IOException Signals that an I/O exception has occurred.
*/
private void uploadData(GCubeUser user, String scopeGroupId, HttpServletRequest request, final HttpServletResponse response, final FileItemStream uploadItem, String uploadType,String clientUploadKey) throws ServletException, IOException{
private void uploadData(GCubeUser user, String scopeGroupId, HttpServletRequest request,
final HttpServletResponse response, final FileItemStream uploadItem, String uploadType,
String clientUploadKey) throws ServletException, IOException {
String fileName = uploadItem.getName();
logger.info("Upload servlet parameters: [fileName: "+fileName+ ", uploadType: "+uploadType+", clientUploadKey: "+clientUploadKey+"]");
logger.info("Upload servlet parameters: [fileName: " + fileName + ", uploadType: " + uploadType
+ ", clientUploadKey: " + clientUploadKey + "]");
if (uploadType == null || uploadType.isEmpty()) {
logger.error("Error processing request in upload servlet for: "+fileName+". No upload type found");
logger.error("Error processing request in upload servlet for: " + fileName + ". No upload type found");
sendError(response, "Internal error: No upload type found");
return;
}
if(clientUploadKey==null || clientUploadKey.isEmpty()){
logger.error("Error processing request in upload servlet for: "+fileName+". No client upload key found");
if (clientUploadKey == null || clientUploadKey.isEmpty()) {
logger.error(
"Error processing request in upload servlet for: " + fileName + ". No client upload key found");
sendError(response, "Internal error: No client upload key found");
return;
}
//CLIENT UPLOAD IS THE KEY
// CLIENT UPLOAD IS THE KEY
// WorkspaceUploaderItem workspaceUploader = createNewWorkspaceUploader(clientUploadKey,destinationId,fileName);
// saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.WAIT, "Uploading "+fileName+" at 0%", request.getSession());
//RETRIVE WORKSPACE UPLOADER FROM SESSION
// RETRIVE WORKSPACE UPLOADER FROM SESSION
FileUploadingState workspaceUploader = null;
try {
workspaceUploader = WsUtil.getWorkspaceUploaderInSession(request, clientUploadKey);
} catch (Exception e) {
logger.error("Error during workspace uploader retrieving", e);
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred during upload: "+fileName+". Error processing request in upload servlet", request.getSession());
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error processing request in upload servlet");
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED,
"An error occurred during upload: " + fileName + ". Error processing request in upload servlet",
request.getSession());
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
"Error processing request in upload servlet");
return;
}
try {
//Removing path from fileName
// Removing path from fileName
String itemName = fileName;
//Getting extension
// Getting extension
String extension = FilenameUtils.getExtension(itemName);
logger.debug("extension: "+extension);
//Getting base name
String baseName = FilenameUtils.getBaseName(itemName); //Using base name in order to avoid Task #12470
//Task #17152
extension = extension.isEmpty()?"":"."+extension;
itemName = baseName+extension;
logger.debug("purged item name is: "+itemName);
//SIZE
logger.debug("extension: " + extension);
// Getting base name
String baseName = FilenameUtils.getBaseName(itemName); // Using base name in order to avoid Task #12470
// Task #17152
extension = extension.isEmpty() ? "" : "." + extension;
itemName = baseName + extension;
logger.debug("purged item name is: " + itemName);
// SIZE
Long size = getContentLength(request);
logger.debug("size: " + size + " bytes");
//Instancing the progress listener
final AbstractUploadProgressListener uploadProgressListener = createNewListener(request.getSession(), clientUploadKey);
// Instancing the progress listener
final AbstractUploadProgressListener uploadProgressListener = createNewListener(request.getSession(),
clientUploadKey);
final UploadProgressInputStream inputStream = new UploadProgressInputStream(uploadItem.openStream(), size);
inputStream.addListener(uploadProgressListener);
workspaceUploader.setUploadProgress(uploadProgressListener.getUploadProgress());
saveWorkspaceUploaderInSession(workspaceUploader, request.getSession());
String contentType = uploadItem.getContentType();
logger.debug("Stream content type: "+contentType);
//UPLOAD FILE. IT IS DEFAULT CASE
logger.debug("Stream content type: " + contentType);
// UPLOAD FILE. IT IS DEFAULT CASE
logger.debug("Uploading file in the TEMP system folder...");
workspaceUploader = createStreamToTempFile(request, workspaceUploader, inputStream, user.getUsername(), clientUploadKey, fileName, extension);
workspaceUploader = createStreamToTempFile(request, workspaceUploader, inputStream, user.getUsername(),
clientUploadKey, fileName, extension);
saveWorkspaceUploaderInSession(workspaceUploader, request.getSession());
if(workspaceUploader==null)
if (workspaceUploader == null)
throw new Exception("Error when creating uploader, it is null!");
/*
* Incident #10095. Commented OK as response
* in order to avoid downloading of .dms file by Safari
* from MAC
* Incident #10095. Commented OK as response in order to avoid downloading of
* .dms file by Safari from MAC
*/
//sendMessage(response, workspaceUploader.getIdentifier());
} catch (IOException e){
// sendMessage(response, workspaceUploader.getIdentifier());
} catch (IOException e) {
logger.error("Error creating elements, is it cancel?", e);
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "Uploading error", request.getSession());
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "Uploading error",
request.getSession());
sendError(response, "Internal error: An item with that name already exists");
return;
// sendError(response, "Internal error: An item with that name already exists");
// return;
}catch (Exception e) {
} catch (Exception e) {
logger.error("Error creating elements", e);
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "Uploading error. "+e.getMessage(), request.getSession());
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "Uploading error. " + e.getMessage(),
request.getSession());
// sendError(response, "Internal error: An error occurred on uploading the file, try again later");
// return;
}finally{
//TODO
} finally {
// TODO
removeCurrentListener(request.getSession(), clientUploadKey);
}
}
/**
* Save workspace uploader status.
*
* @param workspaceUploader the workspace uploader
* @param status the status
* @param description the description
* @param session the session
* @param status the status
* @param description the description
* @param session the session
* @return the workspace uploader item
*/
private synchronized FileUploadingState saveWorkspaceUploaderStatus(FileUploadingState workspaceUploader, UPLOAD_STATUS status, String description, HttpSession session){
private synchronized FileUploadingState saveWorkspaceUploaderStatus(FileUploadingState workspaceUploader,
UPLOAD_STATUS status, String description, HttpSession session) {
workspaceUploader.setUploadStatus(status);
workspaceUploader.setStatusDescription(description);
try {
@ -457,20 +496,22 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
return workspaceUploader;
}
/**
* Creates the new workspace uploader.
*
* @param clientUploadKey the client upload key
* @param fileName the file name
* @param fileName the file name
* @param user the user
* @param formFieldName the form field name
* @return the workspace uploader item
*/
private FileUploadingState createNewWorkspaceUploader(String clientUploadKey, String fileName, String user){
//CLIENT UPLOAD IS THE KEY
private FileUploadingState createNewWorkspaceUploader(String clientUploadKey, String fileName, String user,
String formFieldName) {
// CLIENT UPLOAD IS THE KEY
FileUploadingState workspaceUploader = new FileUploadingState(clientUploadKey);
workspaceUploader.setClientUploadKey(clientUploadKey);
//Create File
FileUploaded wsUploadFile = new FileUploaded(fileName, null, user);
// Create File
FileUploaded wsUploadFile = new FileUploaded(fileName, null, user, new FilePath(formFieldName));
workspaceUploader.setFile(wsUploadFile);
return workspaceUploader;
}
@ -479,39 +520,43 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
* Save workspace uploader in session.
*
* @param workspaceUploader the workspace uploader
* @param httpSession the http session
* @param httpSession the http session
* @return the workspace uploader item
* @throws Exception the exception
*/
public static void saveWorkspaceUploaderInSession(FileUploadingState workspaceUploader, HttpSession httpSession) throws Exception {
public static void saveWorkspaceUploaderInSession(FileUploadingState workspaceUploader, HttpSession httpSession)
throws Exception {
if(workspaceUploader!=null){
if (workspaceUploader != null) {
try {
WsUtil.putWorkspaceUploaderInSession(httpSession, workspaceUploader);
} catch (Exception e) {
logger.error("Error during WorkspaceUploaderItem save in session workspace uploader: "+workspaceUploader,e);
logger.error(
"Error during WorkspaceUploaderItem save in session workspace uploader: " + workspaceUploader,
e);
throw new Exception("An error occurred in the upload. Try again");
}
}else
} else
throw new Exception("An error occurred in the upload. Workspace Uploader not found. Abort and try again");
}
/**
* Creates the stream to temp file.
* @param request
*
* @param request the request
* @param workspaceUploader the workspace uploader
* @param in the in
* @param username the username
* @param clientUploadKey the client upload key
* @param fileName the file name
* @param fileExtension the file extension
* @param in the in
* @param username the username
* @param clientUploadKey the client upload key
* @param fileName the file name
* @param fileExtension the file extension
* @return the workspace uploader item
* @throws IOException Signals that an I/O exception has occurred.
*/
public FileUploadingState createStreamToTempFile(HttpServletRequest request, FileUploadingState workspaceUploader, InputStream in, String username, String clientUploadKey, String fileName, String fileExtension) throws IOException{
public FileUploadingState createStreamToTempFile(HttpServletRequest request, FileUploadingState workspaceUploader,
InputStream in, String username, String clientUploadKey, String fileName, String fileExtension)
throws IOException {
if (fileExtension == null)
fileExtension = "";
if (username == null)
@ -523,8 +568,8 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
String uniqueFileName = String.format("%s_%s", clientUploadKey, fileName);
File tempFile = File.createTempFile(uniqueFileName, fileExtension);
tempFile.deleteOnExit();
//File tempFile = File.createTempFile(uniqueFileName, fileExtension);
//File tempFile = tempFilePath.toFile();
// File tempFile = File.createTempFile(uniqueFileName, fileExtension);
// File tempFile = tempFilePath.toFile();
FileOutputStream out = new FileOutputStream(tempFile);
IOUtils.copy(in, out);
workspaceUploader.getFile().setTempSystemPath(tempFile.getAbsolutePath());
@ -532,110 +577,112 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
workspaceUploader.setUploadStatus(UPLOAD_STATUS.COMPLETED);
saveWorkspaceUploaderInSession(workspaceUploader, request.getSession());
saveFileUplodedInSession(workspaceUploader.getFile(), request.getSession());
logger.info("File uploaded at: "+tempFile.getAbsolutePath());
}catch (Exception e) {
workspaceUploader.setStatusDescription("Error on uploading: "+fileName+". "+e.getMessage());
logger.info("File uploaded at: " + tempFile.getAbsolutePath());
} catch (Exception e) {
workspaceUploader.setStatusDescription("Error on uploading: " + fileName + ". " + e.getMessage());
workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED);
}finally {
} finally {
try {
WsUtil.setErasableWorkspaceUploaderInSession(request, workspaceUploader.getIdentifier());
} catch (Exception e2) {
logger.error("Error during setErasableWorkspaceUploaderInSession session update: ",e2);
logger.error("Error during setErasableWorkspaceUploaderInSession session update: ", e2);
}
}
return workspaceUploader;
}
/**
* Save file uploded in session.
*
* @param fileUploaded the file uploaded
* @param httpSession the http session
* @param httpSession the http session
*/
private void saveFileUplodedInSession(FileUploaded fileUploaded, HttpSession httpSession) {
if(fileUploaded!=null){
List<FileUploaded> listFiles = (List<FileUploaded>) httpSession.getAttribute(ConstantsMPFormBuilder.FILE_UPLOADED_SESSION_ATTR);
if(listFiles==null)
if (fileUploaded != null) {
List<FileUploaded> listFiles = (List<FileUploaded>) httpSession
.getAttribute(ConstantsMPFormBuilder.FILE_UPLOADED_SESSION_ATTR);
if (listFiles == null)
listFiles = new ArrayList<FileUploaded>();
listFiles.add(fileUploaded);
httpSession.setAttribute(ConstantsMPFormBuilder.FILE_UPLOADED_SESSION_ATTR, listFiles);
logger.info("Added: "+fileUploaded +" in session");
logger.info("Added: " + fileUploaded + " in session");
}
}
//TEST TIME
// TEST TIME
/**
* Prints the start time.
*
* @return the long
*/
public static Long printStartTime(){
Long startTime = System.currentTimeMillis();
logger.debug("Start time: "+startTime);
public static Long printStartTime() {
Long startTime = System.currentTimeMillis();
logger.debug("Start time: " + startTime);
return startTime;
}
//TEST TIME
// TEST TIME
/**
* Prints the elapsed time.
*
* @param startTime the start time
*/
public static void printElapsedTime(long startTime){
public static void printElapsedTime(long startTime) {
Long endTime = System.currentTimeMillis() - startTime;
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
logger.debug("Elapsed Time: "+time);
logger.debug("Elapsed Time: " + time);
}
/**
* Send error.
*
* @param response the response
* @param message the message
* @param message the message
* @throws IOException Signals that an I/O exception has occurred.
*/
protected void sendError(HttpServletResponse response, String message) throws IOException{
protected void sendError(HttpServletResponse response, String message) throws IOException {
try {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
HandlerResultMessage resultMessage = HandlerResultMessage.errorResult(message);
response.getWriter().write(resultMessage.toString());
//5.6 Closure of Response Object:
//When a response is closed, the container must immediately flush all remaining content in the response buffer to the client
// 5.6 Closure of Response Object:
// When a response is closed, the container must immediately flush all remaining
// content in the response buffer to the client
// response.flushBuffer();
} catch (IOException e){
logger.warn("IOException class name: "+e.getClass().getSimpleName());
} catch (IOException e) {
logger.warn("IOException class name: " + e.getClass().getSimpleName());
if (e.getClass().getSimpleName().equals("ClientAbortException"))
logger.warn("Skipping ClientAbortException: "+e.getMessage());
logger.warn("Skipping ClientAbortException: " + e.getMessage());
else
throw e; //Sending Exceptions
throw e; // Sending Exceptions
}
}
/**
* Send session expired.
*
* @param response the response
* @param message the message
* @param message the message
* @throws IOException Signals that an I/O exception has occurred.
*/
protected void sendSessionExpired(HttpServletResponse response, String message) throws IOException{
protected void sendSessionExpired(HttpServletResponse response, String message) throws IOException {
try {
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
HandlerResultMessage resultMessage = HandlerResultMessage.sessionExpiredResult(message);
response.getWriter().write(resultMessage.toString());
//5.6 Closure of Response Object:
//When a response is closed, the container must immediately flush all remaining content in the response buffer to the client
// 5.6 Closure of Response Object:
// When a response is closed, the container must immediately flush all remaining
// content in the response buffer to the client
// response.flushBuffer();
} catch (IOException e){
logger.warn("IOException class name: "+e.getClass().getSimpleName());
} catch (IOException e) {
logger.warn("IOException class name: " + e.getClass().getSimpleName());
if (e.getClass().getSimpleName().equals("ClientAbortException"))
logger.warn("Skipping ClientAbortException: "+e.getMessage());
logger.warn("Skipping ClientAbortException: " + e.getMessage());
else
throw e; //Sending Exceptions
throw e; // Sending Exceptions
}
}
@ -643,24 +690,25 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
* Send message.
*
* @param response the response
* @param message the message
* @param message the message
* @throws IOException Signals that an I/O exception has occurred.
*/
protected void sendMessage(HttpServletResponse response, String message) throws IOException{
protected void sendMessage(HttpServletResponse response, String message) throws IOException {
try {
response.setStatus(HttpServletResponse.SC_ACCEPTED);
message = message.replaceAll(":", "");
HandlerResultMessage resultMessage = HandlerResultMessage.okResult(message);
response.getWriter().write(resultMessage.toString());
//5.6 Closure of Response Object:
//When a response is closed, the container must immediately flush all remaining content in the response buffer to the client
// 5.6 Closure of Response Object:
// When a response is closed, the container must immediately flush all remaining
// content in the response buffer to the client
// response.flushBuffer();
} catch (IOException e){
logger.warn("IOException class name: "+e.getClass().getSimpleName());
} catch (IOException e) {
logger.warn("IOException class name: " + e.getClass().getSimpleName());
if (e.getClass().getSimpleName().equals("ClientAbortException"))
logger.warn("Skipping ClientAbortException: "+e.getMessage());
logger.warn("Skipping ClientAbortException: " + e.getMessage());
else
throw e; //Sending Exceptions
throw e; // Sending Exceptions
}
}
@ -668,41 +716,42 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
* Send warn message.
*
* @param response the response
* @param message the message
* @param message the message
* @throws IOException Signals that an I/O exception has occurred.
*/
protected void sendWarnMessage(HttpServletResponse response, String message) throws IOException{
protected void sendWarnMessage(HttpServletResponse response, String message) throws IOException {
try {
response.setStatus(HttpServletResponse.SC_ACCEPTED);
HandlerResultMessage resultMessage = HandlerResultMessage.warnResult(message);
response.getWriter().write(resultMessage.toString());
//5.6 Closure of Response Object:
//When a response is closed, the container must immediately flush all remaining content in the response buffer to the client
// 5.6 Closure of Response Object:
// When a response is closed, the container must immediately flush all remaining
// content in the response buffer to the client
// response.flushBuffer();
} catch (IOException e){
logger.warn("IOException class name: "+e.getClass().getSimpleName());
} catch (IOException e) {
logger.warn("IOException class name: " + e.getClass().getSimpleName());
if (e.getClass().getSimpleName().equals("ClientAbortException"))
logger.warn("Skipping ClientAbortException: "+e.getMessage());
logger.warn("Skipping ClientAbortException: " + e.getMessage());
else
throw e; //Sending Exceptions
throw e; // Sending Exceptions
}
}
/**
* Mark the current upload process to be canceled.
*
* @param session the session
* @param session the session
* @param clientUploadKey the client upload key
* @return true, if successful
*/
public boolean cancelUpload(HttpSession session, String clientUploadKey) {
logger.debug("UPLOAD-SERVLET (" + session.getId()+ ") cancelling Upload: "+clientUploadKey);
logger.debug("UPLOAD-SERVLET (" + session.getId() + ") cancelling Upload: " + clientUploadKey);
AbstractUploadProgressListener listener = getCurrentListener(session, clientUploadKey);
if (listener != null && !listener.isCanceled()) {
logger.info("CancelUpload listener is "+listener.toString());
logger.info("CancelUpload listener is " + listener.toString());
listener.setException(new UploadCanceledException());
return true;
}else{
} else {
logger.info("Skipping cancel upload: listener is null or is cancel");
return false;
}
@ -711,7 +760,7 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
/**
* Get the listener active in this session.
*
* @param session the session
* @param session the session
* @param clientUploadKey the client upload key
* @return the listener active
*/
@ -724,8 +773,8 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
}
/**
* Just a method to detect whether the web container is running with
* appengine restrictions.
* Just a method to detect whether the web container is running with appengine
* restrictions.
*
* @return true if the case of the application is running in appengine
*/
@ -736,7 +785,7 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
/**
* Create a new listener for this session.
*
* @param session the session
* @param session the session
* @param clientUploadKey the client upload key
* @return the appropriate listener
*/
@ -748,7 +797,6 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
}
}
/**
* Gets the content length.
*
@ -758,8 +806,7 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
private long getContentLength(HttpServletRequest request) {
long size = -1;
try {
size = Long.parseLong(request
.getHeader(FileUploadBase.CONTENT_LENGTH));
size = Long.parseLong(request.getHeader(FileUploadBase.CONTENT_LENGTH));
} catch (NumberFormatException e) {
}
return size;
@ -768,17 +815,17 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme
/**
* Remove the listener active in this session.
*
* @param session the session
* @param session the session
* @param clientUploadKey the client upload key
*/
protected void removeCurrentListener(HttpSession session, String clientUploadKey) {
logger.debug("RemoveCurrentListener: "+clientUploadKey);
logger.debug("RemoveCurrentListener: " + clientUploadKey);
AbstractUploadProgressListener listener = getCurrentListener(session, clientUploadKey);
if (listener != null) {
logger.debug("Removing listener: "+listener.getClientUploadKey());
logger.debug("Removing listener: " + listener.getClientUploadKey());
listener.remove();
}else
logger.warn("Listener "+clientUploadKey+ "is null");
} else
logger.warn("Listener " + clientUploadKey + "is null");
}
}

View File

@ -1,118 +1,108 @@
package org.gcube.portlets.widgets.mpformbuilder.shared;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
/**
* The Class GenericDatasetBean.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 19, 2020
* Oct 19, 2020
*/
public class GenericDatasetBean implements Serializable {
public class GenericDatasetBean<T extends MetaDataProfileBean, F extends FileUploaded> implements Serializable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -5215392381589702647L;
/** The metadata profile list. */
private List<MetaDataProfileBean> metadataProfileList;
private List<T> metadataProfileList;
/** The form data entry fields. */
private Map<String, List<String>> formDataEntryFields;
private LinkedHashMap<String, List<String>> formDataEntryFields;
/** The files uploaded. */
private List<FileUploaded> filesUploaded;
private List<F> filesUploaded;
/**
* Instantiates a new generic dataset bean.
*/
public GenericDatasetBean(){
public GenericDatasetBean() {
}
/**
* Instantiates a new generic dataset bean.
*
* @param metadataProfileList the metadata profile list
* @param formDataEntryFields the form data entry fields
* @param filesUploaded the files uploaded
* @param filesUploaded the files uploaded
*/
public GenericDatasetBean(List<MetaDataProfileBean> metadataProfileList, Map<String, List<String>> formDataEntryFields,
List<FileUploaded> filesUploaded) {
public GenericDatasetBean(List<T> metadataProfileList, LinkedHashMap<String, List<String>> formDataEntryFields,
List<F> filesUploaded) {
super();
this.metadataProfileList = metadataProfileList;
this.formDataEntryFields = formDataEntryFields;
this.filesUploaded = filesUploaded;
}
/**
* Gets the metadata profile list.
*
* @return the metadata profile list
*/
public List<MetaDataProfileBean> getMetadataProfileList() {
public List<T> getMetadataProfileList() {
return metadataProfileList;
}
/**
* Sets the metadata profile list.
*
* @param metadataProfileList the new metadata profile list
*/
public void setMetadataProfileList(List<MetaDataProfileBean> metadataProfileList) {
public void setMetadataProfileList(List<T> metadataProfileList) {
this.metadataProfileList = metadataProfileList;
}
/**
* Gets the form data entry fields.
*
* @return the form data entry fields
*/
public Map<String, List<String>> getFormDataEntryFields() {
public LinkedHashMap<String, List<String>> getFormDataEntryFields() {
return formDataEntryFields;
}
/**
* Sets the form data entry fields.
*
* @param formDataEntryFields the form data entry fields
*/
public void setFormDataEntryFields(Map<String, List<String>> formDataEntryFields) {
public void setFormDataEntryFields(LinkedHashMap<String, List<String>> formDataEntryFields) {
this.formDataEntryFields = formDataEntryFields;
}
/**
* Gets the files uploaded.
*
* @return the files uploaded
*/
public List<FileUploaded> getFilesUploaded() {
public List<F> getFilesUploaded() {
return filesUploaded;
}
/**
* Sets the files uploaded.
*
* @param filesUploaded the new files uploaded
*/
public void setFilesUploaded(List<FileUploaded> filesUploaded) {
public void setFilesUploaded(List<F> filesUploaded) {
this.filesUploaded = filesUploaded;
}
/**
* To string.
*
@ -124,6 +114,4 @@ public class GenericDatasetBean implements Serializable {
+ formDataEntryFields + ", filesUploaded=" + filesUploaded + "]";
}
}

View File

@ -1,335 +0,0 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.catalogue;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
/**
* This bean will contain during ckan metadata creation information related to the future build.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
@SuppressWarnings("serial")
public class DatasetBean implements Serializable {
private String id;
private String title;
private String description;
private String license; // chosen by the user
private String source; // url of the folder in the workspace
private String authorName; // author name
private String authorSurname; // author surname
private String authorFullName;
private String authorEmail; // owner's email
private String maintainer;
private String maintainerEmail;
private String ownerIdentifier; // owner of the folder into the workspace (e.g., andrea.rossi)
private String chosenType; // the name of the MetaDataType chosen
private String selectedOrganization;
private long version; // version 1, 2 ...
private boolean visible; // Private (false) or Public(true)
private List<OrganizationBean> organizationList; // list of organization in which the user is present and could create the dataset
private ResourceElementBean resourceRoot; // in case of workspace, this is the directory root or the single file information
private List<MetaDataProfileBean> metadataList;
private List<String> tags; // on retrieve, they are the keys of the product
private List<String> tagsVocabulary; // when available
private Map<String, List<String>> customFields;
private List<OrganizationBean> groups;
private List<OrganizationBean> groupsForceCreation;
public DatasetBean(){
super();
}
/** Create a metadata bean object.
* @param id
* @param title
* @param description
* @param customFields
* @param tags
* @param license
* @param visibility
* @param source
* @param version
* @param author
* @param authorEmail
* @param maintainer
* @param maintainerEmail
* @param ownerIdentifier
* @param organizationList
* @param selectedOrganization
* @param resourcesIds
* @param addResources
* @param metadataList
*/
public DatasetBean(String id, String title, String description,
Map<String, List<String>> customFields, List<String> tags,
String license, boolean visible, String source, long version,
String authorName, String authorSurname, String authorEmail, String maintainer,
String maintainerEmail, String ownerIdentifier,
List<OrganizationBean> organizationList, String selectedOrganization,
ResourceElementBean resourceRoot,
List<MetaDataProfileBean> metadataList, List<OrganizationBean> groups, List<String> tagsVocabulary) {
super();
this.id = id;
this.title = title;
this.description = description;
this.customFields = customFields;
this.tags = tags;
this.license = license;
this.visible = visible;
this.source = source;
this.version = version;
this.authorName = authorName;
this.authorSurname = authorSurname;
this.authorEmail = authorEmail;
this.maintainer = maintainer;
this.maintainerEmail = maintainerEmail;
this.ownerIdentifier = ownerIdentifier;
this.organizationList = organizationList;
this.selectedOrganization = selectedOrganization;
this.resourceRoot = resourceRoot;
this.metadataList = metadataList;
this.groups = groups;
this.tagsVocabulary = tagsVocabulary;
}
public String getChosenType() {
return chosenType;
}
public void setChosenType(String chosenType) {
this.chosenType = chosenType;
}
public List<MetaDataProfileBean> getMetadataList() {
return metadataList;
}
public void setMetadataList(List<MetaDataProfileBean> metadataListTypes) {
this.metadataList = metadataListTypes;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getOwnerIdentifier() {
return ownerIdentifier;
}
public void setOwnerIdentifier(String ownerIdentifier) {
this.ownerIdentifier = ownerIdentifier;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Map<String, List<String>> getCustomFields() {
return customFields;
}
public void setCustomFields(Map<String, List<String>> customFields) {
this.customFields = customFields;
}
public List<String> getTags() {
return tags;
}
public void setTags(List<String> tags) {
this.tags = tags;
}
public String getLicense() {
return license;
}
public void setLicense(String license) {
this.license = license;
}
public boolean getVisibility() {
return visible;
}
public void setVisibile(boolean visibile) {
this.visible = visibile;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public long getVersion() {
return version;
}
public void setVersion(long version) {
this.version = version;
}
public String getAuthorName() {
return authorName;
}
public void setAuthorName(String authorName) {
this.authorName = authorName;
}
public String getAuthorSurname() {
return authorSurname;
}
public void setAuthorSurname(String authorSurname) {
this.authorSurname = authorSurname;
}
public String getAuthorEmail() {
return authorEmail;
}
public void setAuthorEmail(String authorEmail) {
this.authorEmail = authorEmail;
}
public String getMaintainer() {
return maintainer;
}
public void setMaintainer(String maintainer) {
this.maintainer = maintainer;
}
public String getMaintainerEmail() {
return maintainerEmail;
}
public void setMaintainerEmail(String maintainerEmail) {
this.maintainerEmail = maintainerEmail;
}
public List<OrganizationBean> getOrganizationList() {
return organizationList;
}
public void setOrganizationList(List<OrganizationBean> organizationList) {
this.organizationList = organizationList;
}
public String getSelectedOrganization() {
return selectedOrganization;
}
public void setSelectedOrganization(String selectedOrganization) {
this.selectedOrganization = selectedOrganization;
}
public ResourceElementBean getResourceRoot() {
return resourceRoot;
}
public void setResourceRoot(ResourceElementBean resourceRoot) {
this.resourceRoot = resourceRoot;
}
public String getAuthorFullName() {
return authorFullName;
}
public void setAuthorFullName(String authorFullName) {
this.authorFullName = authorFullName;
}
public List<OrganizationBean> getGroups() {
return groups;
}
public void setGroups(List<OrganizationBean> groups) {
this.groups = groups;
}
public List<String> getTagsVocabulary() {
return tagsVocabulary;
}
public void setTagsVocabulary(List<String> tagsVocabulary) {
this.tagsVocabulary = tagsVocabulary;
}
public List<OrganizationBean> getGroupsForceCreation() {
return groupsForceCreation;
}
public void setGroupsForceCreation(List<OrganizationBean> groupsForceCreation) {
this.groupsForceCreation = groupsForceCreation;
}
@Override
public String toString() {
return "DatasetBean ["
+ (id != null ? "id=" + id + ", " : "")
+ (title != null ? "title=" + title + ", " : "")
+ (description != null ? "description=" + description + ", "
: "")
+ (license != null ? "license=" + license + ", " : "")
+ (source != null ? "source=" + source + ", " : "")
+ (authorName != null ? "authorName=" + authorName + ", " : "")
+ (authorSurname != null ? "authorSurname=" + authorSurname
+ ", " : "")
+ (authorFullName != null ? "authorFullName=" + authorFullName
+ ", " : "")
+ (authorEmail != null ? "authorEmail=" + authorEmail + ", "
: "")
+ (maintainer != null ? "maintainer=" + maintainer + ", " : "")
+ (maintainerEmail != null ? "maintainerEmail="
+ maintainerEmail + ", " : "")
+ (ownerIdentifier != null ? "ownerIdentifier="
+ ownerIdentifier + ", " : "")
+ (chosenType != null ? "chosenType=" + chosenType + ", " : "")
+ (selectedOrganization != null ? "selectedOrganization="
+ selectedOrganization + ", " : "")
+ "version="
+ version
+ ", visible="
+ visible
+ ", "
+ (organizationList != null ? "organizationList="
+ organizationList + ", " : "")
+ (resourceRoot != null ? "resourceRoot=" + resourceRoot + ", "
: "")
+ (metadataList != null ? "metadataList=" + metadataList + ", "
: "")
+ (tags != null ? "tags=" + tags + ", " : "")
+ (tagsVocabulary != null ? "tagsVocabulary=" + tagsVocabulary
+ ", " : "")
+ (customFields != null ? "customFields=" + customFields + ", "
: "")
+ (groups != null ? "groups=" + groups + ", " : "")
+ (groupsForceCreation != null ? "groupsForceCreation="
+ groupsForceCreation : "") + "]";
}
}

View File

@ -1,75 +0,0 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.catalogue;
import java.io.Serializable;
/**
* A ckan organization/group (you can check its nature by looking at getIsOrganization();) like bean with name and title
* @author Costantino Perciante (costantino.perciante@isti.cnr.it)
*/
public class OrganizationBean implements Serializable{
private static final long serialVersionUID = -6566519399945530602L;
private String title;
private String name;
private boolean isOrganization;
private boolean propagateUp; // an item linked to this group has to be added on the whole hierarchy chain
public OrganizationBean(){
super();
}
public OrganizationBean(String title, String name, boolean isOrganization) {
super();
this.title = title;
this.name = name;
this.isOrganization = isOrganization;
}
public OrganizationBean(String title, String name, boolean isOrganization, boolean propagateUp) {
super();
this.title = title;
this.name = name;
this.isOrganization = isOrganization;
this.propagateUp = propagateUp;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isOrganization() {
return isOrganization;
}
public void setOrganization(boolean isOrganization) {
this.isOrganization = isOrganization;
}
public boolean isPropagateUp() {
return propagateUp;
}
public void setPropagateUp(boolean propagateUp) {
this.propagateUp = propagateUp;
}
@Override
public String toString() {
return "OrganizationBean [title=" + title + ", name=" + name
+ ", isOrganization=" + isOrganization + ", propagateUp="
+ propagateUp + "]";
}
}

View File

@ -0,0 +1,146 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.catalogue;
import java.io.Serializable;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* The Class OrganizationBeanProfile.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Feb 15, 2024
*/
public class OrganizationBeanProfile implements Serializable, IsSerializable {
/**
*
*/
private static final long serialVersionUID = -2078766102599662775L;
private String title;
private String name;
private boolean isOrganization;
private boolean propagateUp; // an item linked to this group has to be added on the whole hierarchy chain
/**
* Instantiates a new organization bean profile.
*/
public OrganizationBeanProfile() {
}
/**
* Instantiates a new organization bean profile.
*
* @param title the title
* @param name the name
* @param isOrganization the is organization
*/
public OrganizationBeanProfile(String title, String name, boolean isOrganization) {
this.title = title;
this.name = name;
this.isOrganization = isOrganization;
}
/**
* Instantiates a new organization bean profile.
*
* @param title the title
* @param name the name
* @param isOrganization the is organization
* @param propagateUp the propagate up
*/
public OrganizationBeanProfile(String title, String name, boolean isOrganization, boolean propagateUp) {
this.title = title;
this.name = name;
this.isOrganization = isOrganization;
this.propagateUp = propagateUp;
}
/**
* Gets the title.
*
* @return the title
*/
public String getTitle() {
return title;
}
/**
* Sets the title.
*
* @param title the new title
*/
public void setTitle(String title) {
this.title = title;
}
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Sets the name.
*
* @param name the new name
*/
public void setName(String name) {
this.name = name;
}
/**
* Checks if is organization.
*
* @return true, if is organization
*/
public boolean isOrganization() {
return isOrganization;
}
/**
* Sets the organization.
*
* @param isOrganization the new organization
*/
public void setOrganization(boolean isOrganization) {
this.isOrganization = isOrganization;
}
/**
* Checks if is propagate up.
*
* @return true, if is propagate up
*/
public boolean isPropagateUp() {
return propagateUp;
}
/**
* Sets the propagate up.
*
* @param propagateUp the new propagate up
*/
public void setPropagateUp(boolean propagateUp) {
this.propagateUp = propagateUp;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("OrganizationBeanProfile [title=");
builder.append(title);
builder.append(", name=");
builder.append(name);
builder.append(", isOrganization=");
builder.append(isOrganization);
builder.append(", propagateUp=");
builder.append(propagateUp);
builder.append("]");
return builder.toString();
}
}

View File

@ -3,14 +3,15 @@ package org.gcube.portlets.widgets.mpformbuilder.shared.catalogue;
import java.io.Serializable;
import java.util.List;
import com.google.gwt.view.client.ProvidesKey;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* A resource element bean. Contains part of the logic used into the TwinColumn widget
* A resource element bean. Contains part of the logic used into the TwinColumn
* widget
*
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class ResourceElementBean implements Comparable<ResourceElementBean>, Serializable{
public class ResourceElementBeanProfile implements Serializable, IsSerializable {
private static final long serialVersionUID = -1230871392599580669L;
private String name;
@ -23,30 +24,21 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
private String url;
private String description;
private String organizationNameDatasetParent; // the organization name in which the parent dataset was created
private ResourceElementBean parent;
private List<ResourceElementBean> children;
// to generate the GWT identifiers
private static int nextId = 0;
// identifier of this instance
private int identifierGWT;
private ResourceElementBeanProfile parent;
private List<ResourceElementBeanProfile> children;
/**
* The key provider that provides the unique ID of a bean.
* Default constructor
*/
public static final ProvidesKey<ResourceElementBean> KEY_PROVIDER = new ProvidesKey<ResourceElementBean>() {
@Override
public Object getKey(ResourceElementBean item) {
return item == null ? null : item.identifierGWT;
}
};
public ResourceElementBeanProfile() {
}
/**
* Copy constructor
*
* @param another
*/
public ResourceElementBean(ResourceElementBean another) {
public ResourceElementBeanProfile(ResourceElementBeanProfile another) {
this.name = another.name;
this.toBeAdded = another.toBeAdded;
this.fullPath = another.fullPath;
@ -58,15 +50,6 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
this.organizationNameDatasetParent = another.organizationNameDatasetParent;
}
/**
* Default constructor
*/
public ResourceElementBean(){
super();
this.identifierGWT = nextId;
nextId++;
}
/**
* @param identifier
* @param parentFolder
@ -74,14 +57,8 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
* @param movedToRight
* @param isFolder
*/
public ResourceElementBean(
ResourceElementBean parent,
String name,
boolean isFolder,
List<ResourceElementBean> children,
String fullPath) {
this.identifierGWT = nextId;
nextId++;
public ResourceElementBeanProfile(ResourceElementBeanProfile parent, String name, boolean isFolder,
List<ResourceElementBeanProfile> children, String fullPath) {
this.parent = parent;
this.name = name;
this.isFolder = isFolder;
@ -102,14 +79,11 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
* @param description
* @param organizationNameDatasetParent
*/
public ResourceElementBean(String name, boolean toBeAdded,
boolean isFolder, ResourceElementBean parent,
List<ResourceElementBean> children, String fullPath,
String originalIdInWorkspace, String mimeType, String url,
String description, String organizationNameDatasetParent) {
public ResourceElementBeanProfile(String name, boolean toBeAdded, boolean isFolder,
ResourceElementBeanProfile parent, List<ResourceElementBeanProfile> children, String fullPath,
String originalIdInWorkspace, String mimeType, String url, String description,
String organizationNameDatasetParent) {
super();
this.identifierGWT = nextId;
nextId++;
this.name = name;
this.toBeAdded = toBeAdded;
this.isFolder = isFolder;
@ -123,11 +97,11 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
this.organizationNameDatasetParent = organizationNameDatasetParent;
}
public ResourceElementBean getParent() {
public ResourceElementBeanProfile getParent() {
return parent;
}
public void setParent(ResourceElementBean parent) {
public void setParent(ResourceElementBeanProfile parent) {
this.parent = parent;
}
@ -175,8 +149,7 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
return organizationNameDatasetParent;
}
public void setOrganizationNameDatasetParent(
String organizationNameDatasetParent) {
public void setOrganizationNameDatasetParent(String organizationNameDatasetParent) {
this.organizationNameDatasetParent = organizationNameDatasetParent;
}
@ -188,11 +161,11 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
this.isFolder = isFolder;
}
public List<ResourceElementBean> getChildren() {
public List<ResourceElementBeanProfile> getChildren() {
return children;
}
public void setChildren(List<ResourceElementBean> children) {
public void setChildren(List<ResourceElementBeanProfile> children) {
this.children = children;
}
@ -220,33 +193,35 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
this.editableName = newName;
}
@Override
public boolean equals(Object o) {
boolean toReturn = false;
if (o instanceof ResourceElementBean) {
toReturn = identifierGWT == ((ResourceElementBean) o).identifierGWT;
}
return toReturn;
}
@Override
public int compareTo(ResourceElementBean o) {
int toReturn = (o == null || o.fullPath == null) ? -1 : -o.fullPath.compareTo(fullPath);
return toReturn;
}
@Override
public String toString() {
return "ResourceElementBean [identifierGWT=" + identifierGWT
+ ", name=" + name + ", editableName=" + editableName
+ ", toBeAdded=" + toBeAdded + ", isFolder=" + isFolder
+ ", fullPath=" + fullPath + ", originalIdInWorkspace="
+ originalIdInWorkspace + ", mimeType=" + mimeType + ", url="
+ url + ", description=" + description
+ ", organizationNameDatasetParent="
+ organizationNameDatasetParent + ", parent=" + parent
+ ", children number=" + (children == null ? 0 : children.size()) + "]";
StringBuilder builder = new StringBuilder();
builder.append("ResourceElementBeanProfile [name=");
builder.append(name);
builder.append(", editableName=");
builder.append(editableName);
builder.append(", toBeAdded=");
builder.append(toBeAdded);
builder.append(", isFolder=");
builder.append(isFolder);
builder.append(", fullPath=");
builder.append(fullPath);
builder.append(", originalIdInWorkspace=");
builder.append(originalIdInWorkspace);
builder.append(", mimeType=");
builder.append(mimeType);
builder.append(", url=");
builder.append(url);
builder.append(", description=");
builder.append(description);
builder.append(", organizationNameDatasetParent=");
builder.append(organizationNameDatasetParent);
builder.append(", parent=");
builder.append(parent);
builder.append(", children=");
builder.append(children);
builder.append("]");
return builder.toString();
}
}

View File

@ -51,6 +51,11 @@ public class CategoryWrapper implements Serializable{
this.description = description;
}
/**
* NB!!! DOES NOT USE THIS IN UPTATE/EDIT MODE.
*
* @return the fields for this category
*/
public List<MetadataFieldWrapper> getFieldsForThisCategory() {
return fieldsForThisCategory;
}

View File

@ -4,24 +4,39 @@ import java.io.Serializable;
import java.util.List;
/**
* A MetaDataProfileBean with its children (MetaDataType, MetaDataFields, Categories)
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
* The Class MetaDataProfileBean.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Mar 3, 2022
*/
public class MetaDataProfileBean implements Serializable{
private static final long serialVersionUID = -7377022025375553568L;
public class MetaDataProfileBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = -8307518917648131477L;
private String type;
private String title;
private List<CategoryWrapper> categories;
private List<MetadataFieldWrapper> metadataFields;
public MetaDataProfileBean(){
/**
* Instantiates a new meta data profile bean.
*/
public MetaDataProfileBean() {
super();
}
public MetaDataProfileBean(String type,
String title,
List<MetadataFieldWrapper> metadataFields,
/**
* Instantiates a new meta data profile bean.
*
* @param type the type
* @param title the title
* @param metadataFields the metadata fields
* @param categories the categories
*/
public MetaDataProfileBean(String type, String title, List<MetadataFieldWrapper> metadataFields,
List<CategoryWrapper> categories) {
super();
this.type = type;
@ -30,57 +45,51 @@ public class MetaDataProfileBean implements Serializable{
this.metadataFields = metadataFields;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return the metadataFields
*/
public List<MetadataFieldWrapper> getMetadataFields() {
return metadataFields;
}
/**
* @param metadataFields the metadataFields to set
*/
public void setMetadataFields(List<MetadataFieldWrapper> metadataFields) {
this.metadataFields = metadataFields;
public String getTitle() {
return title;
}
public List<CategoryWrapper> getCategories() {
return categories;
}
public void setCategories(List<CategoryWrapper> categories) {
this.categories = categories;
public List<MetadataFieldWrapper> getMetadataFields() {
return metadataFields;
}
public String getTitle() {
return title;
public void setType(String type) {
this.type = type;
}
public void setTitle(String title) {
this.title = title;
}
public void setCategories(List<CategoryWrapper> categories) {
this.categories = categories;
}
public void setMetadataFields(List<MetadataFieldWrapper> metadataFields) {
this.metadataFields = metadataFields;
}
@Override
public String toString() {
final int maxLen = 10;
return "MetaDataProfileBean [type="
+ type
+ ", title="
+ title
+ ", categories="
+ (categories != null ? categories.subList(0,
Math.min(categories.size(), maxLen)) : null)
+ ", metadataFields="
+ (metadataFields != null ? metadataFields.subList(0,
Math.min(metadataFields.size(), maxLen)) : null) + "]";
StringBuilder builder = new StringBuilder();
builder.append("MetaDataProfileBean [type=");
builder.append(type);
builder.append(", title=");
builder.append(title);
builder.append(", categories=");
builder.append(categories);
builder.append(", metadataFields=");
builder.append(metadataFields);
builder.append("]");
return builder.toString();
}
}

View File

@ -1,18 +1,20 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.metadata;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
/**
* The Class MetadataFieldWrapper.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* @author francesco-mangiacrapa at ISTI-CNR (costantino.perciante@isti.cnr.it)
* Mar 3, 2022
*/
public class MetadataFieldWrapper implements Serializable{
public class MetadataFieldWrapper implements UpdatableField, Serializable {
private static final long serialVersionUID = -8476731365884466698L;
private String fieldId;
private String fieldName;
private String fieldNameFromCategory;
private Boolean mandatory = false;
@ -25,9 +27,11 @@ public class MetadataFieldWrapper implements Serializable{
private CategoryWrapper ownerCategory;
private FieldAsGroup asGroup;
private FieldAsTag asTag;
private Integer maxOccurs = 1;
private String[] currentValues;
/**
* Instantiates a new metadata field.
*/
@ -36,22 +40,23 @@ public class MetadataFieldWrapper implements Serializable{
}
/**
* Instantiates a new metadata field.
* Instantiates a new metadata field wrapper.
*
* @param fieldName the field name
* @param mandatory the mandatory
* @param type the type
* @param fieldId the field id (optional) if present is used instead of
* fieldName as result
* @param fieldName the field name
* @param mandatory the mandatory
* @param type the type
* @param defaultValue the default value
* @param note the note
* @param vocabulary the vocabulary
* @param validator the validator
* @param category the category
* @param note the note
* @param vocabulary the vocabulary
* @param validator the validator
* @param category the category
*/
public MetadataFieldWrapper(
String fieldName, Boolean mandatory, DataTypeWrapper type,
String defaultValue, String note, List<String> vocabulary,
String validator, CategoryWrapper category) {
public MetadataFieldWrapper(String fieldId, String fieldName, Boolean mandatory, DataTypeWrapper type,
String defaultValue, String note, List<String> vocabulary, String validator, CategoryWrapper category) {
super();
this.fieldId = fieldId;
this.fieldName = fieldName;
this.mandatory = mandatory;
this.type = type;
@ -61,8 +66,6 @@ public class MetadataFieldWrapper implements Serializable{
this.validator = validator;
this.ownerCategory = category;
}
/**
* Gets the max occurs.
@ -82,10 +85,28 @@ public class MetadataFieldWrapper implements Serializable{
this.maxOccurs = maxOccurs;
}
/**
* Gets the field id.
*
* @return the field id
*/
public String getFieldId() {
return fieldId;
}
/**
* Sets the field id.
*
* @param fieldId the new field id
*/
public void setFieldId(String fieldId) {
this.fieldId = fieldId;
}
/**
* Gets the field name.
*
* @return the fieldName
* @return the serviceFieldName
*/
public String getFieldName() {
@ -145,7 +166,7 @@ public class MetadataFieldWrapper implements Serializable{
/**
* Sets the field name.
*
* @param fieldName the fieldName to set
* @param fieldName the new field name
*/
public void setFieldName(String fieldName) {
@ -310,30 +331,78 @@ public class MetadataFieldWrapper implements Serializable{
this.asTag = asTag;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
/**
* Gets the current values.
*
* @return the current values
*/
public List<String> getCurrentValues() {
if (currentValues == null)
return null;
return Arrays.asList(currentValues);
}
/**
* Sets the current values.
*
* @param currentValues the new current values
*/
public void setCurrentValues(String... currentValues) {
this.currentValues = currentValues;
}
/**
* Gets the current single value.
*
* @return the current single value
*/
public String getCurrentSingleValue() {
if (this.currentValues != null && this.currentValues.length > 0)
return this.currentValues[0];
return null;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
return "MetadataFieldWrapper ["
+ (fieldName != null ? "fieldName=" + fieldName + ", " : "")
+ (fieldNameFromCategory != null ? "fieldNameFromCategory="
+ fieldNameFromCategory + ", " : "")
+ (mandatory != null ? "mandatory=" + mandatory + ", " : "")
+ (maxOccurs != null ? "maxOccurs=" + maxOccurs + ", " : "")
+ (type != null ? "type=" + type + ", " : "")
+ (defaultValue != null ? "defaultValue=" + defaultValue + ", "
: "")
+ (note != null ? "note=" + note + ", " : "")
+ (vocabulary != null ? "vocabulary=" + vocabulary + ", " : "")
+ "multiSelection="
+ multiSelection
+ ", "
+ (validator != null ? "validator=" + validator + ", " : "")
+ (ownerCategory != null ? "ownerCategory=" + ownerCategory.getId()
+ ", " : "")
+ (asGroup != null ? "asGroup=" + asGroup + ", " : "")
+ (asTag != null ? "asTag=" + asTag : "") + "]";
StringBuilder builder = new StringBuilder();
builder.append("MetadataFieldWrapper [fieldId=");
builder.append(fieldId);
builder.append(", fieldName=");
builder.append(fieldName);
builder.append(", fieldNameFromCategory=");
builder.append(fieldNameFromCategory);
builder.append(", mandatory=");
builder.append(mandatory);
builder.append(", type=");
builder.append(type);
builder.append(", defaultValue=");
builder.append(defaultValue);
builder.append(", note=");
builder.append(note);
builder.append(", vocabulary=");
builder.append(vocabulary);
builder.append(", multiSelection=");
builder.append(multiSelection);
builder.append(", validator=");
builder.append(validator);
builder.append(", ownerCategory=");
builder.append(ownerCategory);
builder.append(", asGroup=");
builder.append(asGroup);
builder.append(", asTag=");
builder.append(asTag);
builder.append(", maxOccurs=");
builder.append(maxOccurs);
builder.append(", currentValues=");
builder.append(getCurrentValues());
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,10 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.metadata;
import java.util.List;
public interface UpdatableField {
void setCurrentValues(String... values);
List<String> getCurrentValues();
}

View File

@ -0,0 +1,99 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.upload;
import java.io.Serializable;
/**
* The Class FilePath.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Apr 13, 2023
*/
public class FilePath implements Serializable {
/**
*
*/
private static final long serialVersionUID = -1544808784879956412L;
private String formFieldLabel; // It is the gcubeProfileFieldName registered in the UCD of Geoportal
private String fieldName; // It is the fieldName registered in the UCD of Geoportal
/**
* Instantiates a new file paths.
*/
public FilePath() {
}
/**
* Instantiates a new file path.
*
* @param formFieldLabel the form field label
*/
public FilePath(String formFieldLabel) {
this.formFieldLabel = formFieldLabel;
}
/**
* Instantiates a new file path.
*
* @param formFieldLabel the form field label
* @param fieldName the field name
*/
public FilePath(String formFieldLabel, String fieldName) {
this.formFieldLabel = formFieldLabel;
this.fieldName = fieldName;
}
/**
* Gets the form field label.
*
* @return the form field label
*/
public String getFormFieldLabel() {
return formFieldLabel;
}
/**
* Sets the form field label.
*
* @param formFieldLabel the new form field label
*/
public void setFormFieldLabel(String formFieldLabel) {
this.formFieldLabel = formFieldLabel;
}
/**
* Gets the field name.
*
* @return the field name
*/
public String getFieldName() {
return fieldName;
}
/**
* Sets the field name.
*
* @param fieldName the new field name
*/
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("FilePath [formFieldLabel=");
builder.append(formFieldLabel);
builder.append(", fieldName=");
builder.append(fieldName);
builder.append("]");
return builder.toString();
}
}

View File

@ -7,49 +7,50 @@ import java.io.Serializable;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* The Class FileUploaded.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 8, 2020
* Oct 8, 2020
*/
public class FileUploaded implements Serializable, IsSerializable{
public class FileUploaded implements Serializable, IsSerializable {
/**
*
*/
private static final long serialVersionUID = -7869956386977214114L;
private static final long serialVersionUID = -6666006742990360875L;
/** The file name. */
private String fileName;
/** The item id. */
private String tempSystemPath;
private String createdByUser;
private FilePath filePath;
/**
* Instantiates a new workspace upload file.
*/
public FileUploaded() {
}
/**
* Instantiates a new workspace upload file.
* Instantiates a new file uploaded.
*
* @param fileName the file name
* @param fileName the file name
* @param tempSystemPath the temp system path
* @param createdByUser the created by user
* @param createdByUser the created by user
* @param filePath the file path
*/
public FileUploaded(String fileName, String tempSystemPath, String createdByUser) {
public FileUploaded(String fileName, String tempSystemPath, String createdByUser, FilePath filePath) {
super();
this.fileName = fileName;
this.tempSystemPath = tempSystemPath;
this.createdByUser = createdByUser;
this.filePath = filePath;
}
/**
@ -61,8 +62,6 @@ public class FileUploaded implements Serializable, IsSerializable{
return fileName;
}
/**
* Sets the file name.
*
@ -72,8 +71,6 @@ public class FileUploaded implements Serializable, IsSerializable{
this.fileName = fileName;
}
/**
* Gets the temp system path.
*
@ -83,8 +80,6 @@ public class FileUploaded implements Serializable, IsSerializable{
return tempSystemPath;
}
/**
* Sets the temp system path.
*
@ -94,8 +89,6 @@ public class FileUploaded implements Serializable, IsSerializable{
this.tempSystemPath = tempSystemPath;
}
/**
* Gets the created by user.
*
@ -105,8 +98,6 @@ public class FileUploaded implements Serializable, IsSerializable{
return createdByUser;
}
/**
* Sets the created by user.
*
@ -116,18 +107,24 @@ public class FileUploaded implements Serializable, IsSerializable{
this.createdByUser = createdByUser;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("FileUploaded [fileName=");
builder.append(fileName);
builder.append(", tempSystemPath=");
builder.append(tempSystemPath);
builder.append(", createdByUser=");
builder.append(createdByUser);
builder.append("]");
return builder.toString();
/**
* Gets the file paths.
*
* @return the file paths
*/
public FilePath getFilePath() {
return filePath;
}
/**
* Sets the file path.
*
* @param filePath the new file path
*/
public void setFilePath(FilePath filePath) {
this.filePath = filePath;
}
}

View File

@ -0,0 +1,74 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.upload;
/**
* The Class FileUploadedRemote.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Feb 1, 2023
*/
public class FileUploadedRemote extends FileUploaded {
/**
*
*/
private static final long serialVersionUID = 2991541932545131966L;
private String url;
private String mimeType;
/**
* Instantiates a new file uploaded remote.
*/
public FileUploadedRemote() {
}
/**
* Gets the url.
*
* @return the url
*/
public String getUrl() {
return url;
}
/**
* Sets the url.
*
* @param url the new url
*/
public void setUrl(String url) {
this.url = url;
}
/**
* Gets the mime type.
*
* @return the mime type
*/
public String getMimeType() {
return mimeType;
}
/**
* Sets the mime type.
*
* @param mimeType the new mime type
*/
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("FileUploadedRemote [url=");
builder.append(url);
builder.append(", mimeType=");
builder.append(mimeType);
builder.append("]");
return builder.toString();
}
}