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
This commit is contained in:
Lucio Lelii 2009-02-23 15:08:27 +00:00
parent d819772daf
commit 11f82637ad
5 changed files with 85 additions and 38 deletions

View File

@ -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 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,'searchGUI#Search')
INSERT INTO PORTLETRELTOFUNCT VALUES(0,'collectionsnavigator#CollectionsNavigatorPortlet') INSERT INTO PORTLETRELTOFUNCT VALUES(0,'collectionsnavigator#CollectionsNavigatorPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(0,'resultsetPortlet#ResultsetPortlet') INSERT INTO PORTLETRELTOFUNCT VALUES(0,'resultsetPortlet#ResultsetPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(0,'Metadata_Viewing_Portlet#Metadata_Viewing_Portlet') 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,'quicksearchportlet#QuickSearchPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(12,'resultsetPortlet#ResultsetPortlet') INSERT INTO PORTLETRELTOFUNCT VALUES(12,'resultsetPortlet#ResultsetPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(12,'Metadata_Viewing_Portlet#Metadata_Viewing_Portlet') 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(1,'AnnotationFrontEnd#ImageAnnotationPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(5,'Metadata_Editing_Portlet#Metadata_Editing_Portlet') 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') INSERT INTO SERVICES VALUES(1,'ABE','Annotation', '1.00.00')

View File

@ -132,7 +132,7 @@ public class ModelerService {
ArrayList<String> relatedGHN=new ArrayList<String>(); ArrayList<String> relatedGHN=new ArrayList<String>();
try{ try{
DBInterface.connect(); 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()+"';"); ResultSet resRelated= DBInterface.queryDB("select ghnid from VRERELATEDGHN where VRERELATEDGHN.vreid='"+getResource().getId()+"';");
while(resRelated.next()) while(resRelated.next())

View File

@ -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.impl.util.VREManagerServiceHandler;
import org.gcube.vremanagement.vremodeler.portallayout.CollectionResourceCreation; import org.gcube.vremanagement.vremodeler.portallayout.CollectionResourceCreation;
import org.gcube.vremanagement.vremodeler.portallayout.GenericResourcePortlet; import org.gcube.vremanagement.vremodeler.portallayout.GenericResourcePortlet;
import org.gcube.vremanagement.vremodeler.portallayout.LayoutCreation;
import org.globus.wsrf.ResourceException; import org.globus.wsrf.ResourceException;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
@ -64,7 +65,7 @@ public class DeployVRE extends Thread{
public void run() { public void run() {
try { 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<Couple<String, String>> GHNList= new ArrayList<Couple<String, String>>(); List<Couple<String, String>> GHNList= new ArrayList<Couple<String, String>>();
while (resRelatedGHN.next()) GHNList.add(new Couple<String, String>(resRelatedGHN.getString(1),resRelatedGHN.getString(2))); while (resRelatedGHN.next()) GHNList.add(new Couple<String, String>(resRelatedGHN.getString(1),resRelatedGHN.getString(2)));
@ -246,6 +247,9 @@ public class DeployVRE extends Thread{
GenericResourcePortlet.createResource(getResource().getId(), vreName); GenericResourcePortlet.createResource(getResource().getId(), vreName);
collectionResourceCreation.createAndPublish(); collectionResourceCreation.createAndPublish();
LayoutCreation createdlayout= new LayoutCreation(getResource().getId(), vreName);
createdlayout.createAndPublishLayout();
//waiting few seconds to be sure that generic resources will be published //waiting few seconds to be sure that generic resources will be published
Thread.currentThread().sleep(60000); Thread.currentThread().sleep(60000);
@ -285,11 +289,15 @@ public class DeployVRE extends Thread{
//adding the CollectionResource genericResource //adding the CollectionResource genericResource
ResourceItem genResItem= new ResourceItem(); ResourceItem genResItem= new ResourceItem();
genResItem= new ResourceItem();
genResItem.setID(collectionResourceCreation.getCreatedResourceId()); genResItem.setID(collectionResourceCreation.getCreatedResourceId());
genResItem.setType(GCUBEGenericResource.TYPE); genResItem.setType(GCUBEGenericResource.TYPE);
resItemList.add(genResItem); resItemList.add(genResItem);
genResItem= new ResourceItem();
genResItem.setID(createdlayout.getCreatedResourceId());
genResItem.setType(GCUBEGenericResource.TYPE);
resItemList.add(genResItem);
//adding the other needed resources //adding the other needed resources
try{ try{
ResourceItem resItem; ResourceItem resItem;

View File

@ -55,6 +55,7 @@ public class CollectionResourceCreation {
res.load(new StringReader(this.transformCollectionResource())); res.load(new StringReader(this.transformCollectionResource()));
ISPublisher pub= GHNContext.getImplementation(ISPublisher.class); ISPublisher pub= GHNContext.getImplementation(ISPublisher.class);
res.setID(""); res.setID("");
res.removeScope(ServiceContext.getContext().getScope());
res.load(new StringReader(pub.registerGCUBEResource(res, GCUBEScope.getScope(ServiceContext.getContext().getScope()+"/"+this.vreName), ServiceContext.getContext()))); res.load(new StringReader(pub.registerGCUBEResource(res, GCUBEScope.getScope(ServiceContext.getContext().getScope()+"/"+this.vreName), ServiceContext.getContext())));
this.createdResourceId= res.getID(); this.createdResourceId= res.getID();
} }

View File

@ -1,24 +1,19 @@
package org.gcube.vremanagement.vremodeler.portallayout; package org.gcube.vremanagement.vremodeler.portallayout;
import java.io.StringReader; import java.io.StringReader;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import org.gcube.common.core.contexts.GHNContext; import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.publisher.ISPublisher; import org.gcube.common.core.informationsystem.publisher.ISPublisher;
import org.gcube.common.core.resources.GCUBEGenericResource; import org.gcube.common.core.resources.GCUBEGenericResource;
import org.gcube.common.core.scope.GCUBEScope; 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.ServiceContext;
import org.gcube.vremanagement.vremodeler.impl.util.Couple;
import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil; 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.Document;
import org.w3c.dom.Element;
public class LayoutCreation { public class LayoutCreation {
private TreeNode layoutTree;
private Document doc; private Document doc;
private GCUBEGenericResource resource; private GCUBEGenericResource resource;
private String vreId; private String vreId;
@ -36,7 +31,8 @@ public class LayoutCreation {
resource.setDescription("the gridsphere layout for vre: "+ServiceContext.getContext().getScope()+"/"+this.vreName); resource.setDescription("the gridsphere layout for vre: "+ServiceContext.getContext().getScope()+"/"+this.vreName);
String[] splitScope=ServiceContext.getContext().getScope().toString().split("/"); String[] splitScope=ServiceContext.getContext().getScope().toString().split("/");
resource.setName("Layout_"+splitScope[1]+"_"+splitScope[2]+"_"+this.vreName); 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); ISPublisher publisher= GHNContext.getImplementation(ISPublisher.class);
resource.load(new StringReader(publisher.registerGCUBEResource(resource, GCUBEScope.getScope(ServiceContext.getContext().getScope()+"/"+this.vreName), ServiceContext.getContext()))); resource.load(new StringReader(publisher.registerGCUBEResource(resource, GCUBEScope.getScope(ServiceContext.getContext().getScope()+"/"+this.vreName), ServiceContext.getContext())));
this.createdResourceId= resource.getID(); this.createdResourceId= resource.getID();
@ -53,34 +49,68 @@ public class LayoutCreation {
} }
public GCUBEGenericResource createAndPublishLayout() throws Exception{ public GCUBEGenericResource createAndPublishLayout() throws Exception{
layoutTree = new TreeNode("Root"); doc.appendChild(this.createLayout());
createTree();
doc.appendChild(layoutTree.createElement(doc));
publish(doc); publish(doc);
return resource; return resource;
} }
private void createTree() throws Exception{ @SuppressWarnings("unchecked")
private Element createLayout() throws Exception{
try { 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+"';"); Element root= XMLUtil.createTextElement(doc, "tabbed-pane", null, new Couple<String, String>("can-modify", "false"), new Couple<String, String>("label", ""), new Couple<String, String>("required-role", ""), new Couple<String, String>("style", "menu"), new Couple<String, String>("visible", "true"), new Couple<String, String>("width", ""));
while (selectedPortlet.next()){ Element tab= XMLUtil.createTextElement(doc, "tab", null, new Couple<String,String>("align", "left"), new Couple<String,String>("can-modify", "false"), new Couple<String,String>("label", ""), new Couple<String,String>("order", "50"), new Couple<String,String>("outline", "true"), new Couple<String,String>("required-role", "VRE-Manager"), new Couple<String,String>("style", ""), new Couple<String,String>("visible", "true"), new Couple<String,String>("width", ""));
AbstractTree child= new TreeLeaf(selectedPortlet.getString(1), selectedPortlet.getString(2) ); Element title= XMLUtil.createTextElement(doc, "title", "VRE Management", new Couple<String, String>("lang", "en"));
String parent= selectedPortlet.getString(3); Element subRoot= XMLUtil.createTextElement(doc, "tabbed-pane", null, new Couple<String, String>("can-modify", "false"), new Couple<String, String>("label", ""), new Couple<String, String>("required-role", ""), new Couple<String, String>("style", "sub-menu"), new Couple<String, String>("visible", "true"), new Couple<String, String>("width", ""));
System.out.println("parent: "+parent);
while(parent!=null){ //layoutCreatorPortlet
ResultSet parentPortlet= DBInterface.queryDB("select p.name, p.parent from PORTLET as p WHERE p.name='"+parent+"' ;"); Element layoutCreationTab= XMLUtil.createTextElement(doc, "tab", null, new Couple<String,String>("align", "left"), new Couple<String,String>("can-modify", "false"), new Couple<String,String>("label", ""), new Couple<String,String>("order", "50"), new Couple<String,String>("outline", "true"), new Couple<String,String>("required-role", "VRE-Manager"), new Couple<String,String>("style", ""), new Couple<String,String>("visible", "true"), new Couple<String,String>("width", ""));
parentPortlet.next();
AbstractTree tempParent= new TreeNode(parentPortlet.getString(1)); Element layoutCreationTitle= XMLUtil.createTextElement(doc, "title", "Layout Creator", new Couple<String, String>("lang", "en"));
tempParent.addPathNode(child);
child= tempParent; Element layoutCreationRow =XMLUtil.createTextElement(doc, "row", null,new Couple<String, String>("can-modify", "false"), new Couple<String, String>("label", ""), new Couple<String, String>("required-role", "") ,new Couple<String, String>("style", ""),new Couple<String, String>("visible", "true"),new Couple<String, String>("width", "") );
try{
parent= parentPortlet.getString(2); Element layoutCreationColumn =XMLUtil.createTextElement(doc, "column", null,new Couple<String, String>("can-modify", "false"), new Couple<String, String>("label", ""), new Couple<String, String>("required-role", "") ,new Couple<String, String>("style", ""),new Couple<String, String>("visible", "true"),new Couple<String, String>("width", "") );
}catch(Exception e){parent=null;}
} Element layoutCreationframe = XMLUtil.createTextElement(doc, "frame", null,new Couple<String, String>("can-modify", "false"), new Couple<String, String>("inner-padding", ""), new Couple<String, String>("label", "") ,new Couple<String, String>("outer-padding", ""),new Couple<String, String>("required-role", ""),new Couple<String, String>("style", ""),new Couple<String, String>("transparent", "true"),new Couple<String, String>("visible", "true"),new Couple<String, String>("width", "") );
layoutTree.addPathNode(child);
} Element layoutCreationPortlet= XMLUtil.createTextElement(doc, "portlet-class", "layoutcreator#LayoutcreatorPortlet");
} catch (SQLException e) {
throw new Exception("Error creating the Portlet Tree",e); 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<String,String>("align", "left"), new Couple<String,String>("can-modify", "false"), new Couple<String,String>("label", ""), new Couple<String,String>("order", "50"), new Couple<String,String>("outline", "true"), new Couple<String,String>("required-role", "VRE-Manager"), new Couple<String,String>("style", ""), new Couple<String,String>("visible", "true"), new Couple<String,String>("width", ""));
Element informationSpaceTitle= XMLUtil.createTextElement(doc, "title", "Layout Creator", new Couple<String, String>("lang", "en"));
Element informationSpaceRow =XMLUtil.createTextElement(doc, "row", null,new Couple<String, String>("can-modify", "false"), new Couple<String, String>("label", ""), new Couple<String, String>("required-role", "") ,new Couple<String, String>("style", ""),new Couple<String, String>("visible", "true"),new Couple<String, String>("width", "") );
Element informationSpaceColumn =XMLUtil.createTextElement(doc, "column", null,new Couple<String, String>("can-modify", "false"), new Couple<String, String>("label", ""), new Couple<String, String>("required-role", "") ,new Couple<String, String>("style", ""),new Couple<String, String>("visible", "true"),new Couple<String, String>("width", "") );
Element informationSpaceFrame = XMLUtil.createTextElement(doc, "frame", null,new Couple<String, String>("can-modify", "false"), new Couple<String, String>("inner-padding", ""), new Couple<String, String>("label", "") ,new Couple<String, String>("outer-padding", ""),new Couple<String, String>("required-role", ""),new Couple<String, String>("style", ""),new Couple<String, String>("transparent", "true"),new Couple<String, String>("visible", "true"),new Couple<String, String>("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);
} }
} }