From 716553cf3b2523ff11068528ba9c4234bf84e161 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Fri, 20 May 2016 12:09:49 +0000 Subject: [PATCH] First import of the new version (made with bootstrap) git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/vre-definition@128736 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 54 ++ .project | 53 ++ .settings/.jsdtscope | 13 + .settings/com.google.gdt.eclipse.core.prefs | 4 + .settings/com.google.gwt.eclipse.core.prefs | 2 + .settings/org.eclipse.core.resources.prefs | 6 + .settings/org.eclipse.jdt.core.prefs | 8 + .settings/org.eclipse.jst.jsp.core.prefs | 3 + .settings/org.eclipse.m2e.core.prefs | 4 + .settings/org.eclipse.wst.common.component | 10 + ....eclipse.wst.common.project.facet.core.xml | 8 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .settings/org.eclipse.wst.validation.prefs | 2 + .tern-project | 1 + META-INF/clientlog4j.properties | 13 + distro/LICENSE | 1 + distro/README | 67 ++ distro/changelog.xml | 6 + distro/descriptor.xml | 42 ++ distro/profile.xml | 25 + pom.xml | 270 +++++++ .../vredefinition/client/VREDefinition.java | 35 + .../client/VREDefinitionPanel.java | 692 ++++++++++++++++++ .../client/VREDefinitionService.java | 43 ++ .../client/VREDefinitionServiceAsync.java | 21 + .../vredefinition/client/ui/PageHeader.java | 40 + .../vredefinition/client/ui/PageHeader.ui.xml | 14 + .../client/ui/ResourcesTable.java | 456 ++++++++++++ .../vredefinition/client/ui/SummaryPanel.java | 79 ++ .../client/ui/SummaryPanel.ui.xml | 50 ++ .../client/ui/VRECreationFormSkeleton.java | 304 ++++++++ .../client/ui/VRECreationFormSkeleton.ui.xml | 97 +++ .../server/VREDefinitionServiceImpl.java | 663 +++++++++++++++++ .../server/portlet/VREDefinitionPortlet.java | 25 + .../vredefinition/shared/Functionality.java | 93 +++ .../admin/vredefinition/shared/Resource.java | 68 ++ .../shared/ResourceCategory.java | 61 ++ .../shared/VREDescriptionBean.java | 95 +++ .../exception/VREDefinitionException.java | 27 + .../admin/vredefinition/VreDefinition.gwt.xml | 21 + .../client/Messages_fr.properties | 2 + src/main/webapp/VreDefinition.css | 56 ++ src/main/webapp/VreDefinition.html | 50 ++ .../webapp/WEB-INF/jsp/VREDefinition_view.jsp | 8 + src/main/webapp/WEB-INF/liferay-display.xml | 8 + .../WEB-INF/liferay-plugin-package.properties | 9 + src/main/webapp/WEB-INF/liferay-portlet.xml | 16 + src/main/webapp/WEB-INF/portlet.xml | 24 + src/main/webapp/WEB-INF/web.xml | 22 + src/main/webapp/images/statistics-loader.gif | Bin 0 -> 9511 bytes .../vredefinition/client/TestForDeploy.java | 19 + .../vredefinition/VreDefinitionJUnit.gwt.xml | 9 + 53 files changed, 3701 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/.jsdtscope create mode 100644 .settings/com.google.gdt.eclipse.core.prefs create mode 100644 .settings/com.google.gwt.eclipse.core.prefs create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.jst.jsp.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs create mode 100644 .settings/org.eclipse.wst.common.component create mode 100644 .settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 .settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 .settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 .settings/org.eclipse.wst.validation.prefs create mode 100644 .tern-project create mode 100644 META-INF/clientlog4j.properties create mode 100644 distro/LICENSE create mode 100644 distro/README create mode 100644 distro/changelog.xml create mode 100644 distro/descriptor.xml create mode 100644 distro/profile.xml create mode 100644 pom.xml create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/client/VREDefinition.java create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/client/VREDefinitionPanel.java create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/client/VREDefinitionService.java create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/client/VREDefinitionServiceAsync.java create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/PageHeader.java create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/PageHeader.ui.xml create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/ResourcesTable.java create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/SummaryPanel.java create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/SummaryPanel.ui.xml create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/VRECreationFormSkeleton.java create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/VRECreationFormSkeleton.ui.xml create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/server/VREDefinitionServiceImpl.java create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/server/portlet/VREDefinitionPortlet.java create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/shared/Functionality.java create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/shared/Resource.java create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/shared/ResourceCategory.java create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/shared/VREDescriptionBean.java create mode 100644 src/main/java/org/gcube/portlets/admin/vredefinition/shared/exception/VREDefinitionException.java create mode 100644 src/main/resources/org/gcube/portlets/admin/vredefinition/VreDefinition.gwt.xml create mode 100644 src/main/resources/org/gcube/portlets/admin/vredefinition/client/Messages_fr.properties create mode 100644 src/main/webapp/VreDefinition.css create mode 100644 src/main/webapp/VreDefinition.html create mode 100644 src/main/webapp/WEB-INF/jsp/VREDefinition_view.jsp create mode 100644 src/main/webapp/WEB-INF/liferay-display.xml create mode 100644 src/main/webapp/WEB-INF/liferay-plugin-package.properties create mode 100644 src/main/webapp/WEB-INF/liferay-portlet.xml create mode 100644 src/main/webapp/WEB-INF/portlet.xml create mode 100644 src/main/webapp/WEB-INF/web.xml create mode 100644 src/main/webapp/images/statistics-loader.gif create mode 100644 src/test/java/org/gcube/portlets/admin/vredefinition/client/TestForDeploy.java create mode 100644 src/test/resources/org/gcube/portlets/admin/vredefinition/VreDefinitionJUnit.gwt.xml diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..69c1604 --- /dev/null +++ b/.classpath @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..636dc18 --- /dev/null +++ b/.project @@ -0,0 +1,53 @@ + + + vre-definition + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + com.google.gdt.eclipse.core.webAppProjectValidator + + + + + com.google.gwt.eclipse.core.gwtProjectValidator + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + com.google.gwt.eclipse.core.gwtNature + + diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope new file mode 100644 index 0000000..b72a6a4 --- /dev/null +++ b/.settings/.jsdtscope @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/.settings/com.google.gdt.eclipse.core.prefs b/.settings/com.google.gdt.eclipse.core.prefs new file mode 100644 index 0000000..5879e15 --- /dev/null +++ b/.settings/com.google.gdt.eclipse.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +lastWarOutDir=/home/costantino/workspace/vre-definition-new/target/vre-definition-new-1.0.0-SNAPSHOT +warSrcDir=src/main/webapp +warSrcDirIsOutput=false diff --git a/.settings/com.google.gwt.eclipse.core.prefs b/.settings/com.google.gwt.eclipse.core.prefs new file mode 100644 index 0000000..f23a752 --- /dev/null +++ b/.settings/com.google.gwt.eclipse.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +entryPointModules= diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..29abf99 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..45a6e0e --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/.settings/org.eclipse.jst.jsp.core.prefs b/.settings/org.eclipse.jst.jsp.core.prefs new file mode 100644 index 0000000..3a5c98d --- /dev/null +++ b/.settings/org.eclipse.jst.jsp.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +validateFragments=false +validation.use-project-settings=true diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..711d756 --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..2a74e67 --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..3bd5d0a --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.name b/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..05bd71b --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 0000000..04cad8c --- /dev/null +++ b/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,2 @@ +disabled=06target +eclipse.preferences.version=1 diff --git a/.tern-project b/.tern-project new file mode 100644 index 0000000..a185ba0 --- /dev/null +++ b/.tern-project @@ -0,0 +1 @@ +{"ide":{"scriptPaths":[]},"plugins":{"aui":{},"liferay":{},"yui":{}},"libs":["ecma5","browser"]} \ No newline at end of file diff --git a/META-INF/clientlog4j.properties b/META-INF/clientlog4j.properties new file mode 100644 index 0000000..574c7b1 --- /dev/null +++ b/META-INF/clientlog4j.properties @@ -0,0 +1,13 @@ +log4j.rootLogger=DEBUG, A1 +log4j.appender.A1=org.apache.log4j.ConsoleAppender +log4j.appender.A1.layout=org.apache.log4j.PatternLayout + +# Print the date in ISO 8601 format +log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n + +# Print only messages of level TRACE or above in the package org.gcube +log4j.logger.org.gcube=TRACE +log4j.logger.org.gcube.application.framework.core.session=INFO +log4j.logger.com.netflix.astyanax.connectionpool=ERROR +log4j.logger.org.gcube.portal.databook.server.DBCassandraAstyanaxImpl=TRACE +log4j.logger.org.gcube.common=ERROR \ No newline at end of file diff --git a/distro/LICENSE b/distro/LICENSE new file mode 100644 index 0000000..2d9616a --- /dev/null +++ b/distro/LICENSE @@ -0,0 +1 @@ +${gcube.license} \ No newline at end of file diff --git a/distro/README b/distro/README new file mode 100644 index 0000000..f1a2d55 --- /dev/null +++ b/distro/README @@ -0,0 +1,67 @@ +The gCube System - ${name} +-------------------------------------------------- + +${description} + + +${gcube.description} + +${gcube.funding} + + +Version +-------------------------------------------------- + +${version} (${buildDate}) + +Please see the file named "changelog.xml" in this directory for the release notes. + + +Authors +-------------------------------------------------- + +* Massimiliano Assante (massimiliano.assante-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). +* Costantino Perciante (costantino.perciante-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). + + +Maintainers +----------- + +* Massimiliano Assante (massimiliano.assante-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). +* Costantino Perciante (costantino.perciante-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). + +Download information +-------------------------------------------------- + +Source code is available from SVN: + ${scm.url} + +Binaries can be downloaded from the gCube website: + ${gcube.website} + + +Installation +-------------------------------------------------- + +Installation documentation is available on-line in the gCube Wiki: + ${gcube.wikiRoot}/ + + +Documentation +-------------------------------------------------- + +Documentation is available on-line in the gCube Wiki: + ${gcube.wikiRoot}/ + ${gcube.wikiRoot}/ + +Support +-------------------------------------------------- + +Bugs and support requests can be reported in the gCube issue tracking tool: + ${gcube.issueTracking} + + +Licensing +-------------------------------------------------- + +This software is licensed under the terms you may find in the file named "LICENSE" in this directory. diff --git a/distro/changelog.xml b/distro/changelog.xml new file mode 100644 index 0000000..6085b1a --- /dev/null +++ b/distro/changelog.xml @@ -0,0 +1,6 @@ + + + First version + + \ No newline at end of file diff --git a/distro/descriptor.xml b/distro/descriptor.xml new file mode 100644 index 0000000..c81acc0 --- /dev/null +++ b/distro/descriptor.xml @@ -0,0 +1,42 @@ + + servicearchive + + tar.gz + + / + + + ${distroDirectory} + / + true + + README + LICENSE + changelog.xml + profile.xml + + 755 + true + + + target/apidocs + /${artifactId}/doc/api + true + 755 + + + + + ${distroDirectory}/profile.xml + ./ + true + + + target/${build.finalName}.war + /${artifactId} + + + \ No newline at end of file diff --git a/distro/profile.xml b/distro/profile.xml new file mode 100644 index 0000000..05f3322 --- /dev/null +++ b/distro/profile.xml @@ -0,0 +1,25 @@ + + + + Service + + ${description} + PortletAdmin + ${artifactId} + ${version} + + + ${artifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + + target/${build.finalName}.war + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..d6e741a --- /dev/null +++ b/pom.xml @@ -0,0 +1,270 @@ + + + + 4.0.0 + + maven-parent + org.gcube.tools + 1.0.0 + + + + org.gcube.portlets.admin + vre-definition-new + war + 1.0.0-SNAPSHOT + VRE Definition Portlet + + gCube VRE Definition Portlet shows a Wizard to create VREs. + + + + + + 2.7.0 + + + 1.7 + 1.7 + distro + ${project.build.directory}/${project.build.finalName} + 6.2.5 + UTF-8 + + + + + + com.google.gwt + gwt + ${gwtVersion} + pom + import + + + org.gcube.distribution + maven-portal-bom + LATEST + pom + import + + + + + + + xerces + xercesImpl + 2.9.1 + provided + + + + com.google.gwt + gwt-servlet + ${gwtVersion} + provided + + + com.google.gwt + gwt-user + ${gwtVersion} + provided + + + com.google.gwt + gwt-dev + ${gwtVersion} + provided + + + com.github.gwtbootstrap + gwt-bootstrap + + + org.gcube.portlets.user + gcube-widgets + compile + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + + + org.gcube.applicationsupportlayer + aslcore + provided + + + org.gcube.applicationsupportlayer + aslvre + [5.2.0-SNAPSHOT,) + compile + + + org.gcube.applicationsupportlayer + aslsocial + provided + + + org.gcube.common + home-library + provided + + + org.gcube.core + common-scope-maps + provided + + + + org.gcube.vremanagement + vremodeler-client-library + [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + + + org.gcube.dvos + usermanagement-core + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + provided + + + org.gcube.portal + custom-portal-handler + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + provided + + + com.liferay.portal + portal-service + ${liferayVersion} + provided + + + javax.portlet + portlet-api + provided + + + log4j + log4j + provided + + + org.slf4j + slf4j-log4j12 + provided + + + org.slf4j + slf4j-api + provided + + + junit + junit + 4.11 + test + + + + + + ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + + + + org.codehaus.mojo + gwt-maven-plugin + ${gwtVersion} + + + + compile + test + + + + + + VreDefinition.html + ${webappDirectory} + + + + + org.apache.maven.plugins + maven-war-plugin + 2.1.1 + + + compile + + exploded + + + + + ${webappDirectory} + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.5 + 1.5 + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2 + + + ${distroDirectory}/descriptor.xml + + + + + servicearchive + install + + single + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + + copy-profile + install + + copy-resources + + + target + + + ${distroDirectory} + true + + profile.xml + + + + + + + + + + + diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/client/VREDefinition.java b/src/main/java/org/gcube/portlets/admin/vredefinition/client/VREDefinition.java new file mode 100644 index 0000000..6908678 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/client/VREDefinition.java @@ -0,0 +1,35 @@ +package org.gcube.portlets.admin.vredefinition.client; + +import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper; + +import com.github.gwtbootstrap.client.ui.AlertBlock; +import com.github.gwtbootstrap.client.ui.constants.AlertType; +import com.google.gwt.core.client.EntryPoint; +import com.google.gwt.user.client.Window.Location; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.RootPanel; + +/** + * Entry point classes define onModuleLoad(). + */ +public class VREDefinition implements EntryPoint { + + /** + * This is the entry point method. + */ + public void onModuleLoad() { + ClientScopeHelper.getService().setScope(Location.getHref(), new AsyncCallback() { + + public void onSuccess(Boolean result) { + RootPanel.get("VREDefinitionDIV").add(new VREDefinitionPanel()); + } + + public void onFailure(Throwable caught) { + AlertBlock errorScope = new AlertBlock(AlertType.ERROR); + errorScope.setClose(false); + errorScope.setText("Sorry, something wrong happened. Try to refresh the page or logout."); + RootPanel.get("VREDefinitionDIV").add(errorScope); + } + }); + } +} diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/client/VREDefinitionPanel.java b/src/main/java/org/gcube/portlets/admin/vredefinition/client/VREDefinitionPanel.java new file mode 100644 index 0000000..00ed36d --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/client/VREDefinitionPanel.java @@ -0,0 +1,692 @@ +package org.gcube.portlets.admin.vredefinition.client; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.gcube.portlets.admin.vredefinition.client.ui.PageHeader; +import org.gcube.portlets.admin.vredefinition.client.ui.ResourcesTable; +import org.gcube.portlets.admin.vredefinition.client.ui.SummaryPanel; +import org.gcube.portlets.admin.vredefinition.client.ui.VRECreationFormSkeleton; +import org.gcube.portlets.admin.vredefinition.shared.Functionality; +import org.gcube.portlets.admin.vredefinition.shared.Resource; +import org.gcube.portlets.admin.vredefinition.shared.ResourceCategory; +import org.gcube.portlets.admin.vredefinition.shared.VREDescriptionBean; + +import com.github.gwtbootstrap.client.ui.AlertBlock; +import com.github.gwtbootstrap.client.ui.AppendButton; +import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.CheckBox; +import com.github.gwtbootstrap.client.ui.Column; +import com.github.gwtbootstrap.client.ui.Form; +import com.github.gwtbootstrap.client.ui.HelpInline; +import com.github.gwtbootstrap.client.ui.Row; +import com.github.gwtbootstrap.client.ui.Tab; +import com.github.gwtbootstrap.client.ui.TabPanel; +import com.github.gwtbootstrap.client.ui.TextBox; +import com.github.gwtbootstrap.client.ui.constants.AlertType; +import com.github.gwtbootstrap.client.ui.constants.ButtonType; +import com.github.gwtbootstrap.client.ui.constants.IconSize; +import com.github.gwtbootstrap.client.ui.constants.IconType; +import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs; +import com.github.gwtbootstrap.client.ui.resources.ButtonSize; +import com.google.gwt.core.client.GWT; +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.event.logical.shared.ValueChangeEvent; +import com.google.gwt.event.logical.shared.ValueChangeHandler; +import com.google.gwt.user.client.Timer; +import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.Tree; +import com.google.gwt.user.client.ui.TreeItem; +import com.google.gwt.user.client.ui.VerticalPanel; + +/** + * The VREDefinitionPanel class contains the form to create/edit a VRE. + * @author Costantino Perciante at ISTI-CNR + * (costantino.perciante@isti.cnr.it) + */ +public class VREDefinitionPanel extends Composite { + + // async services + VREDefinitionServiceAsync rpcService = GWT.create(VREDefinitionService.class); + + // main panel + private VerticalPanel mainPanel; + + // skeleton + private VRECreationFormSkeleton skeleton = new VRECreationFormSkeleton(); + + // summary panel + private SummaryPanel summary = new SummaryPanel(); + + // main tab + private TabPanel mainTabPanel = new TabPanel(Tabs.LEFT); + + // tab panel for VRE information + private Tab vreInformationTab = new Tab(); + + // the create vre button + private Button createVREButton = new Button("Upload"); + + // retrieving information alert block + private AlertBlock retrievingInformation = new AlertBlock(AlertType.INFO); + + // hashmap to keep track of the selection of the subfunctionalities + protected class SubFunctionalityClientBean{ + + private CheckBox checkbox; + private Functionality subfunctionality; + + SubFunctionalityClientBean(CheckBox checkbox, Functionality subfunctionality){ + + this.checkbox = checkbox; + this.subfunctionality = subfunctionality; + + } + + public CheckBox getCheckbox() { + return checkbox; + } + + + public Functionality getSubfunctionality() { + return subfunctionality; + } + } + + HashMap> subFunctionalityBeansMap = + new HashMap>(); + + // keys of the hashmap returned by some rpc services + private static final String DESIGNER = "Designer"; + private static final String MANAGER = "Manager"; + private static final String VRE_NAME_FIELD = "vreName"; + private static final String VRE_MANAGER_FIELD = "vreManager"; + private static final String VRE_DESIGNER_FIELD = "vreDesigner"; + private static final String VRE_DESCRIPTION_FIELD = "vreDescription"; + private static final String VRE_START_TIME_FIELD = "vreStartTime"; + private static final String VRE_END_TIME_FIELD = "vreEndTime"; + private static final String EDIT_MODE = "edit"; + + public VREDefinitionPanel(){ + + super(); + + // create main panel + mainPanel = new VerticalPanel(); + + // init + initWidget(mainPanel); + + // set its style + mainPanel.addStyleName("vre-definition-main-panel"); + + // add the main tab panel to the main panel + mainPanel.add(mainTabPanel); + + // add skeleton as tab + vreInformationTab.setHeading("VRE Information"); + vreInformationTab.add(skeleton); + + // add and set as selected + mainTabPanel.add(vreInformationTab); + mainTabPanel.selectTab(0); + + // add loader to skeletonTab + retrievingInformation.setClose(false); + retrievingInformation.setText("Retrieving information, please wait..."); + vreInformationTab.add(retrievingInformation); + + // require designers/managers information or retrieve a previous bean saved into section + rpcService.getVRE(new AsyncCallback>() { + + @SuppressWarnings("unchecked") + public void onSuccess(Map result) { + + // remove loader + vreInformationTab.remove(retrievingInformation); + + if(result != null && !result.isEmpty()){ + + retrievingInformation.setText("Retrieving functionalities, please wait..."); + vreInformationTab.add(retrievingInformation); + + boolean editMode = (Boolean) result.get(EDIT_MODE); + + // check edit mode + if(editMode){ + + skeleton.setVREDesigner((String)result.get(VRE_DESIGNER_FIELD)); + skeleton.setVREManagers((List)result.get(MANAGER), (String)result.get(VRE_MANAGER_FIELD)); // pass all the managers plus the selected one + skeleton.setVREName((String)result.get(VRE_NAME_FIELD)); + skeleton.setVREDescription((String)result.get(VRE_DESCRIPTION_FIELD)); + skeleton.setVREFromDate((Date)result.get(VRE_START_TIME_FIELD)); + skeleton.setVREToDate((Date)result.get(VRE_END_TIME_FIELD)); + + }else{ + skeleton.setVREDesigner((String)result.get(DESIGNER)); + skeleton.setVREManagers((List)result.get(MANAGER), null); + } + + // require functionalities + requireFunctionalities(editMode, mainTabPanel); + + }else + showErrors("Unable to retrieve the current designer and managers for this Virtual Organization"); + + } + + public void onFailure(Throwable caught) { + + // remove loader + vreInformationTab.remove(retrievingInformation); + showErrors("Unable to retrieve the current designer and managers for this Virtual Organization"); + + } + }); + + } + + /** + * Require the list of functionalities + * @param mainTabPanel + */ + private void requireFunctionalities(boolean isEditMode, final TabPanel mainTabPanel) { + // require the list of functionalities + rpcService.getFunctionality(isEditMode, new AsyncCallback>() { + + public void onSuccess(final ArrayList result) { + + // remove info + vreInformationTab.remove(retrievingInformation); + + if(result != null){ + + // put these widgets into the skeleton as rows + for (final Functionality functionality : result) { + + // create a tab + Tab functionalityTab = new Tab(); + functionalityTab.setHeading(functionality.getName()); + + // the header row of each macro functionality will look like + // Title - Subtitle + Row mainRow = new Row(); + + // title and subtitle of the macrofunctionality + PageHeader header = new PageHeader(); + header.setText(functionality.getName(), functionality.getDescription()); + mainRow.add(header); + + // get subfunctionalities + List children = functionality.getSubFunctionalities(); + + // if there are more than two, we add a button to select/deselect them all + if(children.size() >= 2){ + + // Select/Deselect sub-functionalities button + final Button selectDeselectAll = new Button("Select All"); + selectDeselectAll.setTitle("Select all the sub-functionalities"); + selectDeselectAll.setType(ButtonType.LINK); + selectDeselectAll.setSize(ButtonSize.LARGE); + selectDeselectAll.addStyleName("select-deselect-button-style"); + + final Boolean[] selectedAll = new Boolean[0]; + selectedAll[0] = false; + + // add an handler to the button Select/Deselect All + selectDeselectAll.addClickHandler(new ClickHandler() { + + public void onClick(ClickEvent event) { + + // get the list from the hashmap + List listSubfs = + subFunctionalityBeansMap.get(functionality.getName()); + + // select/deselect all the subfunctionalities within the list for this macrofunctionality + if(!selectedAll[0]){ + + // swap to deselect all + selectDeselectAll.setTitle("Deselect all the sub-functionalities"); + selectDeselectAll.setText("Deselect All"); + + for(VREDefinitionPanel.SubFunctionalityClientBean subBean : listSubfs){ + subBean.getCheckbox().setValue(true); + subBean.getSubfunctionality().setSelected(true); + } + + }else{ + + // swap to select all + selectDeselectAll.setTitle("Select all the sub-functionalities"); + selectDeselectAll.setText("Select All"); + + for(VREDefinitionPanel.SubFunctionalityClientBean subBean : listSubfs){ + subBean.getCheckbox().setValue(false); + subBean.getSubfunctionality().setSelected(false); + } + + } + + // swap status + selectedAll[0] = !selectedAll[0]; + } + }); + + mainRow.add(selectDeselectAll); + + } + // append the whole row to the container + functionalityTab.add(mainRow); + + mainTabPanel.add(functionalityTab); + + if(children != null){ + for(final Functionality child: children){ + + // create a row for the subfunctionality + Row subFunctionalityRow = new Row(); + + // put all the stuff into a form + Form subFunctionalityForm = new Form(); + subFunctionalityForm.addStyleName("subfunctionality-form"); + + // select subfunctionality checkbox + CheckBox checkBoxSubfunctionality = new CheckBox(); + checkBoxSubfunctionality.setText(child.getName()); + checkBoxSubfunctionality.setValue(child.isSelected()); // Auth for example is already set + checkBoxSubfunctionality.addStyleName("subfunctionality-textbox"); + + // add handler to this checkbox + checkBoxSubfunctionality.addValueChangeHandler(new ValueChangeHandler() { + + public void onValueChange(ValueChangeEvent event) { + + child.setSelected(event.getValue()); + + } + }); + + // subfunctionality description + HelpInline helpBlock = new HelpInline(); + helpBlock.setText(child.getDescription()); + + + subFunctionalityForm.add(checkBoxSubfunctionality); + subFunctionalityForm.add(helpBlock); + + // add form to row + subFunctionalityRow.add(subFunctionalityForm); + + // insert this entry > to the map + if(subFunctionalityBeansMap.containsKey(functionality.getName())){ + + // we need to update the list + List oldList = + subFunctionalityBeansMap.get(functionality.getName()); + + oldList.add(new SubFunctionalityClientBean(checkBoxSubfunctionality, child)); + + }else{ + + // there is not yet such macro functionality + List newList = new ArrayList(); + newList.add(new SubFunctionalityClientBean(checkBoxSubfunctionality, child)); + + // put into the hashmap + subFunctionalityBeansMap.put(functionality.getName(), newList); + + } + + // append to the main row + functionalityTab.add(subFunctionalityRow); + + // iterate over resources (of the subfunctionality) + List categoryResources = child.getResources(); + + if(categoryResources != null){ + for (ResourceCategory resourceCategory : categoryResources) { + + // skip the category and go to its children (i.e. the resources) + List resources = resourceCategory.getItems(); + + // if there are resources, add a filter widget to the form and a table + if(resources.size() > 0){ + + AppendButton apButton = new AppendButton(); + + TextBox searchBox = new TextBox(); + searchBox.setPlaceholder("Filter by name"); + Button searchButton = new Button(); + searchButton.setIcon(IconType.SEARCH); + searchButton.setIconSize(IconSize.DEFAULT); + searchButton.setType(ButtonType.DEFAULT); + + apButton.add(searchBox); + apButton.add(searchButton); + + apButton.addStyleName("filter-functionalities-box"); + subFunctionalityForm.add(apButton); + + // create a table whose rows are + // and show the first 5 rows + ResourcesTable table = new ResourcesTable(resources, apButton, checkBoxSubfunctionality); + + // append to the form + subFunctionalityForm.add(table); + + } + + } + } + } + } + } + + // add SummaryTabPane + final Tab summaryTab = new Tab(); + summaryTab.setHeading("Summary"); + summaryTab.add(summary); + summaryTab.addClickHandler(new ClickHandler() { + + public void onClick(ClickEvent event) { + + onGenerateSummarySubmit(result, summaryTab); + + } + }); + + // add to the tab panel + mainTabPanel.add(summaryTab); + + }else{ + + // remove info + vreInformationTab.remove(retrievingInformation); + showErrors("Unable to retrieve VRE functionalities"); + + } + } + + public void onFailure(Throwable caught) { + + // remove info + vreInformationTab.remove(retrievingInformation); + showErrors("Unable to retrieve VRE functionalities"); + + } + }); + } + + /** + * Generate summary + * @param result + * @param summaryTab + */ + private void onGenerateSummarySubmit(final ArrayList result, final Tab summaryTab) { + + // we need to generate the current summary and check if something wrong is present (e.g., vre's name missing) + final String vreName = skeleton.getCurrentVREName(); + String vreDesigner = skeleton.getCurrentVREDesigner(); + String vreSelectedManager = skeleton.getCurrentVREManager(); + String vreDescription = skeleton.getCurrentVREDescription(); + Date vreStartDate = skeleton.getCurrentVREStartDate(); + Date vreToDate = skeleton.getCurrentVREToDate(); + + // check errors: vreName, vreDesigner, vreDescription cannot be empty + if(vreName.isEmpty() || vreName.contains(" ")){ + + Timer t = new Timer() { + + @Override + public void run() { + + mainTabPanel.selectTab(0); + + } + }; + t.schedule(100); + skeleton.showAlertBlockVREName(); + return; + } + + if(vreDescription.isEmpty() || vreDescription.trim().length() == 0){ + skeleton.showAlertBlockVREDescritption(); + Timer t = new Timer() { + + @Override + public void run() { + + mainTabPanel.selectTab(0); + + } + }; + t.schedule(100); + return; + } + + // we can show the panel + summary.setVisible(true); + + // ok, we can create the bean + final VREDescriptionBean vreDescriptionBean = new VREDescriptionBean(vreName, vreDescription, vreDesigner, vreSelectedManager, vreStartDate, vreToDate); + + // clear functionalities panel + summary.clearFunctionalitiesPanel(); + + // collect information on functionalities/subfunctionalities/resources selected and show them + for(Functionality macroFunctionality: result){ + + // get its name + String name = macroFunctionality.getName(); + + // start building a tree having as root this macro functionality + Tree t = new Tree(); + TreeItem root = new TreeItem(); + root.setText(name); + t.addItem(root); + + // panel to add later to the summary for this macrofunctionality + VerticalPanel partialSummaryFunctionality = new VerticalPanel(); + partialSummaryFunctionality.getElement().getStyle().setMarginBottom(10, Unit.PX); + + // get the child list + List subfunctionalities = macroFunctionality.getSubFunctionalities(); + + for (Functionality subfunctionality : subfunctionalities) { + + // set as name the subfunctionality + TreeItem subfuncItem = new TreeItem(); + subfuncItem.setText(subfunctionality.getName()); + + if(subfunctionality.isSelected()){ + + // add to the root + root.addItem(subfuncItem); + + // we need the categories but we need not to put theme into the tree + List categories = subfunctionality.getResources(); + + if(categories == null) + continue; + + for (ResourceCategory resourceCategory : categories) { + + // iterate over its resources + ArrayList resources = resourceCategory.getItems(); + + for (Resource resource : resources) { + if(resource.isSelected()){ + + TreeItem resourceItem = new TreeItem(); + resourceItem.setText(resource.getName()); + + // add to the subfunctionality + subfuncItem.addItem(resourceItem); + + } + } + } + } + + } + + // add the tree to the summary + partialSummaryFunctionality.add(t); + summary.addFunctionality(partialSummaryFunctionality); + + } + + // fill the summary panel with main information + summary.setVreMainInformation(vreName, vreSelectedManager, vreDesigner, vreDescription, vreStartDate, vreToDate); + + // add the summary + summaryTab.add(summary); + + // add the buttons into a flow panel + final FlowPanel summaryButtons = new FlowPanel(); + summaryButtons.addStyleName("summary-buttons-panel"); + summaryButtons.add(createVREButton); + summaryTab.add(summaryButtons); + + // add style to goBackToDefinition button + + // set as primary the create one + createVREButton.setType(ButtonType.PRIMARY); + + // make them large + createVREButton.setSize(ButtonSize.LARGE); + + + // add handler to createVRE button + createVREButton.addClickHandler(new ClickHandler() { + + public void onClick(ClickEvent event) { + + boolean confirmed = Window.confirm("Do you want to create " + vreName + " ?"); + + // disable buttons + createVREButton.setEnabled(false); + + if(confirmed){ + + // add waiting block + final AlertBlock waitingCreation = new AlertBlock(AlertType.INFO); + waitingCreation.setText("Please wait..."); + waitingCreation.setClose(false); + summaryTab.add(waitingCreation); + + // try to set the vre + rpcService.setVRE(vreDescriptionBean, result, new AsyncCallback() { + + public void onSuccess(Boolean result) { + + // remove waiting + summaryTab.remove(waitingCreation); + + // add alert block + addAlertOnCreation(vreName, result, summaryTab); + + // remove the buttons + if(result) + summaryTab.remove(summaryButtons); + else{ + // enable again + createVREButton.setEnabled(true); + } + + } + + public void onFailure(Throwable caught) { + + // remove waiting + summaryTab.remove(waitingCreation); + + // add alert block + addAlertOnCreation(vreName, false, summaryTab); + + // enable again + createVREButton.setEnabled(true); + } + }); + } + + // enable again + createVREButton.setEnabled(true); + } + }); + + } + + /** + * Show errors on async request + */ + private void showErrors(String msg){ + + skeleton.removeLoader(); + + // error block + AlertBlock errorMsg = new AlertBlock(); + errorMsg.setType(AlertType.ERROR); + errorMsg.setClose(false); + errorMsg.setText(msg); + + // put it into a column of width 12 + Row errorRow = new Row(); + Column errorCol = new Column(12); + errorCol.add(errorMsg); + errorRow.add(errorCol); + + // pass to the skeleton + skeleton.appendRow(errorRow); + } + + /** + * After creation show an alert message + * @param vreName + * @param success + * @param summaryTab + */ + private void addAlertOnCreation(String vreName, boolean success, final Tab summaryTab){ + + String msg = "VRE with name " + vreName; + if(success) + msg += " created correctly!"; + else + msg += " not created. Please retry later."; + + final AlertBlock confirmation = new AlertBlock(msg); + + if(success) + confirmation.setType(AlertType.SUCCESS); + else + confirmation.setType(AlertType.ERROR); + + // add to the panel + summaryTab.add(confirmation); + + // remove after a while + Timer t = new Timer() { + + @Override + public void run() { + + summaryTab.remove(confirmation); + + } + }; + + // remove after two seconds + t.schedule(2000); + + } + +} diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/client/VREDefinitionService.java b/src/main/java/org/gcube/portlets/admin/vredefinition/client/VREDefinitionService.java new file mode 100644 index 0000000..7efe780 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/client/VREDefinitionService.java @@ -0,0 +1,43 @@ +package org.gcube.portlets.admin.vredefinition.client; + + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Map; + +import org.gcube.portlets.admin.vredefinition.shared.Functionality; +import org.gcube.portlets.admin.vredefinition.shared.VREDescriptionBean; +import org.gcube.portlets.admin.vredefinition.shared.exception.VREDefinitionException; + +import com.google.gwt.user.client.rpc.RemoteService; +import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; + +@RemoteServiceRelativePath("VREDefinitionServiceImpl") +public interface VREDefinitionService extends RemoteService { + + /** + * Retrieve VRE (that is going to be created) information + * @return an hashmap with a VREDefinitionBean object, a vre designer and + * some vre managers (if any). + */ + Map getVRE(); + + /** + * Request the vre functionalities to show (the returned object is a tree like structure that could be navigated) + * @param isEdit + * @return + * @throws VREDefinitionException + */ + ArrayList getFunctionality(boolean isEdit) throws VREDefinitionException; + + /** + * Create a VRE with the definition information included into the description bean and + * with the functionalities set into the functionalities array list + * @param bean + * @param functionalities + * @return + * @throws VREDefinitionException + */ + boolean setVRE(VREDescriptionBean bean, ArrayList functionalities) throws VREDefinitionException; + +} diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/client/VREDefinitionServiceAsync.java b/src/main/java/org/gcube/portlets/admin/vredefinition/client/VREDefinitionServiceAsync.java new file mode 100644 index 0000000..521cef8 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/client/VREDefinitionServiceAsync.java @@ -0,0 +1,21 @@ +package org.gcube.portlets.admin.vredefinition.client; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Map; + +import org.gcube.portlets.admin.vredefinition.shared.Functionality; +import org.gcube.portlets.admin.vredefinition.shared.VREDescriptionBean; + +import com.google.gwt.user.client.rpc.AsyncCallback; + +public interface VREDefinitionServiceAsync { + + void getVRE(AsyncCallback> callback); + + void getFunctionality(boolean isEdit, AsyncCallback> callback); + + void setVRE(VREDescriptionBean bean, + ArrayList functionalities, + AsyncCallback callback); +} diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/PageHeader.java b/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/PageHeader.java new file mode 100644 index 0000000..dfc8530 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/PageHeader.java @@ -0,0 +1,40 @@ +package org.gcube.portlets.admin.vredefinition.client.ui; + +import com.github.gwtbootstrap.client.ui.Icon; +import com.github.gwtbootstrap.client.ui.Popover; +import com.github.gwtbootstrap.client.ui.constants.Placement; +import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.HeadingElement; +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.Widget; + +public class PageHeader extends Composite{ + + private static PageHeaderUiBinder uiBinder = GWT + .create(PageHeaderUiBinder.class); + + interface PageHeaderUiBinder extends UiBinder { + } + + public PageHeader() { + initWidget(uiBinder.createAndBindUi(this)); + icon.addStyleName("icon-style"); + popoverInfo.setPlacement(Placement.BOTTOM); + popoverInfo.setHtml(true); + } + + @UiField HeadingElement mainText; + @UiField Popover popoverInfo; + @UiField Icon icon; + + /** + * Set the main text + */ + public void setText(String text, String subtext){ + mainText.setInnerHTML(text); + popoverInfo.setHeading("" + text + ""); + popoverInfo.setText(subtext); + } +} diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/PageHeader.ui.xml b/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/PageHeader.ui.xml new file mode 100644 index 0000000..3ae3d95 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/PageHeader.ui.xml @@ -0,0 +1,14 @@ + + + +
+

+

+ + + +
+
+
\ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/ResourcesTable.java b/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/ResourcesTable.java new file mode 100644 index 0000000..f79aca1 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/ResourcesTable.java @@ -0,0 +1,456 @@ +package org.gcube.portlets.admin.vredefinition.client.ui; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +import org.gcube.portlets.admin.vredefinition.shared.Resource; + +import com.github.gwtbootstrap.client.ui.AppendButton; +import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.CellTable; +import com.github.gwtbootstrap.client.ui.CheckBox; +import com.github.gwtbootstrap.client.ui.SimplePager; +import com.github.gwtbootstrap.client.ui.SimplePager.TextLocation; +import com.github.gwtbootstrap.client.ui.TextBox; +import com.github.gwtbootstrap.client.ui.constants.IconType; +import com.google.gwt.cell.client.Cell; +import com.google.gwt.cell.client.Cell.Context; +import com.google.gwt.cell.client.CheckboxCell; +import com.google.gwt.dom.client.Document; +import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.NativeEvent; +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.event.dom.client.KeyCodes; +import com.google.gwt.event.dom.client.KeyDownEvent; +import com.google.gwt.event.dom.client.KeyDownHandler; +import com.google.gwt.safehtml.shared.SafeHtmlBuilder; +import com.google.gwt.user.cellview.client.Column; +import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler; +import com.google.gwt.user.cellview.client.TextColumn; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwt.view.client.ListDataProvider; +import com.google.gwt.view.client.Range; + +/** + * The resources table class. + * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) + */ +public class ResourcesTable extends Composite{ + + // the data provider + protected ListDataProvider dataProvider = new ListDataProvider(); + + // the table that will be displayed + private CellTable table = new CellTable(); + + // save original list + private List originalResources; + + // max row to show + private static final int MAX_ROW_TO_SHOW_BEGINNING = 10; + + // TextBox and Button for filtering + private TextBox searchBox; + private Button searchButton; + + private Boolean isFilteringEnabled = false; + + // show all or switch to pagination button + private Button showAllButton = new Button(); + + // select all rows button + private Button selectAllRows = new Button(); + + // status + private boolean allRowsSelected = false; + + // main panel + private VerticalPanel mainPanel = new VerticalPanel(); + + // keep track of the number of checked resources + private int checkedResourcesNumber = 0; + + // father checkbox (if at least one of the resources is checked, it must be checked as well) + // we need to call the CheckBox.checkHandler that also selects the associated subfunctionality + public ResourcesTable(List resources, AppendButton apButton, final CheckBox checkBoxSubfunctionality){ + + super(); + initWidget(mainPanel); + + // set panel width + mainPanel.setWidth("100%"); + + // save original resources + this.originalResources = resources; + + // add data to the provider + dataProvider.setList(resources); + dataProvider.addDataDisplay(table); + + // style of the table + table.setStriped(true); + table.setWidth("100%", false); + table.addStyleName("table-style"); + table.setBordered(true); + + // visible rows + table.setVisibleRange(new Range(0, MAX_ROW_TO_SHOW_BEGINNING)); + table.setRowCount(resources.size(), true); + + // add handler to apButton (that contains the searchBox textbox and the search button) + searchBox = (TextBox)apButton.getWidget(0); + searchButton = (Button)apButton.getWidget(1); + + // add handlers on click as well as on key down + searchBox.addKeyDownHandler(new KeyDownHandler() { + + public void onKeyDown(KeyDownEvent event) { + event.preventDefault(); + searchOnKeyDown(event); + } + }); + + // add the handler + searchButton.addClickHandler(new ClickHandler() { + + public void onClick(ClickEvent event) { + event.preventDefault(); + boolean[] isFilteringEnabledReference = {isFilteringEnabled}; + searchOnClickEvent(event, isFilteringEnabledReference); + isFilteringEnabled = isFilteringEnabledReference[0]; + } + }); + + // Add a checked column to show the address. + Column chosenColumn = new Column(new CheckboxCell(true,false)) { + + @Override + public Boolean getValue(Resource object) { + return object.isSelected(); + } + + @Override + public void onBrowserEvent(Cell.Context context, final Element parent, final Resource user, NativeEvent event) { + event.preventDefault(); + + if(!"change".equals(event.getType())) + return; + + user.setSelected(!user.isSelected()); + + // update checked elements + checkedResourcesNumber = user.isSelected() ? checkedResourcesNumber + 1 : checkedResourcesNumber - 1; + + // deselect the father + if(checkedResourcesNumber == 0) + checkBoxSubfunctionality.setValue(false, true); + else + checkBoxSubfunctionality.setValue(true, true); + + // refresh data + dataProvider.refresh(); + } + }; + table.addColumn(chosenColumn, "Select"); + + // Add a text column to show the name (and make it sortable) + TextColumn nameColumn = new TextColumn() { + @Override + public String getValue(Resource object) { + return object.getName(); + } + }; + + ListHandler nameColHandler = new ListHandler(dataProvider.getList()); + nameColHandler.setComparator(nameColumn, new Comparator() { + + public int compare(Resource o1, Resource o2) { + + return o1.getName().compareTo(o2.getName()); + + } + }); + nameColumn.setSortable(true); + nameColumn.setDefaultSortAscending(false); + table.addColumnSortHandler(nameColHandler); + table.addColumn(nameColumn, "Name"); + + // Add a date column to show the description (and make it sortable) + TextColumn descColumn = new TextColumn() { + @Override + public String getValue(Resource object) { + return object.getDescription(); + } + + @Override + public void render(Context context, Resource object, + SafeHtmlBuilder sb) { + + // keep the first 120 chars + boolean trunk = object.getDescription().length() > 120; + String toShow = trunk ? object.getDescription().substring(0, 120) : object.getDescription(); + HTML htmlDescription; + String randomPar = Document.get().createUniqueId(); + + // escape full description + String escapedFullDescription = object.getDescription().replaceAll("'", ""); + escapedFullDescription = escapedFullDescription.replaceAll("\"", ""); + + if(trunk) + htmlDescription = new HTML("

" + toShow + "..." + + "See more" + + "

"); + else + htmlDescription = new HTML("

" + toShow + "

"); + + sb.appendHtmlConstant(htmlDescription.getHTML()); + } + + }; + ListHandler descColHandler = new ListHandler(dataProvider.getList()); + descColHandler.setComparator(descColumn, new Comparator() { + + public int compare(Resource o1, Resource o2) { + + return o1.getDescription().compareTo(o2.getDescription()); + + } + }); + descColumn.setSortable(true); + table.addColumnSortHandler(descColHandler); + table.addColumn(descColumn, "Description"); + + // sort by columnName + table.getColumnSortList().push(nameColumn); + + // set width column chosen + table.setColumnWidth(chosenColumn, 60, Unit.PX); + + // control panel + FlowPanel controlPanel = new FlowPanel(); + + // set buttons information + showAllButton.setText("Show all resources"); + showAllButton.addStyleName("show-all-resources-button"); + showAllButton.setTitle("Show all resources"); + selectAllRows.setText("Select all resources"); + selectAllRows.setTitle("Select all resources of the table"); + + // show all button handler + addShowButtonsHandler(); + addselectAllRowsHandler(checkBoxSubfunctionality); + + // add it if the number of rows is larger wrt the page size + if(resources.size() > MAX_ROW_TO_SHOW_BEGINNING){ + controlPanel.add(showAllButton); + + } + + // add the select all rows if there are resources + if(resources.size() > 0){ + controlPanel.add(selectAllRows); + } + + mainPanel.add(controlPanel); + + // pager for pagination + SimplePager pager = new SimplePager(TextLocation.RIGHT); + pager.setPageSize(MAX_ROW_TO_SHOW_BEGINNING); + pager.setDisplay(table); + pager.getElement().getStyle().setMarginTop(20, Unit.PX); + mainPanel.add(pager); + + // add the table + mainPanel.add(table); + } + + /** + * Add handlers for selectAllRowsButtons + * @param checkBoxSubfunctionality + */ + private void addselectAllRowsHandler(final CheckBox checkBoxSubfunctionality) { + + // add handlers on selection + selectAllRows.addClickHandler(new ClickHandler() { + + public void onClick(ClickEvent event) { + + List currentList = dataProvider.getList(); + + if(!allRowsSelected){ + for(Resource resource: currentList) + resource.setSelected(true); + + allRowsSelected = true; + selectAllRows.setText("Deselect all resources"); + selectAllRows.setTitle("Deselect all resources of the table"); + + // check the father as well + checkBoxSubfunctionality.setValue(true, true); + + // update checked elements + checkedResourcesNumber = dataProvider.getList().size(); + + }else{ + for(Resource resource: currentList) + resource.setSelected(false); + + allRowsSelected = false; + selectAllRows.setText("Select all resources"); + selectAllRows.setTitle("Select all resources of the table"); + + // update checked elements + checkedResourcesNumber = dataProvider.getList().size(); + + // uncheck the father as well + checkBoxSubfunctionality.setValue(false, true); + } + + // refresh view + dataProvider.refresh(); + } + }); + } + + /** + * Add handlers to show buttons + */ + private void addShowButtonsHandler() { + + showAllButton.addClickHandler(new ClickHandler() { + + public void onClick(ClickEvent event) { + + boolean visibleAllActive = table.getVisibleRange().getLength() == dataProvider.getList().size(); + + if(visibleAllActive){ + + // switch back to pagination + table.setVisibleRange(new Range(0, MAX_ROW_TO_SHOW_BEGINNING)); + + showAllButton.setText("Show all resources"); + + }else{ + + // show all rows + table.setVisibleRange(new Range(0, dataProvider.getList().size())); + + // change text + showAllButton.setText("Switch to pagination"); + + } + } + }); + } + + /** + * Search on click + * @param event + * @param isFilteringEnabledReference + */ + private void searchOnClickEvent(ClickEvent event, + boolean[] isFilteringEnabledReference) { + + if(isFilteringEnabledReference[0]){ + // change icon style + searchButton.setIcon(IconType.SEARCH); + searchBox.setText(""); + isFilteringEnabledReference[0] = false; + + // show all data + dataProvider.setList(originalResources); + table.setVisibleRange(new Range(0, MAX_ROW_TO_SHOW_BEGINNING)); + table.setRowCount(dataProvider.getList().size(), true); + dataProvider.refresh(); + + }else{ + if(!searchBox.getText().isEmpty()){ + + // current filter + String filter = searchBox.getText(); + + // get current data + List currentList = dataProvider.getList(); + + // the list to show + List toShow = new ArrayList(); + + for(Resource resource : currentList) { + + // lower case + String nameLowerCase = resource.getName().toLowerCase(); + String filterLowerCase = filter.toLowerCase(); + + if(nameLowerCase.contains(filterLowerCase)) + toShow.add(resource); + + } + + dataProvider.setList(toShow); + table.setVisibleRange(new Range(0, MAX_ROW_TO_SHOW_BEGINNING)); + table.setRowCount(dataProvider.getList().size(), true); + dataProvider.refresh(); + + // change icon style + searchButton.setIcon(IconType.REMOVE_SIGN); + searchButton.setTitle("Remove search"); + isFilteringEnabledReference[0] = true; + } + + } + + } + + /** + * Search on key ENTER press + * @param event + */ + private void searchOnKeyDown(KeyDownEvent event){ + + if(event.getNativeKeyCode() == KeyCodes.KEY_ENTER){ + + if(!searchBox.getText().isEmpty()){ + + // current filter + String filter = searchBox.getText(); + + // get current data + List currentList = dataProvider.getList(); + + // the list to show + List toShow = new ArrayList(); + + for(Resource resource : currentList) { + + // lower case + String nameLowerCase = resource.getName().toLowerCase(); + String filterLowerCase = filter.toLowerCase(); + + if(nameLowerCase.contains(filterLowerCase)) + toShow.add(resource); + + } + + dataProvider.setList(toShow); + table.setVisibleRange(new Range(0, MAX_ROW_TO_SHOW_BEGINNING)); + table.setRowCount(dataProvider.getList().size(), true); + dataProvider.refresh(); + + }else{ + + // show all data + dataProvider.setList(originalResources); + table.setVisibleRange(new Range(0, MAX_ROW_TO_SHOW_BEGINNING)); + table.setRowCount(dataProvider.getList().size(), true); + dataProvider.refresh(); + + } + } + } +} diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/SummaryPanel.java b/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/SummaryPanel.java new file mode 100644 index 0000000..39f3ed7 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/SummaryPanel.java @@ -0,0 +1,79 @@ +package org.gcube.portlets.admin.vredefinition.client.ui; + +import java.util.Date; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.i18n.client.DateTimeFormat; +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.InlineLabel; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwt.user.client.ui.Widget; + +public class SummaryPanel extends Composite{ + + private static SummaryPanelUiBinder uiBinder = GWT + .create(SummaryPanelUiBinder.class); + + interface SummaryPanelUiBinder extends UiBinder { + } + + @UiField + InlineLabel vreNameSummary; + @UiField + InlineLabel vreDesignerSummary; + @UiField + InlineLabel vreManagerSummary; + @UiField + InlineLabel vreFromSummary; + @UiField + InlineLabel vreToSummary; + @UiField + InlineLabel vreDescriptionSummary; + @UiField + VerticalPanel functionalities; + + public SummaryPanel() { + initWidget(uiBinder.createAndBindUi(this)); + } + + /** + * Set vre's main information + * @param name + * @param manager + * @param designer + * @param description + * @param from + * @param to + */ + public void setVreMainInformation(String name, String manager, String designer, String description, Date from, Date to){ + + vreNameSummary.setText(name); + vreDesignerSummary.setText(designer); + vreManagerSummary.setText(manager); + vreDescriptionSummary.setText(description); + + // format date in dd/mm/yy + DateTimeFormat formatter = DateTimeFormat.getFormat("dd.MM.yyyy");// new DateTimeFormat("dd.MM.yyyy"); + vreFromSummary.setText(formatter.format(from)); + vreToSummary.setText(formatter.format(to)); + + } + + /** + * Add the functionalities tree + * @param w + */ + public void addFunctionality(Widget w){ + functionalities.add(w); + } + + /** + * Remove the functionalities tree + * @param w + */ + public void clearFunctionalitiesPanel() { + functionalities.clear(); + } +} diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/SummaryPanel.ui.xml b/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/SummaryPanel.ui.xml new file mode 100644 index 0000000..0fefd0e --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/SummaryPanel.ui.xml @@ -0,0 +1,50 @@ + + + + .bold { + font-weight: bold; + } + + +

Summary

+ + +

VRE description

+ +

+ VRE Name: + +

+

+ VRE Designer: + +

+

+ VRE Manager: + +

+ +

+ From: + + + To: + + +

+

+ Description: + +

+ +
+ + +

VRE chosen functionalities

+ + +
+ +
+
\ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/VRECreationFormSkeleton.java b/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/VRECreationFormSkeleton.java new file mode 100644 index 0000000..fce007f --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/VRECreationFormSkeleton.java @@ -0,0 +1,304 @@ +package org.gcube.portlets.admin.vredefinition.client.ui; + +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import com.github.gwtbootstrap.client.ui.HelpInline; +import com.github.gwtbootstrap.client.ui.Image; +import com.github.gwtbootstrap.client.ui.ListBox; +import com.github.gwtbootstrap.client.ui.Row; +import com.github.gwtbootstrap.client.ui.TextArea; +import com.github.gwtbootstrap.client.ui.TextBox; +import com.github.gwtbootstrap.datepicker.client.ui.DateBoxAppended; +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.event.dom.client.KeyPressEvent; +import com.google.gwt.event.dom.client.KeyPressHandler; +import com.google.gwt.event.logical.shared.ValueChangeEvent; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.uibinder.client.UiHandler; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.HasHorizontalAlignment; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwt.user.client.ui.Widget; + +public class VRECreationFormSkeleton extends Composite{ + + private static VRECreationFormSkeletonUiBinder uiBinder = GWT + .create(VRECreationFormSkeletonUiBinder.class); + + interface VRECreationFormSkeletonUiBinder extends + UiBinder { + } + + @UiField VerticalPanel vreFunctionalities; + @UiField DateBoxAppended vreFromDate; + @UiField DateBoxAppended vreToDate; + @UiField TextBox vreNameTextBox; + @UiField TextBox vreDesignerTextBox; + @UiField ListBox vreManagersListBox; + @UiField TextArea vreDescriptionTextArea; + + // error panels + @UiField HelpInline vreNameError; + @UiField HelpInline vreDescriptionError; + @UiField HelpInline vreDesignerError; + + // Path of the image to be shown during loading + public static final String imagePath = GWT.getModuleBaseURL() + "../images/statistics-loader.gif"; + + @SuppressWarnings("deprecation") + public VRECreationFormSkeleton() { + initWidget(uiBinder.createAndBindUi(this)); + + // update data vreToDate + Date end = vreFromDate.getValue(); + end.setYear(end.getYear() + 1); + + vreToDate.setValue(end); + } + + /** + * Append a functionality (it must be a Row object) + * @param child + */ + public void appendRow(Widget child){ + if(child.getClass().equals(Row.class)) + vreFunctionalities.add(child); + } + + @UiHandler("vreFromDate") + void ChangeHandlerStart(ValueChangeEvent event){ + + GWT.log("Change handler FROM"); + + // get current date + Date current = new Date(); + + // get selected date + Date selected = vreFromDate.getValue(); + + if(selected.compareTo(current) < 0) + vreFromDate.setValue(current); + + } + + @SuppressWarnings("deprecation") + @UiHandler("vreToDate") + void ChangeHandlerTo(ValueChangeEvent event){ + + GWT.log("Change handler TO"); + + // get current date start + Date start = vreFromDate.getValue(); + + // get selected date + Date selected = vreToDate.getValue(); + + if(selected.compareTo(start) < 0){ + + Date end = vreFromDate.getValue(); + end.setYear(end.getYear() + 1); + vreToDate.setValue(end); + + } + + } + + /** + * remove image loading + */ + public void removeLoader() { + + vreFunctionalities.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); + vreFunctionalities.clear(); + + } + + /** + * add a loading image + */ + public void showLoader() { + + vreFunctionalities.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); + vreFunctionalities.setWidth("100%"); + vreFunctionalities.add(new Image(imagePath)); + + } + + /** + * Return vre current name + * @return + */ + public String getCurrentVREName(){ + return vreNameTextBox.getText(); + } + + /** + * Return vre current designer + * @return + */ + public String getCurrentVREDesigner(){ + return vreDesignerTextBox.getText(); + } + + /** + * Return vre current manager + * @return + */ + public String getCurrentVREManager(){ + GWT.log("Selected manager is " + vreManagersListBox.getSelectedItemText()); + return vreManagersListBox.getSelectedItemText(); + } + + /** + * Return vre current description + * @return + */ + public String getCurrentVREDescription(){ + return vreDescriptionTextArea.getText(); + } + + /** + * Return vre current start date + * @return + */ + public Date getCurrentVREStartDate(){ + return vreFromDate.getValue(); + } + + /** + * Return vre current to date + * @return + */ + public Date getCurrentVREToDate(){ + return vreToDate.getValue(); + } + + /** + * Set the designer + * @param designer + */ + public void setVREDesigner(String designer){ + + vreDesignerTextBox.setText(designer); + + } + + /** + * Set the managers + * @param managers + * @param a selected manager among the list of managers + */ + public void setVREManagers(List managers, String selectedManager){ + + // sort the list first + Collections.sort(managers); + + for (String manager : managers) { + vreManagersListBox.addItem(manager); + } + + if(selectedManager != null) + vreManagersListBox.setSelectedValue(selectedManager); + } + + /** + * Alert on missing vre name + */ + public void showAlertBlockVREName() { + + vreNameError.setVisible(true); + vreNameTextBox.setFocus(true); // set focus + + vreNameTextBox.addKeyPressHandler(new KeyPressHandler() { + + public void onKeyPress(KeyPressEvent event) { + + vreNameError.setVisible(false); + + } + }); + + vreNameTextBox.addClickHandler(new ClickHandler() { + + public void onClick(ClickEvent event) { + + vreNameError.setVisible(false); + + } + }); + + } + + /** + * Alert on missing vre description + */ + public void showAlertBlockVREDescritption() { + + vreDescriptionError.setVisible(true); + vreDescriptionTextArea.setFocus(true); // set focus + + vreDescriptionTextArea.addKeyPressHandler(new KeyPressHandler() { + + public void onKeyPress(KeyPressEvent event) { + + vreDescriptionError.setVisible(false); + + } + }); + + vreDescriptionTextArea.addClickHandler(new ClickHandler() { + + public void onClick(ClickEvent event) { + + vreDescriptionError.setVisible(false); + + } + }); + + } + + /** + * Set the vre name + * @param vreName + */ + public void setVREName(String vreName) { + + vreNameTextBox.setText(vreName); + + } + + /** + * Set the vre description + * @param description + */ + public void setVREDescription(String description) { + + vreDescriptionTextArea.setText(description); + + } + + /** + * Start from vre date + * @param startDate + */ + public void setVREFromDate(Date startDate) { + + vreFromDate.setValue(startDate); + + } + + /** + * Start from vre date + * @param toDate + */ + public void setVREToDate(Date toDate) { + + vreToDate.setValue(toDate); + + } +} diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/VRECreationFormSkeleton.ui.xml b/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/VRECreationFormSkeleton.ui.xml new file mode 100644 index 0000000..07feaba --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/client/ui/VRECreationFormSkeleton.ui.xml @@ -0,0 +1,97 @@ + + + + .error { + color: red; + } + + +
+

VRE Information

+
+ + + + + + + Name: + + + + + + +

+ + + Designer: + + + + + + +

+ + + Managers: + + + + + + +

+ + + Description: + + + + + + + +

+ + + From: + + + + + +

+ + + To: + + + + + +
+
+
+ +
+ + + +
+
\ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/server/VREDefinitionServiceImpl.java b/src/main/java/org/gcube/portlets/admin/vredefinition/server/VREDefinitionServiceImpl.java new file mode 100644 index 0000000..2da5f69 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/server/VREDefinitionServiceImpl.java @@ -0,0 +1,663 @@ +package org.gcube.portlets.admin.vredefinition.server; + +import java.io.Serializable; +import java.rmi.RemoteException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.gcube.application.framework.core.session.ASLSession; +import org.gcube.application.framework.core.session.SessionManager; +import org.gcube.application.framework.vremanagement.vremanagement.impl.VREGeneratorEvo; +import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager; +import org.gcube.applicationsupportlayer.social.NotificationsManager; +import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite; +import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser; +import org.gcube.common.homelibrary.home.HomeLibrary; +import org.gcube.common.homelibrary.home.workspace.Workspace; +import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; +import org.gcube.portlets.admin.vredefinition.client.VREDefinitionService; +import org.gcube.portlets.admin.vredefinition.shared.Functionality; +import org.gcube.portlets.admin.vredefinition.shared.Resource; +import org.gcube.portlets.admin.vredefinition.shared.ResourceCategory; +import org.gcube.portlets.admin.vredefinition.shared.VREDescriptionBean; +import org.gcube.portlets.admin.vredefinition.shared.exception.VREDefinitionException; +import org.gcube.vomanagement.usermanagement.RoleManager; +import org.gcube.vomanagement.usermanagement.UserManager; +import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager; +import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; +import org.gcube.vomanagement.usermanagement.model.GCubeUser; +import org.gcube.vremanagement.vremodel.cl.stubs.types.FunctionalityItem; +import org.gcube.vremanagement.vremodel.cl.stubs.types.ResourceDescriptionItem; +import org.gcube.vremanagement.vremodel.cl.stubs.types.ResourceItem; +import org.gcube.vremanagement.vremodel.cl.stubs.types.SelectedResourceDescriptionType; +import org.gcube.vremanagement.vremodel.cl.stubs.types.VREDescription; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gwt.user.server.rpc.RemoteServiceServlet; +import com.liferay.portal.service.UserLocalServiceUtil; + +/** + * The VREDefinitionServiceImpl class. + * @author Costantino Perciante at ISTI-CNR + * (costantino.perciante@isti.cnr.it) + */ +public class VREDefinitionServiceImpl extends RemoteServiceServlet implements VREDefinitionService{ + + private static final long serialVersionUID = -7581858549584810224L; + + // Logger + private static final Logger logger = LoggerFactory.getLogger(VREDefinitionServiceImpl.class); + + // some usefull constants + private static final String DESIGNER = "Designer"; + private static final String MANAGER = "Manager"; + private static final String DESCRIPTION = "DESCRIPTION"; + private static final String VRE_MANAGER_STRING = "VRE-Manager"; + private static final String VRE_DEFINER_GENERATOR_ATTRIBUTE = "VREDefinerGenerator"; + private static final String VRE_GENERATOR_ATTRIBUTE = "VREGenerator"; + private static final String REEDIT_TYPE_ATTRIBUTE = "reeditType"; + private static final String EDIT_MODE = "edit"; + private static final String APPROVE_MODE = "approve"; + private static final String VRE_NAME_FIELD = "vreName"; + private static final String VRE_MANAGER_FIELD = "vreManager"; + private static final String VRE_DESIGNER_FIELD = "vreDesigner"; + private static final String VRE_DESCRIPTION_FIELD = "vreDescription"; + private static final String VRE_START_TIME_FIELD = "vreStartTime"; + private static final String VRE_END_TIME_FIELD = "vreEndTime"; + + //dev user + public static final String defaultUserId = "test.user"; + + //dev vo + private static final String voID = "/gcube/devsec"; + + @Override + public void init() { + + logger.debug("Servlet init"); + } + + @Override + public void destroy(){ + + logger.debug("Servlet destroyed"); + + } + + /** + * the current ASLSession + * @return the session + */ + private ASLSession getASLSession() { + + String sessionID = this.getThreadLocalRequest().getSession().getId(); + String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE); + + if (user == null) { + + logger.warn("USER IS NULL setting " + defaultUserId + " and Running OUTSIDE PORTAL"); + user = getDevelopmentUser(); + SessionManager.getInstance().getASLSession(sessionID, user).setScope(voID); + SessionManager.getInstance().getASLSession(sessionID, user).setAttribute(REEDIT_TYPE_ATTRIBUTE, APPROVE_MODE); + + } + + return SessionManager.getInstance().getASLSession(sessionID, user); + } + + /** + * Online or in development mode? + * @return true if you're running into the portal, false if in development + */ + private boolean isWithinPortal() { + try { + UserLocalServiceUtil.getService(); + return true; + } + catch (com.liferay.portal.kernel.bean.BeanLocatorException ex) { + logger.trace("Development Mode ON"); + return false; + } + } + + /** + * when packaging test will fail if the user is not set to test.user + * @return . + */ + public String getDevelopmentUser() { + String user = defaultUserId; + // user = "costantino.perciante"; + return user; + } + + /** + * When the portlet starts, this method is invoked in order to return + * 1) vre managers for the current VO + * 2) the current designer (that is the current user) + * 3) a VREDefinitionBean that will be filled somehow by the designer + */ + public Map getVRE() { + + logger.debug("########### INVOKED getVRE() METHOD ###########"); + + Map toReturn = new HashMap(); + + // retrieve the session + ASLSession session = getASLSession(); + + // username + String username = session.getUsername(); + + // check if development mode or portal + if(!isWithinPortal()){ + + logger.debug("You are in dev mode"); + return getFakeVreDefinition(); + + }else{ + + // check if we are in edit mode or not + boolean editMode = isEditMode(); + + logger.debug("EDIT MODE IS " + editMode); + + // put this information in the returned hashmap + toReturn.put(EDIT_MODE, editMode); + + try{ + + // user and role managers + UserManager um = new LiferayUserManager(); + RoleManager rm = new LiferayRoleManager(); + + // current org id of the vo + long voOrgID = getASLSession().getGroupId(); + long roleId = rm.getRoleId(VRE_MANAGER_STRING, getASLSession().getGroupId()); + + logger.debug(VRE_MANAGER_STRING + " has role id " + roleId + " into organization " + voOrgID); + + logger.debug("Trying to get roleid of " + VRE_MANAGER_STRING + " into " + getASLSession().getGroupName()); + + List belongingUsers = um.listUsersByGroupAndRole(voOrgID, roleId); + + logger.debug("Number of managers is " + belongingUsers.size()); + + ArrayList managers = new ArrayList(); + for (int i = 0; i < belongingUsers.size(); i++) { + + managers.add(belongingUsers.get(i).getFullname()+" ("+belongingUsers.get(i).getUsername()+")"); + + } + toReturn.put(MANAGER, managers); + logger.debug("Managers set as " + managers); + + // set the designer + String fullName = um.getUserByUsername(username).getFullname(); + toReturn.put(DESIGNER, fullName+" ("+username+")"); + logger.debug("Designer set as " + fullName+" ("+username+")"); + + // in edit mode we need to retrieve the selected manager as well as other vre info + if(editMode){ + + try{ + + VREDescriptionBean vreBean = getVREInSession(); + if(vreBean != null) { + toReturn.put(VRE_NAME_FIELD,vreBean.getName()); + toReturn.put(VRE_MANAGER_FIELD, vreBean.getManager()); + toReturn.put(VRE_DESIGNER_FIELD, fullName+" ("+vreBean.getDesigner()+")"); // should be equal to DESIGNER + toReturn.put(VRE_DESCRIPTION_FIELD, vreBean.getDescription()); + toReturn.put(VRE_START_TIME_FIELD, vreBean.getStartTime()); + toReturn.put(VRE_END_TIME_FIELD, vreBean.getEndTime()); + } + + }catch(Exception e){ + logger.error("Error while retrieving vre description bean", e); + } + + } + + }catch(Exception e){ + logger.error("Error while retrieving vre information", e); + } + + } + + return toReturn; + } + + /** + * Generate random data + * @return + */ + private Map getFakeVreDefinition() { + + Map toReturn = new HashMap(); + ArrayList managers = new ArrayList(); + managers.add("Pasquale Pagano (pasquale.pagano)"); + managers.add("Andrea Manzi (andrea.manzi)"); + managers.add("Massimiliano Assante (massimiliano.assante)"); + toReturn.put(MANAGER, managers); + + // designer + toReturn.put(DESIGNER, "Leonardo Candela (leonardo.candela)"); + + // check if we are in edit mode or not + boolean editMode = isEditMode(); + + // put this information in the returned hashmap + toReturn.put(EDIT_MODE, editMode); + + if(editMode){ + try { + VREDescriptionBean vreBean = getVREInSession(); + if(vreBean != null) { + logger.debug(" ########### VRE != NULL ##########"); + logger.debug("Bean is " + vreBean); + toReturn.put(VRE_NAME_FIELD,vreBean.getName()); + toReturn.put(VRE_MANAGER_FIELD, vreBean.getManager()); + toReturn.put(VRE_DESIGNER_FIELD, vreBean.getDesigner()); + toReturn.put(VRE_DESCRIPTION_FIELD, vreBean.getDescription()); + toReturn.put(VRE_START_TIME_FIELD, vreBean.getStartTime().getTime()); + toReturn.put(VRE_END_TIME_FIELD, vreBean.getEndTime().getTime()); + } + } catch (Exception e1){ + logger.error("Missing definition bean..."); + } + } + return toReturn; + } + + /** + * Retrieve the VREDescriptionBean from the session if possible + * @return + * @throws VREDefinitionException + */ + private VREDescriptionBean getVREInSession() throws VREDefinitionException { + VREGeneratorEvo vreGenerator = getVREGenerator(); + + VREDescriptionBean vreDescBean = null; + try { + VREDescription sd = vreGenerator.getVREModel(); + vreDescBean = new VREDescriptionBean(sd.name(), sd.description(), + sd.designer(), sd.manager(), sd.startTime().getTime(), sd.endTime().getTime()); + + } catch (RemoteException e) { + throw new VREDefinitionException("Fail retrieve VRE"); + } + + logger.debug("Model retrieved is " + vreDescBean); + return vreDescBean; + } + + /** + * The VREGenerator is needed to retrieve VRE Bean information + * @return + */ + private VREGeneratorEvo getVREGenerator(){ + ASLSession d4ScienceSession = getASLSession(); + VREGeneratorEvo vreGenerator = (VREGeneratorEvo) d4ScienceSession.getAttribute(VRE_DEFINER_GENERATOR_ATTRIBUTE); + + // if there is not..add it + if(vreGenerator == null){ + logger.debug("There is no VREGeneratorEvo in the session, adding it.."); + vreGenerator = new VREGeneratorEvo(d4ScienceSession); + d4ScienceSession.setAttribute(VRE_DEFINER_GENERATOR_ATTRIBUTE, vreGenerator); + } + return vreGenerator; + } + + /** + * Check if we are in edit mode or not + * @return + */ + private boolean isEditMode(){ + + logger.debug("Checking if we are in edit mode..."); + + // retrieve current session + ASLSession session = getASLSession(); + + // get this attribute + String reeditType = (String)session.getAttribute(REEDIT_TYPE_ATTRIBUTE); + + // set to null the VRE_DEFINER_GENERATOR_ATTRIBUTE + session.setAttribute(VRE_DEFINER_GENERATOR_ATTRIBUTE, null); + + // if the reeditType is actually edit + if(reeditType != null && reeditType.equals(EDIT_MODE)) { + + // retrieve the vreid (of the vre to be changed) + String vreid = (String) session.getAttribute(VRE_GENERATOR_ATTRIBUTE); + + if(vreid != null){ + + // put the generator in session + VREGeneratorEvo vreGenerator = new VREGeneratorEvo(session, vreid); + session.setAttribute(VRE_DEFINER_GENERATOR_ATTRIBUTE, vreGenerator); + + } + + // set to null the attribute REEDIT_TYPE_ATTRIBUTE + session.setAttribute(REEDIT_TYPE_ATTRIBUTE, null); + + return true; + } + + return false; + } + + /** + * {@inheritDoc} + */ + public ArrayList getFunctionality(boolean isEdit) + throws VREDefinitionException { + /* + * if i am creating a new Vre I need to 'pretend' I already set the description to the service otherwise VREModeler won't return me the collections + * if is editing instead this is not necessary + */ + if (!isEdit) { + Calendar cal= Calendar.getInstance(); + long startTime = cal.getTimeInMillis(); + cal.add(Calendar.MONTH, 5); + cal.add(Calendar.HOUR, 7); + long endTime = cal.getTimeInMillis(); + try { + //a useless setVREModel() is needed to retrieve functionalities.... + getVREGenerator().setVREModel("notCompletedVirtualResearchEnv.", UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), startTime, endTime); + Thread.sleep(1000); // wait a sec + } catch (Exception e) { + logger.error("Error on setVREModel()", e); + } + } + + // if the service is not ready, return null + if (!getVREGenerator().isVreModelerServiceUp()) + return null; + + // build up the list of functionalities + List toReturn = new ArrayList(); + + try{ + + // get the list of main functionalities + List listMainFunctionalities = getVREGenerator().getFunctionality(); + + if(listMainFunctionalities != null && !listMainFunctionalities.isEmpty()){ + + // for each functionality + for (FunctionalityItem functionalityItem : listMainFunctionalities) { + + logger.debug("Reading FunctionalityItem with id:" + functionalityItem.id() + " and name " + functionalityItem.name()); + + // add it to the returning list + Functionality mainFunctionality = new Functionality(functionalityItem.id(), functionalityItem.name(), functionalityItem.description(), functionalityItem.selected()); + toReturn.add(mainFunctionality); + + // scan its children (if any) + if(functionalityItem.children() == null || functionalityItem.children().isEmpty()){ + logger.debug(functionalityItem.name() + " has no children."); + } + else{ + // get its children + List childrenFunctionalities = functionalityItem.children(); + + // subfunctionalities of our model + List subFunctionalities = new ArrayList(); + + // for each subfunctionality + for(FunctionalityItem childFunctionality: childrenFunctionalities){ + + logger.debug("Reading child FunctionalityItem " + childFunctionality.name() + " of node " + functionalityItem.name()); + Functionality subFunctionality = new Functionality(childFunctionality.id(), childFunctionality.name(), childFunctionality.description(), childFunctionality.selected()); + + // this subfunctionality could have resource categories + List resourcesDescriptionItems = childFunctionality.selectableResourcesDescription(); + + if(resourcesDescriptionItems != null && !resourcesDescriptionItems.isEmpty()){ + + // categories of our model + List categories = new ArrayList(); + + for (ResourceDescriptionItem resourceDescriptionItem : resourcesDescriptionItems) { + logger.debug("Reading ResourceDescriptionItem " + resourceDescriptionItem.description() + " of functionality " + childFunctionality.name()); + + // resource category list + List resourceItems = resourceDescriptionItem.resources(); + + if(resourceItems != null && !resourceItems.isEmpty()){ + + ResourceCategory rc = new ResourceCategory(resourceDescriptionItem.id(), resourceDescriptionItem.description()); + List resourceModels = new ArrayList(); + for (ResourceItem resource : resourceDescriptionItem.resources()) { + logger.debug("Reading resource " + resource.name() + " of ResourceDescriptionItem " + resourceDescriptionItem.description()); + resourceModels.add(new Resource(resource.id(), resource.name(), resource.description(), resource.selected())); + + } + + // set resources for this category + rc.setItems((ArrayList) resourceModels); + + // append the resource category to categories + categories.add(rc); + } + } + + // append this resources to the child functionality + subFunctionality.setResources(categories); + + } + + // add this subfunctionality to our functionality list + subFunctionalities.add(subFunctionality); + + } + + // add the subfunctionalities to the main functionality + mainFunctionality.setSubFunctionalities(subFunctionalities); + + } + + } + } + + }catch(Exception e){ + logger.error("Error while retrieving the list of functionalities", e); + return null; + } + + // return the list of functionalities + return (ArrayList)toReturn; + } + + /** + * Set the vre functionalities and resources it will use. + * @param functionalities + * @return true on success, false otherwise + */ + private boolean setFunctionalities(List functionalities){ + + //filling up + ArrayList toSend = new ArrayList(); + + // we need a list of checked subfunctionalities' ids + ArrayList subfunctionalitiesIDS = new ArrayList(); + + // iterate over the macro functionalities + for(Functionality macroFunctionality : functionalities){ + + logger.debug("Scanning macro functionality " + macroFunctionality.getName()); + + // retrieve its direct children + List subfunctionalities = macroFunctionality.getSubFunctionalities(); + + // iterate + for (Functionality subfunctionality : subfunctionalities) { + + logger.debug("Scanning sub functionality " + subfunctionality.getName()); + + if(subfunctionality.isSelected()){ + + logger.debug("This subfunctionality was selected"); + + // save its id + subfunctionalitiesIDS.add(subfunctionality.getId()); + + // retrieve its children list + List categories = subfunctionality.getResources(); + + if(categories != null){ + + for(ResourceCategory category : categories){ + + // get the description id + String descriptionId = category.getId(); + + // get its resources + ArrayList resources = category.getItems(); + + // list of ids for resources + ArrayList resourceIds = new ArrayList(); + + if(resources != null){ + + logger.debug("Scanning resources of " + subfunctionality.getName()); + + for (Resource resource : resources) { + + if(resource.isSelected()){ + + logger.debug("Resource of " + resource.getName() + " was selected by the user"); + + // add its id + resourceIds.add(resource.getId()); + } + + } + } + + SelectedResourceDescriptionType toAdd = new SelectedResourceDescriptionType(); + toAdd.descriptionId(descriptionId); + toAdd.resourceIds(resourceIds); + toSend.add(toAdd); + } + + } + + } + } + } + + // convert to array + Integer funcIdAsInts[] = subfunctionalitiesIDS.toArray(new Integer[subfunctionalitiesIDS.size()]); + + // convert to array + SelectedResourceDescriptionType[] selres = toSend.toArray(new SelectedResourceDescriptionType[toSend.size()]); + logger.debug("SelectedResourceDescriptionType[] Sending to Service .... toSend size = " + toSend.size()); + for (int i = 0; i < selres.length; i++) { + logger.debug("SelectedResourceDescriptionType DESC: " + selres[i].getDescriptionId()); + for (int j = 0; j < selres[i].resourceIds().size(); j++) { + logger.debug("resid= " +selres[i].resourceIds().get(j)); + } + } + + // save the above information + VREGeneratorEvo vreGenerator = getVREGenerator(); + try { + vreGenerator.setFunctionality(funcIdAsInts, selres); + vreGenerator.setVREtoPendingState(); + return true; + } catch (RemoteException e) { + logger.error("An error arises", e); + return false; + } + } + + /** + * {@inheritDoc} + */ + public boolean setVRE(VREDescriptionBean bean, + ArrayList functionalities) + throws VREDefinitionException { + + // retrieve information from the description bean + String completeDesigner = bean.getDesigner(); + bean.setDesigner(extractUserName(completeDesigner)); + String managerUserName = extractUserName(bean.getManager()); + bean.setManager(managerUserName); + + // set this description bean + setVREDescription(bean); + + // save this functionalities + setFunctionalities(functionalities); + try { + getVREGenerator().setVREtoPendingState(); + + getASLSession().setAttribute(VRE_DEFINER_GENERATOR_ATTRIBUTE, null); + Workspace workspace = HomeLibrary.getUserWorkspace(getASLSession().getUsername()); + ArrayList toSend = new ArrayList(); + toSend.add(managerUserName); + String subject = "New VRE Definition requires your approval"; + String body = "Dear Manager, \n\n" + completeDesigner + " has created a VRE Definition indicating you as VRE Manager on " + getASLSession().getScope(); + body+=".\n\nThe VRE Name is: " + bean.getName() +", the VRE Description is: " + bean.getDescription()+"."; + String messagedId = workspace.getWorkspaceMessageManager().sendMessageToPortalLogins(subject, body, new ArrayList(), toSend); + + ASLSession session = getASLSession(); + SocialNetworkingUser user = new SocialNetworkingUser(session.getUsername(), session.getUserEmailAddress(), session.getUserFullName(), session.getUserAvatarId()); + NotificationsManager nnm = new ApplicationNotificationsManager(new SocialNetworkingSite(getThreadLocalRequest()), session.getScope(), user); + + if (nnm.notifyMessageReceived(managerUserName, messagedId, subject, body)) + logger.trace("Sending VRE Definition create notification: " + subject + " OK"); + + + return true; + } catch (Exception e) { + logger.error("Error while creating the new VRE ", e); + } + return false; + } + + /** + * Set the bean within the session + * @param bean + * @return + * @throws VREDefinitionException + */ + private String setVREDescription(VREDescriptionBean bean) throws VREDefinitionException { + VREGeneratorEvo vreGenerator = getVREGenerator(); + ASLSession d4ScienceSession = getASLSession(); + d4ScienceSession.setAttribute(VRE_NAME_FIELD, bean.getName()); + d4ScienceSession.setAttribute(DESCRIPTION, bean.getDescription()); + d4ScienceSession.setAttribute(DESIGNER, bean.getDesigner()); + d4ScienceSession.setAttribute(MANAGER, bean.getManager()); + try { + vreGenerator.setVREModel(bean.getName(), bean.getDescription(), bean.getDesigner(), + bean.getManager(), bean.getStartTime().getTime() , bean.getEndTime().getTime()); + } catch (RemoteException e) { + logger.error("An error arises", e); + throw new VREDefinitionException("Set Description Error"); + } + + return null; + } + + /** + * The original format looks like Clark Kent (clark.kent) and we need the name within brackets + * @param toExtract + * @return + */ + private String extractUserName(String toExtract) { + int openBracket = toExtract.indexOf("(")+1; + int closeBracket = toExtract.indexOf(")"); + String toReturn = toExtract.substring(openBracket, closeBracket); + logger.debug("Extracted username is " + toReturn); + return toReturn; + } +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/server/portlet/VREDefinitionPortlet.java b/src/main/java/org/gcube/portlets/admin/vredefinition/server/portlet/VREDefinitionPortlet.java new file mode 100644 index 0000000..1016430 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/server/portlet/VREDefinitionPortlet.java @@ -0,0 +1,25 @@ +package org.gcube.portlets.admin.vredefinition.server.portlet; +import java.io.IOException; + +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.GenericPortlet; +import javax.portlet.PortletException; +import javax.portlet.PortletRequestDispatcher; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; + +import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; + +public class VREDefinitionPortlet extends GenericPortlet { + public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { + response.setContentType("text/html"); + ScopeHelper.setContext(request); + PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/VREDefinition_view.jsp"); + dispatcher.include(request, response); + } + + public void processAction(ActionRequest request, ActionResponse response) + throws PortletException, IOException { + } +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/shared/Functionality.java b/src/main/java/org/gcube/portlets/admin/vredefinition/shared/Functionality.java new file mode 100644 index 0000000..0dcdb6d --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/shared/Functionality.java @@ -0,0 +1,93 @@ +package org.gcube.portlets.admin.vredefinition.shared; + +import java.io.Serializable; +import java.util.List; + +/** + * A functionality class element. + * @author Costantino Perciante at ISTI-CNR + * (costantino.perciante@isti.cnr.it) + */ +@SuppressWarnings("serial") +public class Functionality implements Serializable{ + + private List subFunctionalities; // For Base Functionalities: Authorization.. + private int id; + private List resourceCategories; // For Occurrence and Taxonomic (under BiolCube): Data Discovery/BrazilianFlora for instance + private String description; + private String name; + private boolean selected; // if this object has subFunctionalities and it is selected, they are automatically checked, but + // resources must be manually checked. + + /** + * needed for serialization + */ + public Functionality() { + super(); + } + + /** + * @param subFunctionalities + * @param description + * @param name + */ + public Functionality(int id, String description, String name) { + super(); + this.id = id; + this.description = description; + this.name = name; + } + + public Functionality(int id, String name, String description, boolean selected) { + super(); + this.id = id; + this.description = description; + this.name = name; + this.selected = selected; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + public List getSubFunctionalities() { + return subFunctionalities; + } + public void setSubFunctionalities(List subFunctionalities) { + this.subFunctionalities = subFunctionalities; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public List getResources() { + return resourceCategories; + } + public void setResources(List resourceCategories) { + this.resourceCategories = resourceCategories; + } + public boolean isSelected() { + return selected; + } + public void setSelected(boolean selected) { + this.selected = selected; + } + @Override + public String toString() { + return "Functionality [subFunctionalities=" + subFunctionalities + + ", id=" + id + ", resources=" + resourceCategories + ", description=" + + description + ", name=" + name + ", selected=" + selected + + "]"; + } +} diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/shared/Resource.java b/src/main/java/org/gcube/portlets/admin/vredefinition/shared/Resource.java new file mode 100644 index 0000000..a95a50d --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/shared/Resource.java @@ -0,0 +1,68 @@ +package org.gcube.portlets.admin.vredefinition.shared; + +import java.io.Serializable; + +/** + * A resource class element. + * @author Costantino Perciante at ISTI-CNR + * (costantino.perciante@isti.cnr.it) + * + */ +@SuppressWarnings("serial") +public class Resource implements Serializable{ + + private String id; + private String name; + private String description; + private boolean selected; + + /** + * needed for serialization + */ + public Resource() { + super(); + } + + /** + * @param id + * @param name + * @param description + * @param selected + */ + public Resource(String id, String name, String description, boolean selected) { + super(); + this.id = id; + this.name = name; + this.description = description; + this.selected = selected; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public boolean isSelected() { + return selected; + } + public void setSelected(boolean selected) { + this.selected = selected; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + @Override + public String toString() { + return "Resource [id=" + id + ", name=" + name + ", description=" + + description + ", selected=" + selected + "]"; + } +} diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/shared/ResourceCategory.java b/src/main/java/org/gcube/portlets/admin/vredefinition/shared/ResourceCategory.java new file mode 100644 index 0000000..c74444c --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/shared/ResourceCategory.java @@ -0,0 +1,61 @@ +package org.gcube.portlets.admin.vredefinition.shared; + +import java.io.Serializable; +import java.util.ArrayList; + +/** + * A resource category class element. + * @author Costantino Perciante at ISTI-CNR + * (costantino.perciante@isti.cnr.it) + * + */ +@SuppressWarnings("serial") +public class ResourceCategory implements Serializable{ + + private String id; + private String name; + private ArrayList items; + + /** + * needed for serialization + */ + public ResourceCategory() { + super(); + } + + public ResourceCategory(String id, String name) { + super(); + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ArrayList getItems() { + return items; + } + + public void setItems(ArrayList items) { + this.items = items; + } + + @Override + public String toString() { + return "ResourceCategory [id=" + id + ", name=" + name + ", items=" + + items + "]"; + } +} diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/shared/VREDescriptionBean.java b/src/main/java/org/gcube/portlets/admin/vredefinition/shared/VREDescriptionBean.java new file mode 100644 index 0000000..821ddd4 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/shared/VREDescriptionBean.java @@ -0,0 +1,95 @@ +package org.gcube.portlets.admin.vredefinition.shared; + +import java.io.Serializable; +import java.util.Date; + +/** + * VREDescriptionBean + * @author Costantino Perciante at ISTI-CNR + * (costantino.perciante@isti.cnr.it) + * + */ +@SuppressWarnings("serial") +public class VREDescriptionBean implements Serializable{ + + private String name; + private String description; + private String designer; + private String manager; + private Date startTime; + private Date endTime; + + /** + * needed for serialization + */ + public VREDescriptionBean() { + super(); + } + + public VREDescriptionBean(String name, String description, String designer, + String manager, Date startTime, Date endTime) { + super(); + this.name = name; + this.description = description; + this.designer = designer; + this.manager = manager; + this.startTime = startTime; + this.endTime = endTime; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDesigner() { + return designer; + } + + public void setDesigner(String designer) { + this.designer = designer; + } + + public String getManager() { + return manager; + } + + public void setManager(String manager) { + this.manager = manager; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + @Override + public String toString() { + return "VREDescriptionBean [name=" + name + ", description=" + + description + ", designer=" + designer + ", manager=" + + manager + ", startTime=" + startTime + ", endTime=" + endTime + + "]"; + } +} diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/shared/exception/VREDefinitionException.java b/src/main/java/org/gcube/portlets/admin/vredefinition/shared/exception/VREDefinitionException.java new file mode 100644 index 0000000..7e675f2 --- /dev/null +++ b/src/main/java/org/gcube/portlets/admin/vredefinition/shared/exception/VREDefinitionException.java @@ -0,0 +1,27 @@ +package org.gcube.portlets.admin.vredefinition.shared.exception; + +/** + * VRE definition bean missing exception + * @author Costantino Perciante at ISTI-CNR + * (costantino.perciante@isti.cnr.it) + */ +public class VREDefinitionException extends Exception { + + private static final long serialVersionUID = -8266001298734768421L; + + // message to show + private String error; + + public VREDefinitionException(){ + + this.error = "VRE Definition Error :"; + } + + public VREDefinitionException(String message){ + this.error = message; + } + + public String getError() { + return this.error; + } +} diff --git a/src/main/resources/org/gcube/portlets/admin/vredefinition/VreDefinition.gwt.xml b/src/main/resources/org/gcube/portlets/admin/vredefinition/VreDefinition.gwt.xml new file mode 100644 index 0000000..7ae69be --- /dev/null +++ b/src/main/resources/org/gcube/portlets/admin/vredefinition/VreDefinition.gwt.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/gcube/portlets/admin/vredefinition/client/Messages_fr.properties b/src/main/resources/org/gcube/portlets/admin/vredefinition/client/Messages_fr.properties new file mode 100644 index 0000000..b4a7627 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/admin/vredefinition/client/Messages_fr.properties @@ -0,0 +1,2 @@ +sendButton = Envoyer +nameField = Entrez votre nom \ No newline at end of file diff --git a/src/main/webapp/VreDefinition.css b/src/main/webapp/VreDefinition.css new file mode 100644 index 0000000..447e2fd --- /dev/null +++ b/src/main/webapp/VreDefinition.css @@ -0,0 +1,56 @@ +.vre-definition-main-panel { + width: 100%; +} + +.vre-definition-elements-common-style { + margin-bottom: 10px !important; +} + +.select-deselect-button-style { + margin-top: -40px; + margin-left: 40px; + padding: 0 !important; +} + +.table-style { + margin-top: 10px; +} + +.filter-functionalities-box { + margin-top: 40px; + float: right; +} + +.subfunctionality-textbox { + font-size: 24px; +} + +.show-all-resources-button { + margin-right: 10px; +} + +.generate-summary-button { + float: right; +} + +.summary-buttons-panel { + float: right; +} + +.macrofunctionality-name-summary { + font-weight: bold; + text-decoration: underline; +} + +.subfunctionality-form { + margin-left: 40px !important; + margin-right: 40px !important; +} + +.button-margin-right { + margin-right: 10px; +} + +.icon-style { + color: #08c; +} \ No newline at end of file diff --git a/src/main/webapp/VreDefinition.html b/src/main/webapp/VreDefinition.html new file mode 100644 index 0000000..a3d83d2 --- /dev/null +++ b/src/main/webapp/VreDefinition.html @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + Web Application Starter Project + + + + + + + + + + + + + + + + + + + + + + +
+ + diff --git a/src/main/webapp/WEB-INF/jsp/VREDefinition_view.jsp b/src/main/webapp/WEB-INF/jsp/VREDefinition_view.jsp new file mode 100644 index 0000000..e4be1e8 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/VREDefinition_view.jsp @@ -0,0 +1,8 @@ +<%@page contentType="text/html"%> +<%@page pageEncoding="UTF-8"%> + + + +
\ No newline at end of file diff --git a/src/main/webapp/WEB-INF/liferay-display.xml b/src/main/webapp/WEB-INF/liferay-display.xml new file mode 100644 index 0000000..83a8fd7 --- /dev/null +++ b/src/main/webapp/WEB-INF/liferay-display.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/main/webapp/WEB-INF/liferay-plugin-package.properties b/src/main/webapp/WEB-INF/liferay-plugin-package.properties new file mode 100644 index 0000000..8907315 --- /dev/null +++ b/src/main/webapp/WEB-INF/liferay-plugin-package.properties @@ -0,0 +1,9 @@ +name=VRE Definition Wizard +module-group-id=liferay +module-incremental-version=1 +tags= +short-description= +change-log= +page-url=http://www.d4science.org +author=D4Science.org +licenses=MIT \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/liferay-portlet.xml b/src/main/webapp/WEB-INF/liferay-portlet.xml new file mode 100644 index 0000000..88c8b36 --- /dev/null +++ b/src/main/webapp/WEB-INF/liferay-portlet.xml @@ -0,0 +1,16 @@ + + + + + VREDefinition + false + false + false + + /VreDefinition.css + + + administrator + Administrator + + diff --git a/src/main/webapp/WEB-INF/portlet.xml b/src/main/webapp/WEB-INF/portlet.xml new file mode 100644 index 0000000..0bc49e7 --- /dev/null +++ b/src/main/webapp/WEB-INF/portlet.xml @@ -0,0 +1,24 @@ + + + + VREDefinition + VRE Definition Wizard + org.gcube.portlets.admin.vredefinition.server.portlet.VREDefinitionPortlet + + view-jsp + /WEB-INF/jsp/VREDefinition_view.jsp + + 0 + + text/html + + + VRE Definition Wizard + VRE Definition Wizard + VRE Definition Wizard + + + administrator + + + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..9a190de --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,22 @@ + + + + VREDefinitionServiceImpl + org.gcube.portlets.admin.vredefinition.server.VREDefinitionServiceImpl + + + scopeService + org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl + + + VREDefinitionServiceImpl + /vredefinition/VREDefinitionServiceImpl + + + scopeService + /vredefinition/scopeService + + + VreDefinition.html + + \ No newline at end of file diff --git a/src/main/webapp/images/statistics-loader.gif b/src/main/webapp/images/statistics-loader.gif new file mode 100644 index 0000000000000000000000000000000000000000..e661c2f40033b3596139df81bc6d45c5369e5d86 GIT binary patch literal 9511 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 RJ|U=*dUUl4k+b&H{{h?hf|dXP literal 0 HcmV?d00001 diff --git a/src/test/java/org/gcube/portlets/admin/vredefinition/client/TestForDeploy.java b/src/test/java/org/gcube/portlets/admin/vredefinition/client/TestForDeploy.java new file mode 100644 index 0000000..9f557cc --- /dev/null +++ b/src/test/java/org/gcube/portlets/admin/vredefinition/client/TestForDeploy.java @@ -0,0 +1,19 @@ +package org.gcube.portlets.admin.vredefinition.client; + +import static org.junit.Assert.assertTrue; + +import org.gcube.portlets.admin.vredefinition.server.VREDefinitionServiceImpl; +import org.junit.Test; + +public class TestForDeploy { + + @Test + public void testUserIsTestUser() { + VREDefinitionServiceImpl serviceImpl = new VREDefinitionServiceImpl(); + String username = serviceImpl.getDevelopmentUser(); + System.out.println("username for deploy is: " + username); + assertTrue(username.compareTo(VREDefinitionServiceImpl.defaultUserId) == 0); + System.out.println("Test OK!"); + } + +} diff --git a/src/test/resources/org/gcube/portlets/admin/vredefinition/VreDefinitionJUnit.gwt.xml b/src/test/resources/org/gcube/portlets/admin/vredefinition/VreDefinitionJUnit.gwt.xml new file mode 100644 index 0000000..9a4a9e1 --- /dev/null +++ b/src/test/resources/org/gcube/portlets/admin/vredefinition/VreDefinitionJUnit.gwt.xml @@ -0,0 +1,9 @@ + + + + + + + + +