This commit is contained in:
Lucio Lelii 2009-09-30 09:29:45 +00:00
parent 792ff67e52
commit 4c9fdac867
42 changed files with 1023 additions and 843 deletions

View File

@ -3,8 +3,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/VREMODELERLIBS"/>
<classpathentry kind="lib" path="/home/lucio/gCore/lib/MetadataBrokerLibrary.jar"/>
<classpathentry kind="lib" path="/home/lucio/gCore/lib/org.gcube.metadatamanagement.metadatabroker.stubs.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/GCORELIB"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/GCORE050"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,17 +0,0 @@
#HSQL Database Engine 1.8.0.7
#Thu Oct 09 14:33:14 CEST 2008
hsqldb.script_format=0
runtime.gc_interval=0
sql.enforce_strict_size=false
hsqldb.cache_size_scale=8
readonly=false
hsqldb.nio_data_file=true
hsqldb.cache_scale=14
version=1.8.0
hsqldb.default_table_type=memory
hsqldb.cache_file_scale=1
hsqldb.log_size=200
modified=yes
hsqldb.cache_version=1.7.0
hsqldb.original_version=1.8.0
hsqldb.compatible_version=1.8.0

View File

@ -1,153 +0,0 @@
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
CREATE MEMORY TABLE COLLECTION(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR,DESCRIPTION VARCHAR,MEMBERS VARCHAR,CREATION VARCHAR,LASTUPDATE VARCHAR)
CREATE MEMORY TABLE GHN(ID VARCHAR NOT NULL PRIMARY KEY,HOST VARCHAR,SECURITY VARCHAR,UPTIME VARCHAR,MAINMEMORYVA VARCHAR,MAINMEMORYVS VARCHAR,LOCALAS VARCHAR,LOCATION VARCHAR,COUNTRY VARCHAR,DOMAIN VARCHAR)
CREATE MEMORY TABLE MDCOLLECTION(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR,DESCRIPTION VARCHAR,RELATEDCOLLECTIONID VARCHAR NOT NULL,CONSTRAINT SYS_FK_50 FOREIGN KEY(RELATEDCOLLECTIONID) REFERENCES COLLECTION(ID))
CREATE MEMORY TABLE VRE(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,DESCRIPTION VARCHAR NOT NULL,VREDESIGNER VARCHAR NOT NULL,VREMANAGER VARCHAR NOT NULL,INTERVALFROM DATE,INTERVALTO DATE,EPR VARCHAR,STATUS VARCHAR)
CREATE MEMORY TABLE CS(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,DESCRIPTION VARCHAR NOT NULL)
CREATE MEMORY TABLE RUNNINGINSTANCE(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL, CLASS VARCHAR NOT NULL)
CREATE MEMORY TABLE GHNRELATEDRI(GHNID VARCHAR NOT NULL,RIID VARCHAR NOT NULL,PRIMARY KEY(GHNID,RIID))
CREATE MEMORY TABLE RIRELATEDPKG(RIID VARCHAR NOT NULL,PKGID INTEGER NOT NULL,PRIMARY KEY(RIID,PKGID))
CREATE MEMORY TABLE FUNCTIONALITY(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,DESCRIPTION VARCHAR NOT NULL,FATHER INTEGER,FLAG INTEGER NOT NULL)
CREATE MEMORY TABLE PACKAGE(ID VARCHAR NOT NULL,SCLASS VARCHAR NOT NULL,SNAME VARCHAR NOT NULL,PNAME VARCHAR NOT NULL,PRIMARY KEY(SCLASS,SNAME,PNAME))
CREATE MEMORY TABLE MDFORMAT(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,SCHEMAURI VARCHAR NOT NULL,LANGUAGE VARCHAR NOT NULL)
CREATE MEMORY TABLE DERIVABLEMDF(MDCOLLID VARCHAR NOT NULL,MDFID VARCHAR NOT NULL,TPID VARCHAR NOT NULL,PRIMARY KEY(MDCOLLID,MDFID),CONSTRAINT SYS_FK_170 FOREIGN KEY(MDCOLLID) REFERENCES MDCOLLECTION(ID),CONSTRAINT SYS_FK_171 FOREIGN KEY(MDFID) REFERENCES MDFORMAT(ID))
CREATE MEMORY TABLE NATIVEMDF(MDCOLLID VARCHAR NOT NULL,MDFID VARCHAR NOT NULL,PRIMARY KEY(MDCOLLID,MDFID),CONSTRAINT SYS_FK_178 FOREIGN KEY(MDCOLLID) REFERENCES MDCOLLECTION(ID),CONSTRAINT SYS_FK_179 FOREIGN KEY(MDFID) REFERENCES MDFORMAT(ID))
CREATE MEMORY TABLE VRERELATEDCOLLECTION(VREID VARCHAR NOT NULL,COLLID VARCHAR NOT NULL,PRIMARY KEY(VREID,COLLID))
CREATE MEMORY TABLE VRERELATEDGHN(VREID VARCHAR NOT NULL,GHNID VARCHAR NOT NULL,PRIMARY KEY(VREID,GHNID))
CREATE MEMORY TABLE VRERELATEDCS(VREID VARCHAR NOT NULL,CSID VARCHAR NOT NULL,PRIMARY KEY(VREID,CSID))
CREATE MEMORY TABLE VRERELATEDMETADATAFORMAT(VREID VARCHAR,COLLID VARCHAR,MFID VARCHAR)
CREATE MEMORY TABLE SERVICES(ID INTEGER NOT NULL,NAME VARCHAR NOT NULL,CLASS VARCHAR NOT NULL, VERSION VARCHAR NOT NULL, PRIMARY KEY(ID,NAME,CLASS),CONSTRAINT SYS_FK_189 FOREIGN KEY(ID) REFERENCES FUNCTIONALITY(ID))
CREATE MEMORY TABLE VRERELATEDFUNCT(VREID VARCHAR NOT NULL,FUNCID VARCHAR NOT NULL,PRIMARY KEY(VREID,FUNCID))
CREATE MEMORY TABLE RELATEDSERVICEID(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,CLASS VARCHAR NOT NULL)
CREATE MEMORY TABLE PORTLETRELTOFUNCT(FUNCID INTEGER NOT NULL,PORTLETCLASS VARCHAR NOT NULL, FOREIGN KEY(FUNCID) REFERENCES FUNCTIONALITY(ID) )
CREATE MEMORY TABLE NEEDEDRESOURCES(ID VARCHAR NOT NULL, TYPE VARCHAR NOT NULL, PRIMARY KEY(ID))
ALTER TABLE FUNCTIONALITY ALTER COLUMN ID RESTART WITH 17
CREATE USER SA PASSWORD ""
GRANT DBA TO SA
SET WRITE_DELAY 10
SET SCHEMA PUBLIC
CREATE VIEW SELECTEDNATIVEMDFORMAT(vreid, mdfid, mdcollid, collectionid) AS SELECT v.vreid, v.mfid, mdc.id, v.collid FROM VRERELATEDMETADATAFORMAT AS v, MDCOLLECTION AS mdc, NATIVEMDF AS n WHERE v.mfid=n.MDFID AND v.collid=mdc.relatedcollectionid AND n.mdcollid=mdc.id
CREATE VIEW SELECTEDDERIVABLEMDFORMAT(vreid, mdfid, mdcollid, collectionid, tpid) AS SELECT v.vreid, v.mfid, mdc.id, v.collid, n.tpid FROM VRERELATEDMETADATAFORMAT AS v, MDCOLLECTION AS mdc, DERIVABLEMDF AS n WHERE v.mfid=n.MDFID AND v.collid=mdc.relatedcollectionid AND n.mdcollid=mdc.id
INSERT INTO FUNCTIONALITY VALUES(0,'Search (Browse, Simple, and Combined)','By selecting this function VRE users will be provided with facilities supporting the discovery of Information Objects by issuing keyword based queries. This is the simplest modality for discovering Information Objects constituting the VRE Information Space. In addition to the specification of the keywords characterising the Information Objects the user is interested in, this function permits to restrict the Information Space in which to search by specifying the set of Collections against which the query will be evaluated.',7,0)
INSERT INTO FUNCTIONALITY VALUES(1,'Annotation','By selecting this function VRE users will be provided with facilities for annotating Information Objects. Annotations are additional Information Objects including notes, structured comments or links that an Actor may associate to an existing Information Object to add an interpretative value. This function is particularly useful to support co-operation between the users of a VRE since it allows not only to enrich an Information Object with personal observation and thus share this comment within the VRE community but, in general, also as a mean for transmitting and sharing ideas and thus doing research.',8,0)
INSERT INTO FUNCTIONALITY VALUES(2,'Report definition','By selecting this function VRE users will be provided with facilities for report creation. Starting from a report template, users will be able to instantiate such template by using the information currently available in the VRE. Each of such "living objects" can be materialised as to produce a version of it to be recorded into the VRE either as an HTML or a PDF Information Object.',8,0)
INSERT INTO FUNCTIONALITY VALUES(3,'Course management','By selecting this function VRE users will be provided with facilities for courses management, e.g. course creation and course attendance. Each course is a learning environment providing consumers with an organised set of Information Objects and tools (e.g. chats,forums) tailored to support distant learning activities on a specific topic. This function rely on the MooVREe system, i.e. an open-source e-Learning environment system, and is fully integrated with the rest of the VRE content and functions, e.g. a course will be populated by using Information Objects residing into the VRE Information Space and discovered by using the search function. In addition to curate the content of each course, teachers (designated users) can customise each course by selecting among the activity modules supported by the system, e.g. chat, Glossary, Survey.',8,0)
INSERT INTO FUNCTIONALITY VALUES(4,'Thumbnail','Thumbnails are reduced-size versions of pictures, used to help in recognizing and organizing them, serving the same role for images as a normal text index does for words. Thumbnails are in general created on demand when somebody is asking for them, as for example in the case of a user browsing the content stored in the VRE Information Space through the portal. ',8,0)
INSERT INTO FUNCTIONALITY VALUES(5,'Metadata Editing','By selecting this function the VRE users will be provided with a graphical user interface to edit the metadata of an object beloing to the VRE Information Space. Depending on the schema of the metadata different editors can be displayed. There are two visual editors for Dublin Core and eiDB schemas and a generic one for all other metadata format by default. Specific visula editors can be added by the VO and VRE Managers at any time. However, for some collections, it is forbidden to change the metadata, something that is stated on screen with a relevant message.The visual metadata editors provide an easy and user friendly way of editing the metadata. Adding, deleting and editing elements can be performed by clicking on the appropriate buttons and filling in text fields. When the desired changes are completed, the user has to apply the changes he has done by clicking on the “Save Changes” button. Please notice that the modified metadata is not re-indexed automatically but a specific action has to be taken by the VRE Manager to maintain the consistency between the metadata collection and indexes for that collection.',8,0)
INSERT INTO FUNCTIONALITY VALUES(6,'Report Template Definition','By selecting this function VRE users will be provided with facilities for report template creation. This means that the creator defines the report template in a definitional way by specifying the shape and content of this compound Information Object. Such an Information Objects can then be instantiated by using the information currently available in the VRE. ',8,0)
INSERT INTO FUNCTIONALITY VALUES(7,'Access Functions','This class of functions characterises the facilities that can be activated in the Virtual Research Environment to support users in requesting, locating, and accessing the Virtual Research Environment content.',NULL,0)
INSERT INTO FUNCTIONALITY VALUES(8,'Content Functions','This class of functions characterises the additional Content Management facilities that can be activated in the Virtual Research Environment. The meaning of additional is related to the fact that a fundamental set of Content Management facilities are supported by any VRE and not subject to design choices, e.g. Information Object storage and visualisation. This class contains only the functions providing potential extra-features that can be activated in this specific VRE, e.g. the possibility to annotate Information Object and the possibility to edit Information Objects.',NULL,0)
INSERT INTO FUNCTIONALITY VALUES(9,'Search by Query Expression','The Search by Query Expression will allow users to type their query in the gCube query language. In order the user to submit a valid query, he/she must be well aware of both the syntax of the query and the current status of the infrastructure. Since users must know the IDs of the content and also the existence or not of several types of indexes the full set of this information is dispayed together with the input form.',7,0)
INSERT INTO FUNCTIONALITY VALUES(10,'Google Search','By selecting this function VRE users will be provided with facilities supporting the discovery of Information Objects through Google and thus conceptually residing in the Web. Google is nowadays one of the most used search engines for the World Wide Web, the activation of this function integrates the power of such a search engine into the Virtual Research Environment providing thus providing the VRE users with operations for searching the Web and using the discovered objects to accomplish their activities.',7,0)
INSERT INTO FUNCTIONALITY VALUES(11,'Geographic Search','By selecting this function VRE users will be provided with facilities supporting the discovery of Information Objects by issuing geographic queries. These queries are expressed by defining a polygon on a map and by identifying the Information Space in which to search by specifying the set of Collections against which the query will be evaluated.',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,'collectionsnavigator#CollectionsNavigatorPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(0,'newresultset#newresultset')
INSERT INTO PORTLETRELTOFUNCT VALUES(0,'resultpresentation#resultpresentation')
INSERT INTO PORTLETRELTOFUNCT VALUES(0,'Metadata_Viewing_Portlet#Metadata_Viewing_Portlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(0,'VREInformationSpaceEditor#VREInformationSpaceEditorPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(9,'newresultset#newresultset')
INSERT INTO PORTLETRELTOFUNCT VALUES(9,'resultpresentation#resultpresentation')
INSERT INTO PORTLETRELTOFUNCT VALUES(12,'quicksearchportlet#QuickSearchPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(12,'newresultset#newresultset')
INSERT INTO PORTLETRELTOFUNCT VALUES(12,'resultpresentation#resultpresentation')
INSERT INTO PORTLETRELTOFUNCT VALUES(12,'Metadata_Viewing_Portlet#Metadata_Viewing_Portlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(11,'Metadata_Viewing_Portlet#Metadata_Viewing_Portlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(11,'newresultset#newresultset')
INSERT INTO PORTLETRELTOFUNCT VALUES(11,'resultpresentation#resultpresentation')
INSERT INTO PORTLETRELTOFUNCT VALUES(11,'geospatial#GeoSpatialPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(10,'GoogleSearchPortlet#GoogleSearchPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(10,'newresultset#newresultset')
INSERT INTO PORTLETRELTOFUNCT VALUES(10,'resultpresentation#resultpresentation')
INSERT INTO PORTLETRELTOFUNCT VALUES(10,'geospatial#GeoSpatialPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(6,'templatecreator#TemplateGenerator')
INSERT INTO PORTLETRELTOFUNCT VALUES(2,'reportgenerator#ReportGeneratorPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(1,'AnnotationFrontEnd#GenericAnnotationPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(1,'AnnotationFrontEnd#VideoAnnotationPortlet')
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 PORTLETRELTOFUNCT VALUES(0,'layoutcreator#LayoutcreatorPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(1,'layoutcreator#LayoutcreatorPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(2,'layoutcreator#LayoutcreatorPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(3,'layoutcreator#LayoutcreatorPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(4,'layoutcreator#LayoutcreatorPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(5,'layoutcreator#LayoutcreatorPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(6,'layoutcreator#LayoutcreatorPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(9,'layoutcreator#LayoutcreatorPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(10,'layoutcreator#LayoutcreatorPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(11,'layoutcreator#LayoutcreatorPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(12,'layoutcreator#LayoutcreatorPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(0,'userprofileeditingportlet#UserProfileEditingPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(9,'userprofileeditingportlet#UserProfileEditingPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(10,'userprofileeditingportlet#UserProfileEditingPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(11,'userprofileeditingportlet#UserProfileEditingPortlet')
INSERT INTO PORTLETRELTOFUNCT VALUES(12,'userprofileeditingportlet#UserProfileEditingPortlet')
INSERT INTO SERVICES VALUES(1,'ABE','Annotation', '1.00.00')
INSERT INTO SERVICES VALUES(10,'FilterXPathOperator','Search','1.00.00')
INSERT INTO SERVICES VALUES(10,'JoinInnerOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(10,'KeepTopOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(10,'MergeOperator','Search','1.00.00')
INSERT INTO SERVICES VALUES(10,'SearchMaster','Search','1.00.00')
INSERT INTO SERVICES VALUES(10,'SortOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(10,'TransformXsltOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(10,'GoogleService','Search','1.00.00')
INSERT INTO SERVICES VALUES(11,'FilterXPathOperator','Search','1.00.00')
INSERT INTO SERVICES VALUES(11,'JoinInnerOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(11,'KeepTopOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(11,'MergeOperator','Search','1.00.00')
INSERT INTO SERVICES VALUES(11,'SearchMaster','Search','1.00.00')
INSERT INTO SERVICES VALUES(11,'SortOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(11,'TransformXsltOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(12,'FilterXPathOperator','Search','1.00.00')
INSERT INTO SERVICES VALUES(12,'JoinInnerOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(12,'KeepTopOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(12,'MergeOperator','Search','1.00.00')
INSERT INTO SERVICES VALUES(12,'SearchMaster','Search','1.00.00')
INSERT INTO SERVICES VALUES(12,'SortOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(12,'TransformXsltOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(12,'Master','DIR','1.00.00')
INSERT INTO SERVICES VALUES(9,'FilterXPathOperator','Search','1.00.00')
INSERT INTO SERVICES VALUES(9,'JoinInnerOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(9,'KeepTopOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(9,'MergeOperator','Search','1.00.00')
INSERT INTO SERVICES VALUES(9,'SearchMaster','Search','1.00.00')
INSERT INTO SERVICES VALUES(9,'SortOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(9,'TransformXsltOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(0,'FilterXPathOperator','Search','1.00.00')
INSERT INTO SERVICES VALUES(0,'JoinInnerOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(0,'KeepTopOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(0,'MergeOperator','Search','1.00.00')
INSERT INTO SERVICES VALUES(0,'SearchMaster','Search','1.00.00')
INSERT INTO SERVICES VALUES(0,'SortOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(0,'TransformXsltOperatorService','Search','1.00.00')
INSERT INTO SERVICES VALUES(4,'Thumbnailer-service','Portal','1.00.00')

View File

@ -0,0 +1,20 @@
CREATE MEMORY TABLE COLLECTION(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR,DESCRIPTION VARCHAR,MEMBERS VARCHAR,CREATION VARCHAR,LASTUPDATE VARCHAR)
CREATE MEMORY TABLE GHN(ID VARCHAR NOT NULL PRIMARY KEY,HOST VARCHAR,SECURITY VARCHAR,UPTIME VARCHAR,MAINMEMORYVA VARCHAR,MAINMEMORYVS VARCHAR,LOCALAS VARCHAR,LOCATION VARCHAR,COUNTRY VARCHAR,DOMAIN VARCHAR)
CREATE MEMORY TABLE MCOLLECTION(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR,DESCRIPTION VARCHAR,RELATEDCOLLECTIONID VARCHAR NOT NULL,CONSTRAINT SYS_FK_50 FOREIGN KEY(RELATEDCOLLECTIONID) REFERENCES COLLECTION(ID))
CREATE MEMORY TABLE VRE(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,DESCRIPTION VARCHAR NOT NULL,VREDESIGNER VARCHAR NOT NULL,VREMANAGER VARCHAR NOT NULL,INTERVALFROM DATE,INTERVALTO DATE,EPR VARCHAR,STATUS VARCHAR)
CREATE MEMORY TABLE CS(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,DESCRIPTION VARCHAR NOT NULL)
CREATE MEMORY TABLE RUNNINGINSTANCE(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL, CLASS VARCHAR NOT NULL)
CREATE MEMORY TABLE GHNRELATEDRI(GHNID VARCHAR NOT NULL,RIID VARCHAR NOT NULL,PRIMARY KEY(GHNID,RIID))
CREATE MEMORY TABLE RIRELATEDPKG(RIID VARCHAR NOT NULL,PKGID INTEGER NOT NULL,PRIMARY KEY(RIID,PKGID))
CREATE MEMORY TABLE FUNCTIONALITY(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,DESCRIPTION VARCHAR NOT NULL,FATHER INTEGER,FLAG INTEGER NOT NULL)
CREATE MEMORY TABLE METADATAFORMAT(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,SCHEMAURI VARCHAR NOT NULL,LANGUAGE VARCHAR NOT NULL)
CREATE MEMORY TABLE NATIVEMDF(MDCOLLID VARCHAR NOT NULL,MDFID VARCHAR NOT NULL,PRIMARY KEY(MDCOLLID,MDFID),CONSTRAINT SYS_FK_178 FOREIGN KEY(MDCOLLID) REFERENCES MCOLLECTION(ID),CONSTRAINT SYS_FK_179 FOREIGN KEY(MDFID) REFERENCES METADATAFORMAT(ID))
CREATE MEMORY TABLE VRERELATEDCOLLECTION(VREID VARCHAR NOT NULL,COLLID VARCHAR NOT NULL,PRIMARY KEY(VREID,COLLID))
CREATE MEMORY TABLE VRERELATEDGHN(VREID VARCHAR NOT NULL,GHNID VARCHAR NOT NULL,PRIMARY KEY(VREID,GHNID))
CREATE MEMORY TABLE VRERELATEDCS(VREID VARCHAR NOT NULL,CSID VARCHAR NOT NULL,PRIMARY KEY(VREID,CSID))
CREATE MEMORY TABLE VRERELATEDMETADATAFORMAT(VREID VARCHAR,COLLID VARCHAR,MFID VARCHAR)
CREATE MEMORY TABLE SERVICES(ID INTEGER NOT NULL,NAME VARCHAR NOT NULL,CLASS VARCHAR NOT NULL, VERSION VARCHAR NOT NULL, PRIMARY KEY(ID,NAME,CLASS),CONSTRAINT SYS_FK_189 FOREIGN KEY(ID) REFERENCES FUNCTIONALITY(ID))
CREATE MEMORY TABLE VRERELATEDFUNCT(VREID VARCHAR NOT NULL,FUNCID VARCHAR NOT NULL,PRIMARY KEY(VREID,FUNCID))
CREATE MEMORY TABLE RELATEDSERVICEID(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,CLASS VARCHAR NOT NULL)
CREATE MEMORY TABLE PORTLETRELTOFUNCT(FUNCID INTEGER NOT NULL,PORTLETCLASS VARCHAR NOT NULL, FOREIGN KEY(FUNCID) REFERENCES FUNCTIONALITY(ID) )
CREATE MEMORY TABLE NEEDEDRESOURCES(ID VARCHAR NOT NULL, TYPE VARCHAR NOT NULL, PRIMARY KEY(ID))

View File

@ -11,7 +11,7 @@
<Main>
<Description>Allows user to create new VRE</Description>
<Name>VREModeler-service</Name>
<Version>1.01.2</Version>
<Version>1.01.02</Version>
<Dependencies>
<Dependency>
<Service>

View File

@ -18,10 +18,8 @@
<!-- the polling time: how often the IS synchronizes its content with the RPD values -->
<agg:PollIntervalMillis>60000</agg:PollIntervalMillis>
<agg:ResourcePropertyNames>modeler:Id</agg:ResourcePropertyNames>
<agg:ResourcePropertyNames>modeler:firstReport</agg:ResourcePropertyNames>
<agg:ResourcePropertyNames>modeler:secondReport</agg:ResourcePropertyNames>
</agg:GetMultipleResourcePropertiesPollType>
</agg:AggregatorConfig>
</agg:AggregatorConfig>
<agg:AggregatorData/>

View File

@ -0,0 +1,50 @@
package org.gcube.vremanagement.vremodeler.consumers;
import javax.xml.namespace.QName;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBECollectionQuery;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.BaseNotificationConsumer;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
import org.gcube.vremanagement.vremodeler.resources.handlers.CollectionHandler;
public class CollectionConsumer extends BaseNotificationConsumer{
private GCUBELog logger= new GCUBELog(GHNConsumer.class);
public static final QName collectionQName= new QName("http://gcube-system.org/namespaces/informationsystem/registry","Collection");
private GCUBEScope scope;
public CollectionConsumer(GCUBEScope scope){
super();
this.scope=scope;
}
public void onNotificationReceived(NotificationEvent event){
try{
logger.trace("notificetion received");
ServiceContext.getContext().setScope(this.scope);
String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();
if (operation.compareTo("create")==0){
logger.trace("adding a new GHN in DB");
ISClient client=GHNContext.getImplementation(ISClient.class);
GCUBECollectionQuery query= client.getQuery(GCUBECollectionQuery.class);
query.addAtomicConditions(new AtomicCondition("/ID",id));
Thread.sleep(60000);
new CollectionHandler().add(client.execute(query, this.scope).get(0));
} else if (operation.compareTo("remove")==0){
logger.trace("removing a GHN from DB");
}
}catch(Exception e){logger.error("error in notification received",e);}
}
}

View File

@ -0,0 +1,59 @@
package org.gcube.vremanagement.vremodeler.consumers;
import java.io.StringReader;
import javax.xml.namespace.QName;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericResourceQuery;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.BaseNotificationConsumer;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
import org.gcube.vremanagement.vremodeler.resources.handlers.FunctionalityHandler;
import org.gcube.vremanagement.vremodeler.resources.kxml.KGCUBEGenericFunctionalityResource;
public class FunctionalityConsumer extends BaseNotificationConsumer{
private GCUBELog logger= new GCUBELog(GHNConsumer.class);
public static final QName functionalityQName= new QName("http://gcube-system.org/namespaces/informationsystem/registry","GenericResource");
private String resourceId;
private GCUBEScope scope;
public FunctionalityConsumer(GCUBEScope scope, String resourceId){
super();
this.scope=scope;
this.resourceId= resourceId;
}
public void onNotificationReceived(NotificationEvent event){
try{
logger.trace("notificetion received");
ServiceContext.getContext().setScope(this.scope);
String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();
if (id.compareTo(this.resourceId)==0 && operation.compareTo("modify")==0){
KGCUBEGenericFunctionalityResource resource= new KGCUBEGenericFunctionalityResource();
ISClient client=GHNContext.getImplementation(ISClient.class);
GCUBEGenericResourceQuery query= client.getQuery(GCUBEGenericResourceQuery.class);
query.addAtomicConditions(new AtomicCondition("/Profile/Name","FuctionalitiesResource"), new AtomicCondition("/Profile/SecondaryType","VREModelerResource"));
GCUBEGenericQuery genericQuery= client.getQuery(GCUBEGenericQuery.class);
genericQuery.setExpression(query.getExpression());
resource.load(new StringReader(client.execute(genericQuery, ServiceContext.getContext().getScope()).get(0).toString()));
Thread.sleep(60000);
//FunctionalityHandler
FunctionalityHandler functionalityHandler= new FunctionalityHandler();
functionalityHandler.add(resource);
}
}catch(Exception e){logger.error("error in notification received",e);}
}
}

View File

@ -0,0 +1,49 @@
package org.gcube.vremanagement.vremodeler.consumers;
import javax.xml.namespace.QName;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGHNQuery;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.BaseNotificationConsumer;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
import org.gcube.vremanagement.vremodeler.resources.handlers.GHNHandler;
public class GHNConsumer extends BaseNotificationConsumer{
private GCUBELog logger= new GCUBELog(GHNConsumer.class);
public static final QName ghnQName= new QName("http://gcube-system.org/namespaces/informationsystem/registry","GHN");
private GCUBEScope scope;
public GHNConsumer(GCUBEScope scope){
super();
this.scope=scope;
}
public void onNotificationReceived(NotificationEvent event){
try{
logger.trace("notificetion received");
ServiceContext.getContext().setScope(this.scope);
String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();
if (operation.compareTo("create")==0){
logger.trace("adding a new GHN in DB");
ISClient client=GHNContext.getImplementation(ISClient.class);
GCUBEGHNQuery query= client.getQuery(GCUBEGHNQuery.class);
query.addAtomicConditions(new AtomicCondition("/ID",id));
Thread.sleep(60000);
new GHNHandler().add(client.execute(query, this.scope).get(0));
} else if (operation.compareTo("remove")==0){
logger.trace("removing a GHN from DB");
}
}catch(Exception e){logger.error("error in notification received",e);}
}
}

View File

@ -0,0 +1,52 @@
package org.gcube.vremanagement.vremodeler.consumers;
import javax.xml.namespace.QName;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBEMCollectionQuery;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.BaseNotificationConsumer;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent;
import org.gcube.common.core.resources.GCUBEMCollection;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
import org.gcube.vremanagement.vremodeler.resources.handlers.MCollectionHandler;
public class MCollectionConsumer extends BaseNotificationConsumer{
public static final QName mCollectionQName= new QName("http://gcube-system.org/namespaces/informationsystem/registry","MetadataCollection");
private GCUBELog logger= new GCUBELog(MCollectionConsumer.class);
private GCUBEScope scope;
public MCollectionConsumer(GCUBEScope scope){
super();
this.scope=scope;
}
public void onNotificationReceived(NotificationEvent event){
try{
logger.trace("notificetion received");
ServiceContext.getContext().setScope(this.scope);
String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();
if (operation.compareTo("create")==0){
logger.trace("adding a new MCollection in DB");
ISClient client=GHNContext.getImplementation(ISClient.class);
GCUBEMCollectionQuery query= client.getQuery(GCUBEMCollectionQuery.class);
query.addAtomicConditions(new AtomicCondition("/ID",id));
GCUBEMCollection mColl= client.execute(query, this.scope).get(0);
Thread.sleep(60000);
new MCollectionHandler(mColl.getRelCollection().getCollectionID()).add(mColl);
} else if (operation.compareTo("remove")==0){
logger.trace("removing a GHN from DB");
}
}catch(Exception e){logger.error("error in notification received",e);}
}
}

View File

@ -0,0 +1,54 @@
package org.gcube.vremanagement.vremodeler.consumers;
import javax.xml.namespace.QName;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.BaseNotificationConsumer;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent;
import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
import org.gcube.vremanagement.vremodeler.resources.handlers.RunningInstancesHandler;
public class RunningInstanceConsumer extends BaseNotificationConsumer{
private GCUBELog logger= new GCUBELog(RunningInstanceConsumer.class);
public static final QName riQName= new QName("http://gcube-system.org/namespaces/informationsystem/registry","RunningInstance");
private GCUBEScope scope;
public RunningInstanceConsumer(GCUBEScope scope){
super();
this.scope=scope;
}
public void onNotificationReceived(NotificationEvent event){
try{
logger.trace("notificetion received");
ServiceContext.getContext().setScope(this.scope);
String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();
if (operation.compareTo("create")==0){
logger.trace("adding a new RI in DB");
ISClient client=GHNContext.getImplementation(ISClient.class);
GCUBERIQuery query= client.getQuery(GCUBERIQuery.class);
logger.trace("id: "+id);
query.addAtomicConditions(new AtomicCondition("/ID",id));
Thread.sleep(60000);
GCUBERunningInstance ri= client.execute(query, this.scope).get(0);
new RunningInstancesHandler(ri.getGHNID()).add(ri);
} else if (operation.compareTo("remove")==0){
logger.trace("removing a GHN from DB");
}
}catch(Exception e){logger.error("error in notification received",e);}
}
}

View File

@ -21,10 +21,10 @@ import org.gcube.vremanagement.vremodeler.impl.util.Listable;
*/
public class DBInterface {
private static Connection conn;
private static String dbFile = ServiceContext.getContext().getPersistenceRoot()+ File.separator + "vdldb";
private static String dbFile = ServiceContext.getContext().getPersistenceRoot()+ File.separator + "vreModelerDB";
private static GCUBELog logger = new GCUBELog(DBInterface.class);
/**
@ -32,6 +32,13 @@ public class DBInterface {
* @return
* @throws SQLException
*/
public static boolean dbAlreadyCreated(){
File file= new File(dbFile+ServiceContext.getContext().getScope().toString().replace("/", "-")+".script");
logger.trace("the db "+file.getName()+" exists ?"+ file.exists());
return file.exists();
}
public static Connection connect() throws SQLException{
if(conn==null)
@ -49,10 +56,13 @@ public class DBInterface {
// of the db.
// It can contain directory names relative to the
// current working directory
dbFile=dbFile+ServiceContext.getContext().getScope().toString().replace("/", "-");
conn = DriverManager.getConnection("jdbc:hsqldb:file:"
+ dbFile, // filenames
"sa", // username
""); // password
""); // password
}
return conn;
@ -80,7 +90,7 @@ public class DBInterface {
}
public static synchronized void insertIntoListable(String table, List<? extends Listable> values) throws GCUBEFault {
public static synchronized void insertIntoListable(String table, Listable... values) throws GCUBEFault {
if (values==null) throw new GCUBEFault();
Statement st = null;
@ -134,19 +144,19 @@ public class DBInterface {
* @param values
* @throws RemoteException
*/
public static synchronized void InsertInto(String table, List<List<String>> values) throws GCUBEFault {
public static synchronized void insertInto(String table, String[]... rows) throws GCUBEFault {
if (values==null) throw new GCUBEFault();
Statement st = null;
try{
st = conn.createStatement(); // statement objects can be reused with
}catch(SQLException e){//logger.error("error creating SQL statement");
throw new GCUBEFault(e);}
Statement st = null;
try{
st = conn.createStatement(); // statement objects can be reused with
}catch(SQLException e){//logger.error("error creating SQL statement");
throw new GCUBEFault(e);}
StringBuffer insertQuery;
for (List<String> row: values)
for (String[] row: rows)
{
insertQuery=new StringBuffer();
@ -177,6 +187,7 @@ public class DBInterface {
throw new GCUBEFault(e);}
}
/**
*
* @param query
@ -211,5 +222,5 @@ public class DBInterface {
st.executeUpdate(query);
st.close();
}
}

View File

@ -1,16 +1,16 @@
package org.gcube.vremanagement.vremodeler.db;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.URI;
import java.rmi.RemoteException;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
@ -19,43 +19,33 @@ import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
import org.apache.axis.components.uuid.UUIDGen;
import org.apache.axis.components.uuid.UUIDGenFactory;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.faults.GCUBEFault;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBECSQuery;
import org.gcube.common.core.informationsystem.client.queries.GCUBECollectionQuery;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGHNQuery;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericResourceQuery;
import org.gcube.common.core.informationsystem.client.queries.GCUBEMCollectionQuery;
import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery;
import org.gcube.common.core.informationsystem.client.queries.GCUBEServiceQuery;
import org.gcube.common.core.resources.GCUBECS;
import org.gcube.common.core.resources.GCUBECollection;
import org.gcube.common.core.resources.GCUBEGenericResource;
import org.gcube.common.core.resources.GCUBEHostingNode;
import org.gcube.common.core.resources.GCUBEMCollection;
import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.resources.GCUBEService;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.handlers.GCUBEServiceClientImpl;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
import org.gcube.vremanagement.vremodeler.impl.resources.Functionality;
import org.gcube.vremanagement.vremodeler.impl.resources.MainFunctionality;
import org.gcube.vremanagement.vremodeler.impl.resources.Service;
import org.gcube.vremanagement.vremodeler.impl.resources.kxml.KGCUBEGenericFunctionalityResource;
import org.gcube.vremanagement.vremodeler.impl.util.MBrokerServiceHandler;
import org.gcube.vremanagement.vremodeler.impl.util.MFRelationDerivate;
import org.gcube.vremanagement.vremodeler.impl.util.MFRelationNative;
import org.gcube.vremanagement.vremodeler.impl.util.MetadataFormat;
import org.gcube.vremanagement.vremodeler.resources.Functionality;
import org.gcube.vremanagement.vremodeler.resources.MainFunctionality;
import org.gcube.vremanagement.vremodeler.resources.Service;
import org.gcube.vremanagement.vremodeler.resources.handlers.CollectionHandler;
import org.gcube.vremanagement.vremodeler.resources.handlers.FunctionalityHandler;
import org.gcube.vremanagement.vremodeler.resources.handlers.GHNHandler;
import org.gcube.vremanagement.vremodeler.resources.handlers.GhnRiRelationHandler;
import org.gcube.vremanagement.vremodeler.resources.handlers.MCollectionHandler;
import org.gcube.vremanagement.vremodeler.resources.handlers.MetadataFormatHandler;
import org.gcube.vremanagement.vremodeler.resources.handlers.NativeMetadataFormatHandler;
import org.gcube.vremanagement.vremodeler.resources.handlers.RunningInstancesHandler;
import org.gcube.vremanagement.vremodeler.resources.kxml.KGCUBEGenericFunctionalityResource;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
/**
*
@ -64,11 +54,28 @@ import org.xml.sax.InputSource;
*/
public class IStoDBUtil {
private static GCUBELog logger = new GCUBELog(IStoDBUtil.class.getName());
private static UUIDGen uuidMFGEN= UUIDGenFactory.getUUIDGen();
private static GCUBELog logger = new GCUBELog(IStoDBUtil.class);
private static ISClient queryClient;
private static void createTables(GCUBEScope scope) throws GCUBEFault{
try{
DBInterface.connect();
File file= ServiceContext.getContext().getConfigFile("hsqldb/vreModelerDBInitializer", false);
FileReader fileReader= new FileReader(file);
BufferedReader in = new BufferedReader(fileReader);
String line;
while ((line=in.readLine())!=null){
logger.trace(line);
DBInterface.ExecuteUpdate(line);
}
}catch (Exception e){
logger.error("error creating tables",e);
throw new GCUBEFault(e); }
}
/**
* Initialize all database tables
*
@ -77,24 +84,13 @@ public class IStoDBUtil {
public static void initDB(GCUBEScope scope) throws GCUBEFault{
logger.info("Starting initialization!!");
cleanDB();
insertCollection(scope);
logger.debug("initialization: collection");
insertMetadataCollection(scope);
logger.debug("initialization: metadata");
//insertCS(scope);
//logger.debug("initialization: CS");
//insertServices(scope);
insertGHN(scope);
logger.debug("initialization: GHN");
if (!DBInterface.dbAlreadyCreated())
createTables(scope);
cleanDB(scope);
insertNeededResources(scope);
logger.debug("initialization: Needed Resources");
functionalitiesRecovery(scope);
logger.debug("initialization: Functionalities");
logger.info("Database Initialized!!");
}
private static void cleanDB() throws GCUBEFault
private static void cleanDB(GCUBEScope scope) throws GCUBEFault
{
try{
DBInterface.connect();
@ -104,20 +100,20 @@ public class IStoDBUtil {
//DBInterface.deleteAll("VRERELATEDFUNCT");
//DBInterface.deleteAll("VRERELATEDGHN");
//DBInterface.deleteAll("VRE");
DBInterface.deleteAll("nativemdf");
DBInterface.deleteAll("derivablemdf");
DBInterface.deleteAll("mdformat");
DBInterface.deleteAll("mdcollection");
DBInterface.deleteAll("collection");
DBInterface.deleteAll("relatedserviceid");
DBInterface.deleteAll("ghn");
DBInterface.deleteAll("runninginstance");
DBInterface.deleteAll("ghnrelatedri");
DBInterface.deleteAll("cs");
DBInterface.deleteAll(NativeMetadataFormatHandler.tableName);
//DBInterface.deleteAll("derivablemdf");
DBInterface.deleteAll(MetadataFormatHandler.tableName);
DBInterface.deleteAll(MCollectionHandler.tableName);
DBInterface.deleteAll(CollectionHandler.tableName);
//DBInterface.deleteAll("relatedserviceid");
DBInterface.deleteAll(GHNHandler.tableName);
DBInterface.deleteAll(RunningInstancesHandler.tableName);
DBInterface.deleteAll(GhnRiRelationHandler.tableName);
//DBInterface.deleteAll("cs");
DBInterface.deleteAll("NEEDEDRESOURCES");
DBInterface.deleteAll("PORTLETRELTOFUNCT");
DBInterface.deleteAll("SERVICES");
DBInterface.deleteAll("FUNCTIONALITY");
DBInterface.deleteAll(FunctionalityHandler.portletTableName);
DBInterface.deleteAll(FunctionalityHandler.serviceTableName);
DBInterface.deleteAll(FunctionalityHandler.functionalityTableName);
}catch (SQLException e){
logger.error("error cleaning sqlDB",e);
throw new GCUBEFault(e); }
@ -135,445 +131,24 @@ public class IStoDBUtil {
//NEEDEDRESOURCES(ID, TYPE)
List<List<String>> values = new ArrayList<List<String>>(genericResourcesList.size());
List<String[]> values = new ArrayList<String[]>(genericResourcesList.size());
List<String> row;
for (GCUBEGenericResource gen :genericResourcesList){
row= new ArrayList<String>(2);
row.add(gen.getID());
row.add(gen.getType());
values.add(row);
values.add(row.toArray(new String[2]));
}
try{
DBInterface.connect();
DBInterface.InsertInto("NEEDEDRESOURCES", values);
DBInterface.insertInto("NEEDEDRESOURCES", values.toArray(new String[0][0]));
}catch (SQLException e){
logger.error("VDLModel: DB error ",e);
throw new GCUBEFault(e);
}
}
private static void insertCollection(GCUBEScope scope) throws GCUBEFault {
List<GCUBECollection> collectionList= null;
try{
if (queryClient==null) queryClient= GHNContext.getImplementation(ISClient.class);
GCUBECollectionQuery query= queryClient.getQuery(GCUBECollectionQuery.class);
query.addGenericCondition("$result/Profile/IsUserCollection[string(@value) eq 'true']");
collectionList= queryClient.execute(query, scope);
}catch(Exception e ){logger.error("Error queryng IS"); throw new GCUBEFault(e); }
try{
if (collectionList.size()!=0){
//preparing collectionList to insert
//table declaration:
//COLLECTION(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR,DESCRIPTION VARCHAR,MEMBERS VARCHAR,CREATION VARCHAR,LASTUPDATE VARCHAR)
List<List<String>> values = new ArrayList<List<String>>(collectionList.size());
List<String> row;
for (GCUBECollection col: collectionList ){
row= new ArrayList<String>(6);
row.add(col.getID());
row.add(col.getName());
row.add(col.getDescription()==null? "not provided" : col.getDescription());
row.add(col.getNumberOfMembers()+"");
row.add(col.getCreationTime().getTime().getTime()+"");
row.add(col.getLastUpdateTime().getTime().getTime()+"");
values.add(row);
}
//insert the values in the database
DBInterface.connect();
DBInterface.InsertInto("collection", values);
}
}catch (SQLException e){
logger.error("VDLModel: DB error ",e);
throw new GCUBEFault(e); }
}
/**
*
* @param epr
* @throws RemoteException
*/
private static void insertMetadataCollection(GCUBEScope scope) throws GCUBEFault {
List<GCUBEMCollection> collectionList;
try{
if (queryClient==null) queryClient= GHNContext.getImplementation(ISClient.class);
GCUBEMCollectionQuery query= queryClient.getQuery(GCUBEMCollectionQuery.class);
query.addGenericCondition("$result/Profile/IsUserCollection[string(@value) eq 'true']");
collectionList= queryClient.execute(query, scope);
}catch(Exception e ){logger.error("Error queryng IS"); throw new GCUBEFault(e); }
try{
if (collectionList.size()!=0){
//preparing collectionList to insert
//table declaration:
//MDCOLLECTION(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR,DESCRIPTION VARCHAR,RELATEDCOLLECTIONID VARCHAR NOT NULL)
String uuid;
MetadataFormat mf;
List<List<String>> values = new ArrayList<List<String>>(collectionList.size());
List<String> row;
List<MetadataFormat> metadataFormatList= new ArrayList<MetadataFormat>();
List<MFRelationNative> nativeMetadataFormatList= new ArrayList<MFRelationNative>();
List<MFRelationDerivate> derivateMetadataFormatList= new ArrayList<MFRelationDerivate>();
for (GCUBEMCollection col: collectionList ){
row= new ArrayList<String>(4);
row.add(col.getID());
row.add(col.getName());
row.add(col.getDescription());
row.add(col.getRelCollection().getCollectionID());
values.add(row);
//adding the native metadataformat
uuid=uuidMFGEN.nextUUID();
mf= new MetadataFormat(uuid, col.getMetaFormat().getName(), col.getMetaFormat().getSchemaURI(), col.getMetaFormat().getLanguage());
logger.trace(uuid+ " "+mf.getName() + " "+mf.getSchemaURI()+" "+mf.getLanguage()+" ");
if (!metadataFormatList.contains(mf)){
metadataFormatList.add(mf);
nativeMetadataFormatList.add(new MFRelationNative(col.getID(), mf.getId() ));
}else nativeMetadataFormatList.add(new MFRelationNative(col.getID(), metadataFormatList.get(metadataFormatList.indexOf(mf)).getId()));
/*
try {
ServiceContext.getContext().setScope(scope);
derivateMetadataFormatList.addAll(getMFDerivate(metadataFormatList, col));
} catch (Exception e) {
logger.error("Error in getMFDerivate"+e);
e.printStackTrace();
}*/
}
//insert values in the database
DBInterface.connect();
DBInterface.InsertInto("mdcollection", values);
DBInterface.insertIntoListable("mdformat", metadataFormatList );
DBInterface.insertIntoListable("nativemdf", nativeMetadataFormatList);
DBInterface.insertIntoListable("derivablemdf", derivateMetadataFormatList );
}
}catch (SQLException e){
logger.error("VDLModel: DB error ",e);
throw new GCUBEFault(e); }
}
/*
private static List<MFRelationDerivate> getMFDerivate(List<MetadataFormat> mdfList, GCUBEMCollection col ) throws Exception{
MBrokerServiceHandler<String[], MetadataFormat> sHandler= new MBrokerServiceHandler<String[],MetadataFormat >(){
@Override
protected String[] makeCall(MetadataBrokerPortType mbportType) throws Exception {
FindPossibleTransformationPrograms fptp= new FindPossibleTransformationPrograms();
MetadataBrokerFormat mbInFormat= new MetadataBrokerFormat();
mbInFormat.setType("collection");
String lng=getParameter().getLanguage();
mbInFormat.setLanguage(lng);
String schema=getParameter().getName()+"="+getParameter().getSchemaURI().toString();
mbInFormat.setSchema(schema);
fptp.setInputFormat(mbInFormat);
fptp.setOutputFormat(null);
FindPossibleTransformationProgramsResponse tpRes= mbportType.findPossibleTransformationPrograms(fptp);
String[] toReturn= tpRes.getTransformationProgram();
return toReturn;
}
};
sHandler.setHandled(new GCUBEServiceClientImpl());
sHandler.setParameter(mdfList.get(mdfList.size()-1));
sHandler.run();
String[] resList=sHandler.getReturnValue();
List<MFRelationDerivate> derivatedList= new ArrayList<MFRelationDerivate>();
if (resList!=null && resList.length>0){
String schemaExpr="//TransformationProgram/Output[@name='TPOutput']/Schema/text()";
String languageExpr="//TransformationProgram/Output[@name='TPOutput']/Language[@isVariable='false']/text()";
String typeExpr="//TransformationProgram/Output[@name='TPOutput']/Type/text()";
String tpIdExpr="/Resource/ID/text()";
Document doc;
String tpId, transformationType,lng;
String[] schema;
for(String res: resList){
doc= DocumentBuilderFactory.newInstance().newDocumentBuilder().parse( new InputSource(new StringReader(res)));
//retrieving the TP type
transformationType=executeXpathOnDocument(typeExpr, doc).getWriter().toString();
if (transformationType.compareTo("collection")==0){
//retrieving the language
lng= executeXpathOnDocument(languageExpr, doc).getWriter().toString();
//retrieving the Transformation program ID
tpId= executeXpathOnDocument(tpIdExpr, doc).getWriter().toString();
//retrieving the schema
schema= executeXpathOnDocument(schemaExpr, doc).getWriter().toString().split("=");
//creating the new MDFormat
boolean isLngAny= false;
MetadataFormat mfTemp;
if (lng.compareTo("")==0){
mfTemp=new MetadataFormat(uuidMFGEN.nextUUID(), schema[0], new URI(schema[1]), MetadataFormat.ANY_LANGUAGE);
isLngAny=true;
}else
mfTemp=new MetadataFormat(uuidMFGEN.nextUUID(), schema[0], new URI(schema[1]), lng);
//if the MDFromat already exists use its id else it uses the new ID
MFRelationDerivate mfRelTemp;
MetadataFormat existingMetadataFormat;
if (mdfList.contains(mfTemp)){
existingMetadataFormat= mdfList.get(mdfList.indexOf(mfTemp));
if (isLngAny) existingMetadataFormat.setLanguage(MetadataFormat.ANY_LANGUAGE);
mfRelTemp =new MFRelationDerivate(col.getID(), existingMetadataFormat.getId(), tpId );
}else {
mfRelTemp =new MFRelationDerivate(col.getID(), mfTemp.getId(), tpId );
mdfList.add(mfTemp);
}
derivatedList.add(mfRelTemp);
}
}
}
return derivatedList;
}
*/
/**
*
* @param epr
* @throws RemoteException
*/
@SuppressWarnings("unused")
private static void insertCS(GCUBEScope scope) throws GCUBEFault {
List<GCUBECS> csList= null;
try{
if (queryClient==null) queryClient= GHNContext.getImplementation(ISClient.class);
GCUBECSQuery query= queryClient.getQuery(GCUBECSQuery.class);
csList= queryClient.execute(query, scope);
}catch(Exception e ){logger.error("Error queryng IS"); throw new GCUBEFault(e); }
try{
if (csList.size()!=0){
//preparing collectionList to insert
//table declaration:
//TABLE CS(ID VARCHAR NOT NULL PRIMARY KEY, NAME VARCHAR NOT NULL, DESCRIPTION VARCHAR NOT NULL)
List<List<String>> values = new ArrayList<List<String>>(csList.size());
List<String> row;
for (GCUBECS cs: csList ){
row= new ArrayList<String>(3);
row.add(cs.getID());
row.add(cs.getProcessName());
row.add(cs.getDescription());
values.add(row);
}
//insert the values in the database
DBInterface.connect();
DBInterface.InsertInto("cs", values);
}
}catch (SQLException e){
logger.error("error inserting cs",e);
throw new GCUBEFault(e); }
}
@SuppressWarnings("unused")
private static void insertQuality(EndpointReferenceType epr) throws RemoteException {
}
private static void insertGHN(GCUBEScope scope) throws GCUBEFault {
List<GCUBEHostingNode> ghnList= null;
List<GCUBERunningInstance> riTotalList= new ArrayList<GCUBERunningInstance>();;
try{
if (queryClient==null) queryClient= GHNContext.getImplementation(ISClient.class);
GCUBEGHNQuery query= queryClient.getQuery(GCUBEGHNQuery.class);
query.addGenericCondition("$result/Profile/GHNDescription/Type/string() eq 'Dynamic'");
ghnList= queryClient.execute(query, scope);
}catch(Exception e ){logger.error("Error queryng IS"); throw new GCUBEFault(e); }
if (ghnList.size()!=0){
List<List<String>> riValues= null;
List<List<String>> riRelatedGHNvalues=null;
//preparing collectionList to insert
//table declaration:
//TABLE DHN(ID VARCHAR NOT NULL PRIMARY KEY,HOST VARCHAR,SECURITY VARCHAR,UPTIME VARCHAR,MAINMEMORYVA VARCHAR,MAINMEMORYVS VARCHAR,LOCALAS VARCHAR,LOCATION VARCHAR,COUNTRY VARCHAR,DOMAIN VARCHAR)
List<List<String>> values = new ArrayList<List<String>>(ghnList.size());
List<String> row;
for (GCUBEHostingNode ghn: ghnList ){
row= new ArrayList<String>(10);
String id= ghn.getID();
row.add(id);
row.add(ghn.getNodeDescription().getName());
row.add(ghn.getNodeDescription().isSecurityEnabled()+"");
row.add(ghn.getNodeDescription().getUptime());
row.add(ghn.getNodeDescription().getMemory().getVirtualAvailable()+"");
row.add(ghn.getNodeDescription().getMemory().getVirtualSize()+"");
row.add(ghn.getNodeDescription().getLocalAvailableSpace()+"");
row.add(ghn.getSite().getLocation());
row.add(ghn.getSite().getCountry());
row.add(ghn.getSite().getDomain());
values.add(row);
//Retreiving relatedRI to this GHN
List<GCUBERunningInstance> riList = null;
try {
GCUBERIQuery queryRI= queryClient.getQuery(GCUBERIQuery.class);
queryRI.addGenericCondition("$result/Profile/GHN[string(@UniqueID) eq '"+id+"']");
riList= queryClient.execute(queryRI, scope);
}catch(Exception e ){logger.warn("Error retrieving RIs for GHN "+id);}
if (riList!=null & riList.size()>0)
riTotalList.addAll(riList);
}
//inserting value for tables RI and RIRelatedGHN
//RUNNINGINSTANCE(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL, CLASS VARCHAR NOT NULL)
//GHNRELATEDRI(DHNID VARCHAR NOT NULL,RIID VARCHAR NOT NULL,PRIMARY KEY(DHNID,RIID))
if (riTotalList!=null & riTotalList.size()>0){
riValues = new ArrayList<List<String>>();
List<String> riRow;
riRelatedGHNvalues = new ArrayList<List<String>>(riTotalList.size());
List<String> riRelatedGHNrow;
for (GCUBERunningInstance ri :riTotalList){
riRow= new ArrayList<String>(3);
riRow.add(ri.getID());
riRow.add(ri.getServiceName());
riRow.add(ri.getServiceClass());
riValues.add(riRow);
riRelatedGHNrow= new ArrayList<String>();
riRelatedGHNrow.add(ri.getGHNID());
riRelatedGHNrow.add(ri.getID());
riRelatedGHNvalues.add(riRelatedGHNrow);
}
}
try{
//insert the values in the database
DBInterface.connect();
DBInterface.InsertInto("ghn", values);
DBInterface.InsertInto("runninginstance",riValues );
DBInterface.InsertInto("GHNRELATEDRI",riRelatedGHNvalues );
}catch (SQLException e){
logger.error("error inserting ghn",e);
throw new GCUBEFault(e); }
}
}
@SuppressWarnings("unused")
private static void insertServices(GCUBEScope scope) throws GCUBEFault {
List<GCUBEService> serviceList= null;
try{
if (queryClient==null) queryClient= GHNContext.getImplementation(ISClient.class);
GCUBEServiceQuery query= queryClient.getQuery(GCUBEServiceQuery.class);
serviceList= queryClient.execute(query, scope);
}catch(Exception e ){logger.error("Error queryng IS"); throw new GCUBEFault(e); }
if (serviceList.size()>0){
//preparing collectionList to insert
//table declaration:
// RELATEDSERVICEID(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,CLASS VARCHAR NOT NULL)
//this table represent the service available on the IS
List<List<String>> values = new ArrayList<List<String>>(serviceList.size());
List<String> row;
for (GCUBEService service: serviceList ){
row = new ArrayList<String>(3);
row.add(service.getID());
row.add(service.getServiceName());
row.add(service.getServiceClass());
values.add(row);
}
try{
DBInterface.connect();
DBInterface.InsertInto("relatedserviceid", values);
}catch (SQLException e){
logger.error("error DB",e);
throw new GCUBEFault(e); }
}
}
private static StreamResult executeXpathOnDocument(String xpathString, Document doc) throws Exception{
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"yes");
XPath xpath= XPathFactory.newInstance().newXPath();
NodeList set = (NodeList) xpath.evaluate(xpathString,doc, XPathConstants.NODESET);
StreamResult sr = new StreamResult(new StringWriter());
try {transformer.transform(new DOMSource(set.item(0)),sr);}catch(Exception ignore) {}
return sr;
}
private static void functionalitiesRecovery(GCUBEScope scope) throws GCUBEFault{
KGCUBEGenericFunctionalityResource resource= new KGCUBEGenericFunctionalityResource();
try{
if (queryClient==null) queryClient= GHNContext.getImplementation(ISClient.class);
GCUBEGenericResourceQuery query= queryClient.getQuery(GCUBEGenericResourceQuery.class);
query.addAtomicConditions(new AtomicCondition("/Profile/Name","FuctionalitiesResource"), new AtomicCondition("/Profile/SecondaryType","VREModelerResource"));
GCUBEGenericQuery genericQuery= queryClient.getQuery(GCUBEGenericQuery.class);
genericQuery.setExpression(query.getExpression());
resource.load(new StringReader(queryClient.execute(genericQuery, scope).get(0).toString()));
}catch(Exception e ){logger.error("Error queryng IS"); throw new GCUBEFault(e); }
try{
DBInterface.connect();
PreparedStatement psFunctionality=DBInterface.getConnection().prepareStatement("INSERT INTO FUNCTIONALITY VALUES(?,?,?,?,?)");
PreparedStatement psServices=DBInterface.getConnection().prepareStatement("INSERT INTO SERVICES VALUES(?,?,?,?)");
PreparedStatement psPortlets=DBInterface.getConnection().prepareStatement("INSERT INTO PORTLETRELTOFUNCT VALUES(?,?)");
int id=0;
for (MainFunctionality mainFunctionality: resource.getBody().getMainFunctionalities()){
psFunctionality.setInt(1, id);
psFunctionality.setString(2, mainFunctionality.getName());
psFunctionality.setString(3, mainFunctionality.getDescription());
psFunctionality.setNull(4, Types.INTEGER);
psFunctionality.setInt(5, 0);
psFunctionality.execute();
id++;
for (Functionality functionality: mainFunctionality.getFunctionalities()){
psFunctionality.setInt(1, id);
psFunctionality.setString(2, functionality.getName());
psFunctionality.setString(3, functionality.getDescription());
psFunctionality.setNull(4, Types.INTEGER);
psFunctionality.setInt(5, 0);
psFunctionality.execute();
for (Service service: functionality.getServices()){
psServices.setInt(1, id);
psServices.setString(2, service.getServiceName());
psServices.setString(3, service.getServiceClass());
psServices.setString(4, "1.00.00");
psServices.execute();
}
for (String portlet: functionality.getPortlets()){
psPortlets.setInt(1, id);
psPortlets.setString(2, portlet);
psPortlets.execute();
}
id++;
}
}
}catch(Exception e){
logger.error("error reading functionalities",e);
throw new GCUBEFault(e,"error reading functionalities");}
}
}

View File

@ -126,17 +126,9 @@ public class ModelFactoryService{
* @return void
* @throws RemoteException -
*/
public void removeVRE(String request) throws GCUBEFault{
public void removeVRE(String id) throws GCUBEFault{
try{
ResultSet res=DBInterface.queryDB("Select VRE.id from VRE where VRE.epr='"+request+"';");
String id;
if (res.next()){
try{
id= res.getString(1);
}catch(Exception e){logger.error("Error retrieving the VRE on DB "+e); throw e;}
}else throw new Exception("VRE not retreived in DB");
ModelerContext pctx= ModelerContext.getPortTypeContext();
ModelerResource mr= (ModelerResource) pctx.getWSHome().find(pctx.makeKey(id));

View File

@ -14,9 +14,9 @@ import org.gcube.common.core.types.VOID;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.thread.DeployVRE;
import org.gcube.vremanagement.vremodeler.impl.util.MetadataFormat;
import org.gcube.vremanagement.vremodeler.impl.util.ModelerCollection;
import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil;
import org.gcube.vremanagement.vremodeler.resources.MetadataFormat;
import org.gcube.vremanagement.vremodeler.stubs.CheckStatusResponse;
import org.gcube.vremanagement.vremodeler.stubs.CollectionArray;
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityIDArray;
@ -159,17 +159,17 @@ public class ModelerService {
String dlKey=instanceID;
ArrayList<List<String>> values= new ArrayList<List<String>>(request.getGHNElement().length);
ArrayList<String[]> values= new ArrayList<String[]>(request.getGHNElement().length);
ArrayList<String> row=null;
for (String ghnId: request.getGHNElement())
{
row= new ArrayList<String>(2);
row.add(dlKey);
row.add(ghnId);
values.add(row);
values.add(row.toArray(new String[2]));
}
DBInterface.InsertInto("VRERELATEDGHN", values);
DBInterface.insertInto("VRERELATEDGHN", values.toArray(new String[0][0]));
}catch(Exception e){
logger.error("error setting GHNs "+e);
e.printStackTrace();
@ -224,7 +224,7 @@ public class ModelerService {
String dlKey=(String) getResource().getId();
ArrayList<List<String>> values= new ArrayList<List<String>>(request.getCollectionElement().length);
ArrayList<String[]> values= new ArrayList<String[]>(request.getCollectionElement().length);
ArrayList<String> row=null;
logger.trace("the collection set for"+ dlKey+" are "+request.getCollectionElement().length);
@ -234,10 +234,10 @@ public class ModelerService {
row = new ArrayList<String>(2);
row.add(dlKey);
row.add(request.getCollectionElement()[i]);
values.add(row);
values.add(row.toArray(new String[2]));
}
DBInterface.connect();
DBInterface.InsertInto("VRERELATEDCOLLECTION", values);
DBInterface.insertInto("VRERELATEDCOLLECTION", values.toArray(new String[0][0]));
}catch(Exception e){
e.printStackTrace();
throw new GCUBEFault(e);
@ -281,7 +281,8 @@ public class ModelerService {
ResultSet selectedFormat= DBInterface.queryDB("select rel.collid, mf.id, mf.name, mf.schemauri, mf.language , coll.name, coll.description from COLLECTION as coll, VRERELATEDMETADATAFORMAT as rel, MDFORMAT as mf where mf.id=rel.mfid and rel.vreid='"+getResource().getId()+"' and coll.id=rel.collid;");
while (selectedFormat.next()){
ModelerCollection collection= new ModelerCollection(selectedFormat.getString(1), selectedFormat.getString(7), selectedFormat.getString(6));
MetadataFormat mf= new MetadataFormat(selectedFormat.getString(2), selectedFormat.getString(3), new URI(selectedFormat.getString(4)), selectedFormat.getString(5));
MetadataFormat mf= new MetadataFormat(selectedFormat.getString(2),selectedFormat.getString(3), new URI(selectedFormat.getString(4)), selectedFormat.getString(5));
if (selectedMetadataFormat.containsKey(collection))
selectedMetadataFormat.get(collection).add(mf);
else {
@ -357,7 +358,7 @@ public class ModelerService {
String key=(String) getResource().getId();
//logger.debug(request.getCollectionIDArray().length+" "+request.getMdFormatIDArray().length+" "+request.getCheckedArray().length+" "+request.getCheckedArray(0).getCheckedRowElement().length);
ArrayList<List<String>> values= new ArrayList<List<String>>(request.getCollectionIDArray().length);
ArrayList<String[]> values= new ArrayList<String[]>(request.getCollectionIDArray().length);
ArrayList<String> row=null;
for (int i=0; i<request.getCollectionIDArray().length; i++)
for( int j=0; j<request.getMdFormatIDArray().length; j++)
@ -367,12 +368,12 @@ public class ModelerService {
row.add(key);
row.add(request.getCollectionIDArray(i));
row.add(request.getMdFormatIDArray(j));
values.add(row);
values.add(row.toArray(new String[3]));
}
}
DBInterface.InsertInto("VRERELATEDMETADATAFORMAT", values);
DBInterface.insertInto("VRERELATEDMETADATAFORMAT", values.toArray(new String[0][0]));
}catch(Exception e){
logger.error("setMetadataRelateToCollectio failed ");
e.printStackTrace();
@ -436,22 +437,22 @@ public class ModelerService {
//logger.debug("KEY: "+dlKey);
if (request.getFunctionalityIDElement()!=null){
ArrayList<List<String>> values= new ArrayList<List<String>>(request.getFunctionalityIDElement().length);
ArrayList<String[]> values= new ArrayList<String[]>(request.getFunctionalityIDElement().length);
ArrayList<String> row=null;
for (String funct: request.getFunctionalityIDElement())
{
row= new ArrayList<String>(2);
row.add(vreKey);
row.add(funct);
values.add(row);
values.add(row.toArray(new String[2]));
}
DBInterface.InsertInto("VRERELATEDFUNCT", values);
DBInterface.insertInto("VRERELATEDFUNCT", values.toArray(new String[0][0]));
}else System.out.println("requestFunciotnality is null");
if (request.getCsIDElement()!=null)
{
ArrayList<List<String>> values= new ArrayList<List<String>>(request.getCsIDElement().length);
ArrayList<String[]> values= new ArrayList<String[]>(request.getCsIDElement().length);
ArrayList<String> row=null;
for (String css:request.getCsIDElement())
@ -459,10 +460,10 @@ public class ModelerService {
row= new ArrayList<String>(2);
row.add(vreKey);
row.add(css);
values.add(row);
values.add(row.toArray(new String[2]));
}
DBInterface.InsertInto("VRERELATEDCS", values);
DBInterface.insertInto("VRERELATEDCS", values.toArray(new String[0][0]));
}
}catch(Exception e){
e.printStackTrace();

View File

@ -1,18 +1,29 @@
package org.gcube.vremanagement.vremodeler.impl;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.apache.commons.io.IOUtils;
import java.util.ArrayList;
import javax.xml.namespace.QName;
import org.gcube.common.core.contexts.GCUBEServiceContext;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.notifier.ISNotifier;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
import org.gcube.vremanagement.vremodeler.consumers.CollectionConsumer;
import org.gcube.vremanagement.vremodeler.consumers.FunctionalityConsumer;
import org.gcube.vremanagement.vremodeler.consumers.GHNConsumer;
import org.gcube.vremanagement.vremodeler.consumers.MCollectionConsumer;
import org.gcube.vremanagement.vremodeler.consumers.RunningInstanceConsumer;
import org.gcube.vremanagement.vremodeler.db.IStoDBUtil;
import org.gcube.vremanagement.vremodeler.resources.handlers.CollectionHandler;
import org.gcube.vremanagement.vremodeler.resources.handlers.FunctionalityHandler;
import org.gcube.vremanagement.vremodeler.resources.handlers.GHNHandler;
public class ServiceContext extends GCUBEServiceContext{
private String dbFileName="vdldb.script";
/** Single context instance, created eagerly */
private static ServiceContext cache = new ServiceContext();
@ -26,9 +37,6 @@ public class ServiceContext extends GCUBEServiceContext{
protected String getJNDIName() {return "gcube/vremanagement/vremodeler";}
protected void onReady() throws Exception{
File vredbFile= ServiceContext.getContext().getFile("hsqldb"+File.separator+"vdldb.script", true );
if (!ServiceContext.getContext().getPersistentFile(dbFileName, true).exists())
IOUtils.copy(new FileInputStream(vredbFile), new FileOutputStream(new File(ServiceContext.getContext().getPersistenceRoot()+File.separator+dbFileName)));
try{
logger.info("ready event invoked on " + this.getName());
this.intializeDB();
@ -39,7 +47,46 @@ public class ServiceContext extends GCUBEServiceContext{
}
protected void intializeDB() throws Exception{
ServiceContext.getContext().setScope(ServiceContext.getContext().getStartScopes()[0].isInfrastructure()? ServiceContext.getContext().getStartScopes()[1]: ServiceContext.getContext().getStartScopes()[0]);
IStoDBUtil.initDB(ServiceContext.getContext().getStartScopes()[0].isInfrastructure()? ServiceContext.getContext().getStartScopes()[1]: ServiceContext.getContext().getStartScopes()[0]);
ISNotifier notifier= GHNContext.getImplementation(ISNotifier.class);
for (GCUBEScope scope : ServiceContext.getContext().getStartScopes()){
if (scope.isInfrastructure()) continue;
ServiceContext.getContext().setScope(scope);
GCUBESecurityManager secMan= new GCUBESecurityManagerImpl(){
@Override
public boolean isSecurityEnabled() {
// TODO Auto-generated method stub
return false;
}};
IStoDBUtil.initDB(scope);
new GHNHandler().initialize();
new CollectionHandler().initialize();
FunctionalityHandler functionalityHandler= new FunctionalityHandler();
functionalityHandler.initialize();
logger.debug("Service initialized!!");
//GHNNotification
ArrayList<QName> qnameList= new ArrayList<QName>();
qnameList.add(GHNConsumer.ghnQName);
notifier.registerToISNotification(qnameList, new GHNConsumer(scope), secMan, scope);
//RINotification
qnameList= new ArrayList<QName>();
qnameList.add(RunningInstanceConsumer.riQName);
notifier.registerToISNotification(qnameList, new RunningInstanceConsumer(scope), secMan, scope);
//CollectionNotification
qnameList= new ArrayList<QName>();
qnameList.add(CollectionConsumer.collectionQName);
notifier.registerToISNotification(qnameList, new CollectionConsumer(scope), secMan, scope);
//MCollectionNotification
qnameList= new ArrayList<QName>();
qnameList.add(MCollectionConsumer.mCollectionQName);
notifier.registerToISNotification(qnameList, new MCollectionConsumer(scope), secMan, scope);
//FunctionalityResource
qnameList= new ArrayList<QName>();
qnameList.add(FunctionalityConsumer.functionalityQName);
notifier.registerToISNotification(qnameList, new FunctionalityConsumer(scope,functionalityHandler.getFunctionalityResourceId()), secMan, scope);
logger.debug("consumers registered");
}
}
}

View File

@ -1,23 +0,0 @@
package org.gcube.vremanagement.vremodeler.impl.util;
import java.util.Arrays;
import java.util.List;
public class MFRelationDerivate extends MFRelationNative {
private String transformationProgramId;
public MFRelationDerivate(String collectionId, String metaFormatId, String transformationProgramId) {
super(collectionId, metaFormatId);
this.transformationProgramId= transformationProgramId;
}
public String getTransformationProgramId(){
return this.transformationProgramId;
}
public List<String> getAsStringList(){
return Arrays.asList(new String[]{super.getMetadataCollectionId(), super.getMetadataFormatId(), this.transformationProgramId});
}
}

View File

@ -18,6 +18,7 @@ import javax.xml.transform.stream.StreamResult;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.ModelerService;
import org.gcube.vremanagement.vremodeler.resources.MetadataFormat;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

View File

@ -1,11 +1,17 @@
package org.gcube.vremanagement.vremodeler.portallayout;
import java.io.StringReader;
import java.util.List;
import javax.xml.parsers.DocumentBuilderFactory;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericResourceQuery;
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.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
import org.gcube.vremanagement.vremodeler.impl.util.Couple;
import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil;
@ -14,9 +20,9 @@ import org.w3c.dom.Element;
public class LayoutCreation {
private Document doc;
private GCUBELog logger= new GCUBELog(LayoutCreation.class);
private GCUBEGenericResource resource;
private String vreId;
private String vreName;
private String createdResourceId= null;
@ -24,14 +30,12 @@ public class LayoutCreation {
return this.createdResourceId;
}
private void publish(Document doc) throws Exception{
//System.out.println(XMLUtil.docToString(doc));
resource.setBody(XMLUtil.docToString(doc));
private void publish(String body) throws Exception{
resource.setBody(body);
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("");
resource.setSecondaryType("LayoutResource");
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())));
@ -42,82 +46,21 @@ public class LayoutCreation {
public LayoutCreation(String vreId, String vreName){
try{
this.resource= GHNContext.getImplementation(GCUBEGenericResource.class);
this.doc= DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
this.vreId= vreId;
this.vreName= vreName;
}catch(Exception e){e.printStackTrace();}
}
public GCUBEGenericResource createAndPublishLayout() throws Exception{
doc.appendChild(this.createLayout());
publish(doc);
ISClient client= GHNContext.getImplementation(ISClient.class);
GCUBEGenericResourceQuery query= GHNContext.getImplementation(GCUBEGenericResourceQuery.class);
query.addAtomicConditions(new AtomicCondition("/SecondaryType","VREModelerResource"), new AtomicCondition("/Name","DefaultLayout"));
List<GCUBEGenericResource> defaultLayoutResourceList= client.execute(query, ServiceContext.getContext().getScope());
if (defaultLayoutResourceList.size()>0)
this.publish(defaultLayoutResourceList.get(0).getBody());
else{
logger.debug("no DefaultLayout resource found, creating the VRE with an empty one");
this.publish("<tabbed-pane can-modify=\"false\" label=\"\" required-role=\"\" style=\"menu\" visible=\"true\" width=\"\"></tabbed-pane>");
}
return resource;
}
@SuppressWarnings("unchecked")
private Element createLayout() throws Exception{
try {
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", ""));
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", ""));
Element title= XMLUtil.createTextElement(doc, "title", "VRE Management", new Couple<String, String>("lang", "en"));
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", ""));
//layoutCreatorPortlet
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", ""));
Element layoutCreationTitle= XMLUtil.createTextElement(doc, "title", "Layout Creator", new Couple<String, String>("lang", "en"));
Element layoutCreationTable= XMLUtil.createTextElement(doc, "table", 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 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", "") );
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", "") );
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", "") );
Element layoutCreationPortlet= XMLUtil.createTextElement(doc, "portlet-class", "layoutcreator#LayoutcreatorPortlet");
layoutCreationframe.appendChild(layoutCreationPortlet);
layoutCreationColumn.appendChild(layoutCreationframe);
layoutCreationRow.appendChild(layoutCreationColumn);
layoutCreationTab.appendChild(layoutCreationTitle);
layoutCreationTable.appendChild(layoutCreationRow);
layoutCreationTab.appendChild(layoutCreationTable);
//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", "VRE InformationSpace", new Couple<String, String>("lang", "en"));
Element informationSpaceTable= XMLUtil.createTextElement(doc, "table", 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 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", "VREInformationSpaceEditor#VREInformationSpaceEditorPortlet");
informationSpaceFrame.appendChild(informationSpacePortlet);
informationSpaceColumn.appendChild(informationSpaceFrame);
informationSpaceRow.appendChild(informationSpaceColumn);
informationSpaceTab.appendChild(informationSpaceTitle);
informationSpaceTable.appendChild(informationSpaceRow);
informationSpaceTab.appendChild(informationSpaceTable);
subRoot.appendChild(layoutCreationTab);
subRoot.appendChild(informationSpaceTab);
tab.appendChild(title);
tab.appendChild(subRoot);
root.appendChild(tab);
return root;
} catch (Exception e) {
throw new Exception("Error creating the Portlet Layout",e);
}
}
}

View File

@ -1,9 +1,8 @@
package org.gcube.vremanagement.vremodeler;
package org.gcube.vremanagement.vremodeler.resources;
import java.util.ArrayList;
import java.util.List;
import org.gcube.vremanagement.vremodeler.impl.resources.MainFunctionality;
public class Body {

View File

@ -1,4 +1,4 @@
package org.gcube.vremanagement.vremodeler.impl.resources;
package org.gcube.vremanagement.vremodeler.resources;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,7 +1,6 @@
package org.gcube.vremanagement.vremodeler.impl.resources;
package org.gcube.vremanagement.vremodeler.resources;
import org.gcube.common.core.resources.GCUBEResource;
import org.gcube.vremanagement.vremodeler.Body;
public abstract class GCUBEGenericFunctionalityResource extends GCUBEResource{

View File

@ -0,0 +1,27 @@
package org.gcube.vremanagement.vremodeler.resources;
public class GhnRiRelationObject {
private String ghn;
private String ri;
public GhnRiRelationObject(String ghn, String ri) {
super();
this.ghn = ghn;
this.ri = ri;
}
public String getGhn() {
return ghn;
}
public String getRunningInstance() {
return ri;
}
}

View File

@ -1,8 +1,10 @@
package org.gcube.vremanagement.vremodeler.impl.util;
package org.gcube.vremanagement.vremodeler.resources;
import java.util.Arrays;
import java.util.List;
import org.gcube.vremanagement.vremodeler.impl.util.Listable;
public class MFRelationNative implements Listable{
private String metaCollectionID;

View File

@ -1,4 +1,4 @@
package org.gcube.vremanagement.vremodeler.impl.resources;
package org.gcube.vremanagement.vremodeler.resources;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,29 +1,46 @@
package org.gcube.vremanagement.vremodeler.impl.util;
package org.gcube.vremanagement.vremodeler.resources;
import java.net.URI;
import java.util.Arrays;
import java.util.List;
import org.apache.axis.components.uuid.UUIDGen;
import org.apache.axis.components.uuid.UUIDGenFactory;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.impl.util.Listable;
public class MetadataFormat implements Listable{
private static GCUBELog logger= new GCUBELog(MetadataFormat.class);
private static UUIDGen uuidMFGEN= UUIDGenFactory.getUUIDGen();
public final static String ANY_LANGUAGE="any";
private final static GCUBELog log= new GCUBELog(MetadataFormat.class.getName());
private String id;
private String name;
private URI schemaURI;
private String language;
public MetadataFormat(){}
public MetadataFormat(){
this.id= uuidMFGEN.nextUUID();
}
public MetadataFormat(String id, String name, URI schemaURI, String language){
log.trace("created a metadataFormat Object with "+id);
this.id= id;
public MetadataFormat(String name, URI schemaURI, String language){
this.id= uuidMFGEN.nextUUID();
logger.trace("created a metadataFormat Object with "+id);
this.name=name;
this.language= language;
this.schemaURI= schemaURI;
}
public MetadataFormat(String id,String name, URI schemaURI, String language){
logger.trace("created a metadataFormat Object with "+id);
this.id=id;
this.name=name;
this.language= language;
this.schemaURI= schemaURI;
}
public String getId(){
@ -68,6 +85,7 @@ public class MetadataFormat implements Listable{
return Arrays.asList(new String[]{this.id, this.name, this.schemaURI.toString(), this.language});
}
}

View File

@ -1,4 +1,4 @@
package org.gcube.vremanagement.vremodeler.impl.resources;
package org.gcube.vremanagement.vremodeler.resources;
public class Service {

View File

@ -0,0 +1,56 @@
package org.gcube.vremanagement.vremodeler.resources.handlers;
import java.util.ArrayList;
import java.util.List;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBECollectionQuery;
import org.gcube.common.core.resources.GCUBECollection;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
public class CollectionHandler implements ResourceHandler<GCUBECollection> {
private static GCUBELog logger = new GCUBELog(CollectionHandler.class);
public static final String tableName="COLLECTION";
public void add(GCUBECollection resource) throws Exception {
this.insert(resource);
}
public void drop(GCUBECollection resource) throws Exception {
// TODO Auto-generated method stub
}
public void initialize() throws Exception {
ISClient client= GHNContext.getImplementation(ISClient.class);
GCUBECollectionQuery query=client.getQuery(GCUBECollectionQuery.class);
query.addAtomicConditions(new AtomicCondition("/Profile/IsUserCollection/@value","true"));
List<GCUBECollection> collectionList= client.execute(client.getQuery(GCUBECollectionQuery.class), ServiceContext.getContext().getScope());
for (GCUBECollection collection:collectionList)
try{
insert(collection);
}catch(Exception e){logger.error("error insertin values in "+tableName, e);}
}
private void insert(GCUBECollection collection) throws Exception {
ArrayList<String> row= new ArrayList<String>(6);
row.add(collection.getID());
row.add(collection.getName());
row.add(collection.getDescription()==null? "not provided" : collection.getDescription());
row.add(collection.getNumberOfMembers()+"");
row.add(collection.getCreationTime().getTime().getTime()+"");
row.add(collection.getLastUpdateTime().getTime().getTime()+"");
DBInterface.connect();
DBInterface.insertInto(tableName, row.toArray(new String[6]));
MCollectionHandler mcollHandler= new MCollectionHandler(collection.getID());
mcollHandler.initialize();
}
}

View File

@ -0,0 +1,116 @@
package org.gcube.vremanagement.vremodeler.resources.handlers;
import java.io.StringReader;
import java.sql.PreparedStatement;
import java.sql.Types;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.faults.GCUBEFault;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericResourceQuery;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
import org.gcube.vremanagement.vremodeler.resources.Functionality;
import org.gcube.vremanagement.vremodeler.resources.MainFunctionality;
import org.gcube.vremanagement.vremodeler.resources.Service;
import org.gcube.vremanagement.vremodeler.resources.kxml.KGCUBEGenericFunctionalityResource;
public class FunctionalityHandler implements ResourceHandler<KGCUBEGenericFunctionalityResource>{
private static GCUBELog logger= new GCUBELog(FunctionalityHandler.class);
public static final String functionalityTableName="FUNCTIONALITY";
public static final String portletTableName="PORTLETRELTOFUNCT";
public static final String serviceTableName="SERVICES";
private PreparedStatement psFunctionality;
private PreparedStatement psServices;
private PreparedStatement psPortlets;
private ISClient queryClient;
private String functionalityResourceId;
public FunctionalityHandler() throws Exception{
DBInterface.connect();
this.psFunctionality=DBInterface.getConnection().prepareStatement("INSERT INTO FUNCTIONALITY VALUES(?,?,?,?,?)");
this.psServices=DBInterface.getConnection().prepareStatement("INSERT INTO SERVICES VALUES(?,?,?,?)");
this.psPortlets=DBInterface.getConnection().prepareStatement("INSERT INTO PORTLETRELTOFUNCT VALUES(?,?)");
queryClient= GHNContext.getImplementation(ISClient.class);
}
public void add(KGCUBEGenericFunctionalityResource resource)
throws Exception {
DBInterface.deleteAll(functionalityTableName);
DBInterface.deleteAll(portletTableName);
DBInterface.deleteAll(serviceTableName);
this.insert(resource);
logger.debug("functionality changed");
}
public void drop(KGCUBEGenericFunctionalityResource resource)
throws Exception {}
public void initialize() throws Exception {
KGCUBEGenericFunctionalityResource resource= new KGCUBEGenericFunctionalityResource();
try{
GCUBEGenericResourceQuery query= queryClient.getQuery(GCUBEGenericResourceQuery.class);
query.addAtomicConditions(new AtomicCondition("/Profile/Name","FuctionalitiesResource"), new AtomicCondition("/Profile/SecondaryType","VREModelerResource"));
GCUBEGenericQuery genericQuery= queryClient.getQuery(GCUBEGenericQuery.class);
genericQuery.setExpression(query.getExpression());
resource.load(new StringReader(queryClient.execute(genericQuery, ServiceContext.getContext().getScope()).get(0).toString()));
}catch(Exception e ){logger.error("Error queryng IS",e); throw new GCUBEFault(e); }
this.functionalityResourceId= resource.getID();
this.insert(resource);
logger.debug("functionality initialized");
}
private void insert( KGCUBEGenericFunctionalityResource resource) throws Exception{
int id=0;
for (MainFunctionality mainFunctionality: resource.getBody().getMainFunctionalities()){
psFunctionality.setInt(1, id);
psFunctionality.setString(2, mainFunctionality.getName());
psFunctionality.setString(3, mainFunctionality.getDescription());
psFunctionality.setNull(4, Types.INTEGER);
psFunctionality.setInt(5, 0);
psFunctionality.execute();
id++;
for (Functionality functionality: mainFunctionality.getFunctionalities()){
psFunctionality.setInt(1, id);
psFunctionality.setString(2, functionality.getName());
psFunctionality.setString(3, functionality.getDescription());
psFunctionality.setNull(4, Types.INTEGER);
psFunctionality.setInt(5, 0);
psFunctionality.execute();
for (Service service: functionality.getServices()){
psServices.setInt(1, id);
psServices.setString(2, service.getServiceName());
psServices.setString(3, service.getServiceClass());
psServices.setString(4, "1.00.00");
psServices.execute();
}
for (String portlet: functionality.getPortlets()){
psPortlets.setInt(1, id);
psPortlets.setString(2, portlet);
psPortlets.execute();
}
id++;
}
}
}
public String getFunctionalityResourceId() {
return functionalityResourceId;
}
}

View File

@ -0,0 +1,64 @@
package org.gcube.vremanagement.vremodeler.resources.handlers;
import java.util.ArrayList;
import java.util.List;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGHNQuery;
import org.gcube.common.core.resources.GCUBEHostingNode;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
public class GHNHandler implements ResourceHandler<GCUBEHostingNode> {
private static GCUBELog logger = new GCUBELog(GHNHandler.class);
public static final String tableName="GHN";
//private static final String creationQuery="CREATE MEMORY TABLE "+tableName+" (ID VARCHAR NOT NULL PRIMARY KEY,HOST VARCHAR,SECURITY VARCHAR,UPTIME VARCHAR,MAINMEMORYVA VARCHAR,MAINMEMORYVS VARCHAR,LOCALAS VARCHAR,LOCATION VARCHAR,COUNTRY VARCHAR,DOMAIN VARCHAR)";
public void initialize() throws Exception{
//DBInterface.connect();
//DBInterface.ExecuteUpdate(creationQuery);
ISClient client= GHNContext.getImplementation(ISClient.class);
GCUBEGHNQuery query=client.getQuery(GCUBEGHNQuery.class);
query.addAtomicConditions(new AtomicCondition("/Profile/GHNDescription/Type","Dynamic"));
List<GCUBEHostingNode> ghnList= client.execute(query, ServiceContext.getContext().getScope());
for (GCUBEHostingNode ghn:ghnList)
try{
insert(ghn);
}catch(Exception e){logger.error("error insertin values in "+tableName, e);}
}
private void insert(GCUBEHostingNode ghn) throws Exception {
ArrayList<String> row= new ArrayList<String>(10);
String id= ghn.getID();
row.add(id);
row.add(ghn.getNodeDescription().getName());
row.add(ghn.getNodeDescription().isSecurityEnabled()+"");
row.add(ghn.getNodeDescription().getUptime());
row.add(ghn.getNodeDescription().getMemory().getVirtualAvailable()+"");
row.add(ghn.getNodeDescription().getMemory().getVirtualSize()+"");
row.add(ghn.getNodeDescription().getLocalAvailableSpace()+"");
row.add(ghn.getSite().getLocation());
row.add(ghn.getSite().getCountry());
row.add(ghn.getSite().getDomain());
DBInterface.connect();
DBInterface.insertInto(tableName, row.toArray(new String[0]));
RunningInstancesHandler riHandler= new RunningInstancesHandler(ghn.getID());
riHandler.initialize();
}
public void add(GCUBEHostingNode resource) throws Exception {
this.insert(resource);
}
public void drop(GCUBEHostingNode resource) throws Exception {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,27 @@
package org.gcube.vremanagement.vremodeler.resources.handlers;
import java.util.ArrayList;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.resources.GhnRiRelationObject;
public class GhnRiRelationHandler implements ResourceHandler<GhnRiRelationObject>{
public static final String tableName="GHNRELATEDRI";
//private static final String creationQuery="CREATE IF NOT EXISTS MEMORY TABLE "+tableName+"(GHNID VARCHAR NOT NULL,RIID VARCHAR NOT NULL,PRIMARY KEY(GHNID,RIID))";
public void add(GhnRiRelationObject resource) throws Exception {
ArrayList<String> row= new ArrayList<String>();
row.add(resource.getGhn());
row.add(resource.getRunningInstance());
DBInterface.connect();
DBInterface.insertInto(tableName, row.toArray(new String[0]));
}
public void drop(GhnRiRelationObject resource) throws Exception {
// TODO Auto-generated method stub
}
public void initialize() throws Exception {}
}

View File

@ -0,0 +1,60 @@
package org.gcube.vremanagement.vremodeler.resources.handlers;
import java.util.ArrayList;
import java.util.List;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBEMCollectionQuery;
import org.gcube.common.core.resources.GCUBEMCollection;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
import org.gcube.vremanagement.vremodeler.resources.MetadataFormat;
public class MCollectionHandler implements ResourceHandler<GCUBEMCollection> {
private static GCUBELog logger= new GCUBELog(MCollectionHandler.class);
public static final String tableName="MCOLLECTION";
private String relatedCollectionId;
public MCollectionHandler(String relatedCollectionId){
this.relatedCollectionId= relatedCollectionId;
}
public void add(GCUBEMCollection resource) throws Exception {
this.insert(resource);
}
public void drop(GCUBEMCollection resource) throws Exception {
// TODO Auto-generated method stub
}
public void initialize() throws Exception {
ISClient client= GHNContext.getImplementation(ISClient.class);
GCUBEMCollectionQuery queryMColl= client.getQuery(GCUBEMCollectionQuery.class);
queryMColl.addAtomicConditions(new AtomicCondition("/Profile/RelatedCollection/CollectionID",this.relatedCollectionId));
List<GCUBEMCollection> mcollList= client.execute(queryMColl, ServiceContext.getContext().getScope());
for (GCUBEMCollection mcoll: mcollList)
try{
insert(mcoll);
}catch(Exception e){logger.error("error inserting values in "+tableName, e);}
}
private void insert(GCUBEMCollection mcollection) throws Exception {
List<String> row= new ArrayList<String>(4);
row.add(mcollection.getID());
row.add(mcollection.getName());
row.add(mcollection.getDescription());
row.add(mcollection.getRelCollection().getCollectionID());
DBInterface.connect();
DBInterface.insertInto(tableName, row.toArray(new String[4]));
new MetadataFormatHandler(mcollection.getID()).add(new MetadataFormat(mcollection.getMetaFormat().getName(), mcollection.getMetaFormat().getSchemaURI(), mcollection.getMetaFormat().getLanguage()));
}
}

View File

@ -0,0 +1,60 @@
package org.gcube.vremanagement.vremodeler.resources.handlers;
import java.sql.ResultSet;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.resources.MFRelationNative;
import org.gcube.vremanagement.vremodeler.resources.MetadataFormat;
public class MetadataFormatHandler implements ResourceHandler<MetadataFormat> {
private static GCUBELog logger= new GCUBELog(MetadataFormatHandler.class);
private static final String nameFieldDb="NAME";
private static final String schemaFieldDb="SCHEMAURI";
private static final String languageFieldDb="LANGUAGE";
public static final String tableName="METADATAFORMAT";
private String relatedMCollectionID;
public MetadataFormatHandler(String relatedMCollectionId){
this.relatedMCollectionID= relatedMCollectionId;
}
public void add(MetadataFormat resource) throws Exception {
String id;
if ((id=exists(resource))!=null){
new NativeMetadataFormatHandler().add(new MFRelationNative(this.relatedMCollectionID, id));
}else{
DBInterface.connect();
DBInterface.insertIntoListable(tableName, resource);
new NativeMetadataFormatHandler().add(new MFRelationNative(this.relatedMCollectionID, resource.getId()));
}
}
public void drop(MetadataFormat resource) throws Exception {
// TODO Auto-generated method stub
}
public void initialize() throws Exception {}
/**
* this method returns the id of the MetadataFormat if this metadataFormat exists, null otherwise
*/
private static String exists(MetadataFormat metadataFormat) throws Exception{
DBInterface.connect();
ResultSet result;
if (metadataFormat.getLanguage().compareTo(MetadataFormat.ANY_LANGUAGE)==0){
result=DBInterface.queryDB("SELECT ID from "+tableName+" WHERE "+nameFieldDb+"='"+metadataFormat.getName()+"' AND "+schemaFieldDb+"='"+metadataFormat.getSchemaURI()+"'");
}else
result=DBInterface.queryDB("SELECT ID from "+tableName+" WHERE "+nameFieldDb+"='"+metadataFormat.getName()+"' AND "+schemaFieldDb+"='"+metadataFormat.getSchemaURI()+"' AND ("+languageFieldDb+"='"+MetadataFormat.ANY_LANGUAGE+"' OR "+languageFieldDb+"='"+metadataFormat.getLanguage()+"')");
if (result.next()) {
logger.trace("the metadataFormat already exists");
return result.getString(1);
}else return null;
}
}

View File

@ -0,0 +1,24 @@
package org.gcube.vremanagement.vremodeler.resources.handlers;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.resources.MFRelationNative;
public class NativeMetadataFormatHandler implements ResourceHandler<MFRelationNative> {
private static GCUBELog logger= new GCUBELog(NativeMetadataFormatHandler.class);
public static final String tableName="NATIVEMDF";
public void add(MFRelationNative resource) throws Exception {
DBInterface.connect();
DBInterface.insertIntoListable(tableName, resource);
}
public void drop(MFRelationNative resource) throws Exception {
// TODO Auto-generated method stub
}
public void initialize() throws Exception {}
}

View File

@ -0,0 +1,10 @@
package org.gcube.vremanagement.vremodeler.resources.handlers;
public interface ResourceHandler<T> {
public void initialize() throws Exception;
public void add(T resource) throws Exception;
public void drop(T resource) throws Exception;
}

View File

@ -0,0 +1,61 @@
package org.gcube.vremanagement.vremodeler.resources.handlers;
import java.util.ArrayList;
import java.util.List;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery;
import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
import org.gcube.vremanagement.vremodeler.resources.GhnRiRelationObject;
public class RunningInstancesHandler implements ResourceHandler<GCUBERunningInstance>{
private static GCUBELog logger = new GCUBELog(RunningInstancesHandler.class);
public static final String tableName="RunningInstance";
//private static final String creationQuery="CREATE IF NOT EXISTS MEMORY TABLE "+tableName+" (ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL, CLASS VARCHAR NOT NULL)";
private String relatedGhn;
public RunningInstancesHandler(String ghnId) {
this.relatedGhn=ghnId;
}
public void initialize() throws Exception{
//DBInterface.connect();
//DBInterface.ExecuteUpdate(creationQuery);
ISClient client= GHNContext.getImplementation(ISClient.class);
GCUBERIQuery queryRI= client.getQuery(GCUBERIQuery.class);
queryRI.addGenericCondition("$result/Profile/GHN[string(@UniqueID) eq '"+this.relatedGhn+"']");
List<GCUBERunningInstance> riList= client.execute(queryRI, ServiceContext.getContext().getScope());
for (GCUBERunningInstance ri: riList)
try{
insert(ri);
}catch(Exception e){logger.error("error insertin values in "+tableName, e);}
}
private void insert(GCUBERunningInstance ri) throws Exception{
ArrayList<String> row= new ArrayList<String>(3);
row.add(ri.getID());
row.add(ri.getServiceName());
row.add(ri.getServiceClass());
DBInterface.connect();
DBInterface.insertInto(tableName, row.toArray(new String[0]));
new GhnRiRelationHandler().add(new GhnRiRelationObject(this.relatedGhn, ri.getID()));
}
public void add(GCUBERunningInstance resource) throws Exception {
this.insert(resource);
}
public void drop(GCUBERunningInstance resource) throws Exception {
// TODO Auto-generated method stub
}
}

View File

@ -1,4 +1,4 @@
package org.gcube.vremanagement.vremodeler.impl.resources.kxml;
package org.gcube.vremanagement.vremodeler.resources.kxml;
import static org.gcube.common.resources.kxml.KGCUBEResource.NS;
@ -15,8 +15,8 @@ import org.gcube.common.core.resources.service.Package.ScopeLevel;
import org.gcube.common.resources.kxml.GCUBEResourceImpl;
import org.gcube.common.resources.kxml.KGCUBEResource;
import org.gcube.common.resources.kxml.service.version.VersionSpecificationParser;
import org.gcube.vremanagement.vremodeler.Body;
import org.gcube.vremanagement.vremodeler.impl.resources.MainFunctionality;
import org.gcube.vremanagement.vremodeler.resources.Body;
import org.gcube.vremanagement.vremodeler.resources.MainFunctionality;
import org.kxml2.io.KXmlParser;
import org.kxml2.io.KXmlSerializer;

View File

@ -1,4 +1,4 @@
package org.gcube.vremanagement.vremodeler.impl.resources.kxml;
package org.gcube.vremanagement.vremodeler.resources.kxml;
import static org.gcube.common.resources.kxml.KGCUBEResource.NS;
@ -6,8 +6,8 @@ import org.gcube.common.core.resources.service.Dependency;
import org.gcube.common.resources.kxml.service.KServiceDependency;
import org.gcube.common.resources.kxml.service.version.VersionSpecificationParser;
import org.gcube.common.resources.kxml.utils.KStringList;
import org.gcube.vremanagement.vremodeler.impl.resources.Functionality;
import org.gcube.vremanagement.vremodeler.impl.resources.Service;
import org.gcube.vremanagement.vremodeler.resources.Functionality;
import org.gcube.vremanagement.vremodeler.resources.Service;
import org.kxml2.io.KXmlParser;
import org.kxml2.io.KXmlSerializer;

View File

@ -1,4 +1,4 @@
package org.gcube.vremanagement.vremodeler.impl.resources.kxml;
package org.gcube.vremanagement.vremodeler.resources.kxml;
import java.io.FileNotFoundException;
import java.io.InputStream;
@ -7,7 +7,7 @@ import java.io.Writer;
import java.text.SimpleDateFormat;
import org.gcube.common.resources.kxml.GCUBEResourceImpl;
import org.gcube.common.resources.kxml.KGCUBEResource;
import org.gcube.vremanagement.vremodeler.impl.resources.GCUBEGenericFunctionalityResource;
import org.gcube.vremanagement.vremodeler.resources.GCUBEGenericFunctionalityResource;
import org.kxml2.io.KXmlParser;
import org.kxml2.io.KXmlSerializer;
import static org.gcube.common.resources.kxml.KGCUBEResource.NS;
@ -27,7 +27,7 @@ public class KGCUBEGenericFunctionalityResource extends GCUBEGenericFunctionalit
}
public InputStream getSchemaResource() throws FileNotFoundException {
return KGCUBEGenericFunctionalityResource.class.getResourceAsStream("/org/gcube/vremanagement/vremodeler/impl/resources/schemas/genericFunctionality.xsd");
return KGCUBEGenericFunctionalityResource.class.getResourceAsStream("/org/gcube/vremanagement/vremodeler/resources/schemas/genericFunctionality.xsd");
}
public void load(KXmlParser parser) throws Exception {

View File

@ -1,9 +1,9 @@
package org.gcube.vremanagement.vremodeler.impl.resources.kxml;
package org.gcube.vremanagement.vremodeler.resources.kxml;
import static org.gcube.common.resources.kxml.KGCUBEResource.NS;
import org.gcube.vremanagement.vremodeler.impl.resources.Functionality;
import org.gcube.vremanagement.vremodeler.impl.resources.MainFunctionality;
import org.gcube.vremanagement.vremodeler.resources.Functionality;
import org.gcube.vremanagement.vremodeler.resources.MainFunctionality;
import org.kxml2.io.KXmlParser;
import org.kxml2.io.KXmlSerializer;

View File

@ -1,8 +1,8 @@
package org.gcube.vremanagement.vremodeler.impl.resources.kxml;
package org.gcube.vremanagement.vremodeler.resources.kxml;
import static org.gcube.common.resources.kxml.KGCUBEResource.NS;
import org.gcube.vremanagement.vremodeler.impl.resources.Service;
import org.gcube.vremanagement.vremodeler.resources.Service;
import org.kxml2.io.KXmlParser;
import org.kxml2.io.KXmlSerializer;