From 11f82637ad3db8c1c70eb5f2fdd4033d94671ec0 Mon Sep 17 00:00:00 2001 From: Lucio Lelii Date: Mon, 23 Feb 2009 15:08:27 +0000 Subject: [PATCH] resource layout creation (for first VRE use) and others fixes git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/VREModeler@9957 82a268e6-3cf1-43bd-a215-b396298e98cf --- etc/hsqldb/vdldb.script | 16 +++- .../vremodeler/impl/ModelerService.java | 2 +- .../vremodeler/impl/thread/DeployVRE.java | 12 ++- .../CollectionResourceCreation.java | 1 + .../portallayout/LayoutCreation.java | 92 ++++++++++++------- 5 files changed, 85 insertions(+), 38 deletions(-) diff --git a/etc/hsqldb/vdldb.script b/etc/hsqldb/vdldb.script index ba47b5c..f174ea9 100644 --- a/etc/hsqldb/vdldb.script +++ b/etc/hsqldb/vdldb.script @@ -45,14 +45,11 @@ INSERT INTO FUNCTIONALITY VALUES(11,'Geographic Search','By selecting this funct INSERT INTO FUNCTIONALITY VALUES(12,'Quick Search','Using Quick Search the user will be provided with facilities to perform a generic search in the infrastructure. No selection of collections is required in order to search using this feature. The system automatically identifies the most appropriate collections to search, taking into account the terms specified by the user.',7,0) - - - - INSERT INTO PORTLETRELTOFUNCT VALUES(0,'searchGUI#Search') INSERT INTO PORTLETRELTOFUNCT VALUES(0,'collectionsnavigator#CollectionsNavigatorPortlet') INSERT INTO PORTLETRELTOFUNCT VALUES(0,'resultsetPortlet#ResultsetPortlet') INSERT INTO PORTLETRELTOFUNCT VALUES(0,'Metadata_Viewing_Portlet#Metadata_Viewing_Portlet') +INSERT INTO PORTLETRELTOFUNCT VALUES(0,'VRE InformationSpace Editor#VREInformationSpaceEditorPortlet') INSERT INTO PORTLETRELTOFUNCT VALUES(12,'quicksearchportlet#QuickSearchPortlet') INSERT INTO PORTLETRELTOFUNCT VALUES(12,'resultsetPortlet#ResultsetPortlet') INSERT INTO PORTLETRELTOFUNCT VALUES(12,'Metadata_Viewing_Portlet#Metadata_Viewing_Portlet') @@ -69,6 +66,17 @@ INSERT INTO PORTLETRELTOFUNCT VALUES(1,'AnnotationFrontEnd#VideoAnnotationPortle INSERT INTO PORTLETRELTOFUNCT VALUES(1,'AnnotationFrontEnd#ImageAnnotationPortlet') INSERT INTO PORTLETRELTOFUNCT VALUES(5,'Metadata_Editing_Portlet#Metadata_Editing_Portlet') +INSERT INTO PORTLETRELTOFUNCT VALUES(0,'workspace#WorkspacePortlet') +INSERT INTO PORTLETRELTOFUNCT VALUES(1,'workspace#WorkspacePortlet') +INSERT INTO PORTLETRELTOFUNCT VALUES(2,'workspace#WorkspacePortlet') +INSERT INTO PORTLETRELTOFUNCT VALUES(3,'workspace#WorkspacePortlet') +INSERT INTO PORTLETRELTOFUNCT VALUES(4,'workspace#WorkspacePortlet') +INSERT INTO PORTLETRELTOFUNCT VALUES(5,'workspace#WorkspacePortlet') +INSERT INTO PORTLETRELTOFUNCT VALUES(6,'workspace#WorkspacePortlet') +INSERT INTO PORTLETRELTOFUNCT VALUES(9,'workspace#WorkspacePortlet') +INSERT INTO PORTLETRELTOFUNCT VALUES(10,'workspace#WorkspacePortlet') +INSERT INTO PORTLETRELTOFUNCT VALUES(11,'workspace#WorkspacePortlet') +INSERT INTO PORTLETRELTOFUNCT VALUES(12,'workspace#WorkspacePortlet') INSERT INTO SERVICES VALUES(1,'ABE','Annotation', '1.00.00') diff --git a/src/org/gcube/vremanagement/vremodeler/impl/ModelerService.java b/src/org/gcube/vremanagement/vremodeler/impl/ModelerService.java index 9aae816..a788c8c 100644 --- a/src/org/gcube/vremanagement/vremodeler/impl/ModelerService.java +++ b/src/org/gcube/vremanagement/vremodeler/impl/ModelerService.java @@ -132,7 +132,7 @@ public class ModelerService { ArrayList relatedGHN=new ArrayList(); try{ DBInterface.connect(); - res= DBInterface.queryDB("select * from GHN;"); + res= DBInterface.queryDB("select * from GHN ORDER BY GHN.host;"); ResultSet resRelated= DBInterface.queryDB("select ghnid from VRERELATEDGHN where VRERELATEDGHN.vreid='"+getResource().getId()+"';"); while(resRelated.next()) diff --git a/src/org/gcube/vremanagement/vremodeler/impl/thread/DeployVRE.java b/src/org/gcube/vremanagement/vremodeler/impl/thread/DeployVRE.java index 4cd78f5..bd5ed10 100644 --- a/src/org/gcube/vremanagement/vremodeler/impl/thread/DeployVRE.java +++ b/src/org/gcube/vremanagement/vremodeler/impl/thread/DeployVRE.java @@ -37,6 +37,7 @@ import org.gcube.vremanagement.vremodeler.impl.util.Couple; import org.gcube.vremanagement.vremodeler.impl.util.VREManagerServiceHandler; import org.gcube.vremanagement.vremodeler.portallayout.CollectionResourceCreation; import org.gcube.vremanagement.vremodeler.portallayout.GenericResourcePortlet; +import org.gcube.vremanagement.vremodeler.portallayout.LayoutCreation; import org.globus.wsrf.ResourceException; import org.w3c.dom.Document; import org.w3c.dom.NodeList; @@ -64,7 +65,7 @@ public class DeployVRE extends Thread{ public void run() { try { - ResultSet resRelatedGHN=DBInterface.queryDB("select VRERELATEDGHN.ghnid, GHN.domain from VRERELATEDGHN, GHN where GHN.id=VRERELATEDGHN.ghnid and VRERELATEDGHN.vreid='"+this.resourceId+"'; "); + ResultSet resRelatedGHN=DBInterface.queryDB("select VRERELATEDGHN.ghnid, GHN.domain from VRERELATEDGHN, GHN where GHN.id=VRERELATEDGHN.ghnid and VRERELATEDGHN.vreid='"+this.resourceId+"' ORDER BY GHN.host; "); List> GHNList= new ArrayList>(); while (resRelatedGHN.next()) GHNList.add(new Couple(resRelatedGHN.getString(1),resRelatedGHN.getString(2))); @@ -246,6 +247,9 @@ public class DeployVRE extends Thread{ GenericResourcePortlet.createResource(getResource().getId(), vreName); collectionResourceCreation.createAndPublish(); + LayoutCreation createdlayout= new LayoutCreation(getResource().getId(), vreName); + createdlayout.createAndPublishLayout(); + //waiting few seconds to be sure that generic resources will be published Thread.currentThread().sleep(60000); @@ -285,11 +289,15 @@ public class DeployVRE extends Thread{ //adding the CollectionResource genericResource ResourceItem genResItem= new ResourceItem(); - genResItem= new ResourceItem(); genResItem.setID(collectionResourceCreation.getCreatedResourceId()); genResItem.setType(GCUBEGenericResource.TYPE); resItemList.add(genResItem); + genResItem= new ResourceItem(); + genResItem.setID(createdlayout.getCreatedResourceId()); + genResItem.setType(GCUBEGenericResource.TYPE); + resItemList.add(genResItem); + //adding the other needed resources try{ ResourceItem resItem; diff --git a/src/org/gcube/vremanagement/vremodeler/portallayout/CollectionResourceCreation.java b/src/org/gcube/vremanagement/vremodeler/portallayout/CollectionResourceCreation.java index 7968f1f..65eaabd 100644 --- a/src/org/gcube/vremanagement/vremodeler/portallayout/CollectionResourceCreation.java +++ b/src/org/gcube/vremanagement/vremodeler/portallayout/CollectionResourceCreation.java @@ -55,6 +55,7 @@ public class CollectionResourceCreation { res.load(new StringReader(this.transformCollectionResource())); ISPublisher pub= GHNContext.getImplementation(ISPublisher.class); res.setID(""); + res.removeScope(ServiceContext.getContext().getScope()); res.load(new StringReader(pub.registerGCUBEResource(res, GCUBEScope.getScope(ServiceContext.getContext().getScope()+"/"+this.vreName), ServiceContext.getContext()))); this.createdResourceId= res.getID(); } diff --git a/src/org/gcube/vremanagement/vremodeler/portallayout/LayoutCreation.java b/src/org/gcube/vremanagement/vremodeler/portallayout/LayoutCreation.java index 2b14bf1..0f2d818 100644 --- a/src/org/gcube/vremanagement/vremodeler/portallayout/LayoutCreation.java +++ b/src/org/gcube/vremanagement/vremodeler/portallayout/LayoutCreation.java @@ -1,24 +1,19 @@ package org.gcube.vremanagement.vremodeler.portallayout; import java.io.StringReader; -import java.sql.ResultSet; -import java.sql.SQLException; import javax.xml.parsers.DocumentBuilderFactory; import org.gcube.common.core.contexts.GHNContext; import org.gcube.common.core.informationsystem.publisher.ISPublisher; import org.gcube.common.core.resources.GCUBEGenericResource; import org.gcube.common.core.scope.GCUBEScope; -import org.gcube.vremanagement.vremodeler.db.DBInterface; import org.gcube.vremanagement.vremodeler.impl.ServiceContext; +import org.gcube.vremanagement.vremodeler.impl.util.Couple; import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil; -import org.gcube.vremanagement.vremodeler.portallayout.util.AbstractTree; -import org.gcube.vremanagement.vremodeler.portallayout.util.TreeLeaf; -import org.gcube.vremanagement.vremodeler.portallayout.util.TreeNode; import org.w3c.dom.Document; +import org.w3c.dom.Element; public class LayoutCreation { - private TreeNode layoutTree; private Document doc; private GCUBEGenericResource resource; private String vreId; @@ -36,7 +31,8 @@ public class LayoutCreation { resource.setDescription("the gridsphere layout for vre: "+ServiceContext.getContext().getScope()+"/"+this.vreName); String[] splitScope=ServiceContext.getContext().getScope().toString().split("/"); resource.setName("Layout_"+splitScope[1]+"_"+splitScope[2]+"_"+this.vreName); - resource.setSecondaryType("VRE"); + resource.setSecondaryType(""); + resource.addScope(GCUBEScope.getScope(ServiceContext.getContext().getScope()+"/"+this.vreName)); ISPublisher publisher= GHNContext.getImplementation(ISPublisher.class); resource.load(new StringReader(publisher.registerGCUBEResource(resource, GCUBEScope.getScope(ServiceContext.getContext().getScope()+"/"+this.vreName), ServiceContext.getContext()))); this.createdResourceId= resource.getID(); @@ -53,34 +49,68 @@ public class LayoutCreation { } public GCUBEGenericResource createAndPublishLayout() throws Exception{ - layoutTree = new TreeNode("Root"); - createTree(); - doc.appendChild(layoutTree.createElement(doc)); + doc.appendChild(this.createLayout()); publish(doc); return resource; } - private void createTree() throws Exception{ + @SuppressWarnings("unchecked") + private Element createLayout() throws Exception{ try { - ResultSet selectedPortlet= DBInterface.queryDB("select p.name, p.portletclass, p.parent from VRERELATEDFUNCT as vf,PORTLETRELTOFUNCT as pf, PORTLET as p WHERE vf.FUNCID=pf.FUNCID and pf.PORTLETNAME=p.NAME and vf.VREID='"+this.vreId+"';"); - while (selectedPortlet.next()){ - AbstractTree child= new TreeLeaf(selectedPortlet.getString(1), selectedPortlet.getString(2) ); - String parent= selectedPortlet.getString(3); - System.out.println("parent: "+parent); - while(parent!=null){ - ResultSet parentPortlet= DBInterface.queryDB("select p.name, p.parent from PORTLET as p WHERE p.name='"+parent+"' ;"); - parentPortlet.next(); - AbstractTree tempParent= new TreeNode(parentPortlet.getString(1)); - tempParent.addPathNode(child); - child= tempParent; - try{ - parent= parentPortlet.getString(2); - }catch(Exception e){parent=null;} - } - layoutTree.addPathNode(child); - } - } catch (SQLException e) { - throw new Exception("Error creating the Portlet Tree",e); + Element root= XMLUtil.createTextElement(doc, "tabbed-pane", null, new Couple("can-modify", "false"), new Couple("label", ""), new Couple("required-role", ""), new Couple("style", "menu"), new Couple("visible", "true"), new Couple("width", "")); + Element tab= XMLUtil.createTextElement(doc, "tab", null, new Couple("align", "left"), new Couple("can-modify", "false"), new Couple("label", ""), new Couple("order", "50"), new Couple("outline", "true"), new Couple("required-role", "VRE-Manager"), new Couple("style", ""), new Couple("visible", "true"), new Couple("width", "")); + Element title= XMLUtil.createTextElement(doc, "title", "VRE Management", new Couple("lang", "en")); + Element subRoot= XMLUtil.createTextElement(doc, "tabbed-pane", null, new Couple("can-modify", "false"), new Couple("label", ""), new Couple("required-role", ""), new Couple("style", "sub-menu"), new Couple("visible", "true"), new Couple("width", "")); + + //layoutCreatorPortlet + Element layoutCreationTab= XMLUtil.createTextElement(doc, "tab", null, new Couple("align", "left"), new Couple("can-modify", "false"), new Couple("label", ""), new Couple("order", "50"), new Couple("outline", "true"), new Couple("required-role", "VRE-Manager"), new Couple("style", ""), new Couple("visible", "true"), new Couple("width", "")); + + Element layoutCreationTitle= XMLUtil.createTextElement(doc, "title", "Layout Creator", new Couple("lang", "en")); + + Element layoutCreationRow =XMLUtil.createTextElement(doc, "row", null,new Couple("can-modify", "false"), new Couple("label", ""), new Couple("required-role", "") ,new Couple("style", ""),new Couple("visible", "true"),new Couple("width", "") ); + + Element layoutCreationColumn =XMLUtil.createTextElement(doc, "column", null,new Couple("can-modify", "false"), new Couple("label", ""), new Couple("required-role", "") ,new Couple("style", ""),new Couple("visible", "true"),new Couple("width", "") ); + + Element layoutCreationframe = XMLUtil.createTextElement(doc, "frame", null,new Couple("can-modify", "false"), new Couple("inner-padding", ""), new Couple("label", "") ,new Couple("outer-padding", ""),new Couple("required-role", ""),new Couple("style", ""),new Couple("transparent", "true"),new Couple("visible", "true"),new Couple("width", "") ); + + Element layoutCreationPortlet= XMLUtil.createTextElement(doc, "portlet-class", "layoutcreator#LayoutcreatorPortlet"); + + layoutCreationframe.appendChild(layoutCreationPortlet); + layoutCreationColumn.appendChild(layoutCreationframe); + layoutCreationRow.appendChild(layoutCreationColumn); + layoutCreationTitle.appendChild(layoutCreationRow); + layoutCreationTab.appendChild(layoutCreationTitle); + + //InformationSpaceEditorPortlet + Element informationSpaceTab= XMLUtil.createTextElement(doc, "tab", null, new Couple("align", "left"), new Couple("can-modify", "false"), new Couple("label", ""), new Couple("order", "50"), new Couple("outline", "true"), new Couple("required-role", "VRE-Manager"), new Couple("style", ""), new Couple("visible", "true"), new Couple("width", "")); + + Element informationSpaceTitle= XMLUtil.createTextElement(doc, "title", "Layout Creator", new Couple("lang", "en")); + + Element informationSpaceRow =XMLUtil.createTextElement(doc, "row", null,new Couple("can-modify", "false"), new Couple("label", ""), new Couple("required-role", "") ,new Couple("style", ""),new Couple("visible", "true"),new Couple("width", "") ); + + Element informationSpaceColumn =XMLUtil.createTextElement(doc, "column", null,new Couple("can-modify", "false"), new Couple("label", ""), new Couple("required-role", "") ,new Couple("style", ""),new Couple("visible", "true"),new Couple("width", "") ); + + Element informationSpaceFrame = XMLUtil.createTextElement(doc, "frame", null,new Couple("can-modify", "false"), new Couple("inner-padding", ""), new Couple("label", "") ,new Couple("outer-padding", ""),new Couple("required-role", ""),new Couple("style", ""),new Couple("transparent", "true"),new Couple("visible", "true"),new Couple("width", "") ); + + Element informationSpacePortlet= XMLUtil.createTextElement(doc, "portlet-class", "VRE InformationSpace Editor#VREInformationSpaceEditorPortlet"); + + informationSpaceFrame.appendChild(informationSpacePortlet); + informationSpaceColumn.appendChild(informationSpaceFrame); + informationSpaceRow.appendChild(informationSpaceColumn); + informationSpaceTitle.appendChild(informationSpaceRow); + informationSpaceTab.appendChild(informationSpaceTitle); + + + subRoot.appendChild(layoutCreationTab); + subRoot.appendChild(informationSpaceTab); + + title.appendChild(subRoot); + + tab.appendChild(title); + root.appendChild(tab); + return root; + } catch (Exception e) { + throw new Exception("Error creating the Portlet Layout",e); } }