git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/VREModeler@38407 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3dd33bd69f
commit
f86a3a0d59
|
@ -2,8 +2,11 @@
|
|||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/EolusClient-gCore"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/GCORELIB"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/VreModelerDependecies"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/GCORE"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/ContentManager"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gDL2"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gML2"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/CMDeps"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
CREATE CACHED TABLE COLLECTION(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR,DESCRIPTION VARCHAR,MEMBERS VARCHAR,CREATION VARCHAR,LASTUPDATE VARCHAR)
|
||||
CREATE CACHED 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, ISONCLOUD BOOLEAN)
|
||||
CREATE CACHED 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 CACHED 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,STATUS VARCHAR)
|
||||
CREATE CACHED TABLE CS(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,DESCRIPTION VARCHAR NOT NULL)
|
||||
CREATE CACHED TABLE RUNNINGINSTANCE(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL, CLASS VARCHAR NOT NULL)
|
||||
CREATE CACHED TABLE GHNRELATEDRI(GHNID VARCHAR NOT NULL,RIID VARCHAR NOT NULL,PRIMARY KEY(GHNID,RIID))
|
||||
CREATE CACHED TABLE RIRELATEDPKG(RIID VARCHAR NOT NULL,PKGID INTEGER NOT NULL,PRIMARY KEY(RIID,PKGID))
|
||||
CREATE CACHED 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 CACHED TABLE METADATAFORMAT(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,SCHEMAURI VARCHAR NOT NULL,LANGUAGE VARCHAR NOT NULL)
|
||||
CREATE CACHED 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 CACHED TABLE VRERELATEDCOLLECTION(VREID VARCHAR NOT NULL,COLLID VARCHAR NOT NULL,PRIMARY KEY(VREID,COLLID))
|
||||
CREATE CACHED TABLE VRERELATEDGHN(VREID VARCHAR NOT NULL,GHNID VARCHAR NOT NULL, ISCANDIDATE BOOLEAN,PRIMARY KEY(VREID,GHNID))
|
||||
CREATE CACHED TABLE VRERELATEDCS(VREID VARCHAR NOT NULL,CSID VARCHAR NOT NULL,PRIMARY KEY(VREID,CSID))
|
||||
|
|
|
@ -75,11 +75,6 @@
|
|||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:element name="setMDCollectionRequestMessage" type="tns:setMDFormatArgs"/>
|
||||
|
||||
<xsd:element name="setMDCollectionResponseMessage" type="coretypes:VOID"/>
|
||||
|
||||
|
||||
<xsd:element name="getQualityRequestMessage" type="coretypes:VOID"/>
|
||||
|
||||
<xsd:element name="getQualityResponseMessage" type="xsd:string"/>
|
||||
|
@ -201,21 +196,7 @@
|
|||
<message name="SetCollectionOutputMessage">
|
||||
<part name="response" element="tns:setCollectionResponseMessage"/>
|
||||
</message>
|
||||
|
||||
<message name="GetMDCollectionInputMessage">
|
||||
<part name="request" element="tns:getMDCollectionRequestMessage"/>
|
||||
</message>
|
||||
<message name="GetMDCollectionOutputMessage">
|
||||
<part name="response" element="tns:getMDCollectionResponseMessage"/>
|
||||
</message>
|
||||
|
||||
<message name="SetMDCollectionInputMessage">
|
||||
<part name="request" element="tns:setMDCollectionRequestMessage"/>
|
||||
</message>
|
||||
<message name="SetMDCollectionOutputMessage">
|
||||
<part name="response" element="tns:setMDCollectionResponseMessage"/>
|
||||
</message>
|
||||
|
||||
|
||||
<message name="GetQualityInputMessage">
|
||||
<part name="request" element="tns:getQualityRequestMessage"/>
|
||||
</message>
|
||||
|
@ -346,16 +327,6 @@
|
|||
<output message="tns:SetCollectionOutputMessage"/>
|
||||
</operation>
|
||||
|
||||
<operation name="getMetadataRelatedToCollection">
|
||||
<input message="tns:GetMDCollectionInputMessage"/>
|
||||
<output message="tns:GetMDCollectionOutputMessage"/>
|
||||
</operation>
|
||||
|
||||
<operation name="setMetadataRelatedToCollection">
|
||||
<input message="tns:SetMDCollectionInputMessage"/>
|
||||
<output message="tns:SetMDCollectionOutputMessage"/>
|
||||
</operation>
|
||||
|
||||
<operation name="setUseCloud">
|
||||
<input message="tns:SetUseCloudInputMessage"/>
|
||||
<output message="tns:SetUseCloudOutputMessage"/>
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.gcube.common.core.contexts.GHNContext;
|
|||
import org.gcube.common.core.informationsystem.notifier.ISNotifier.BaseNotificationConsumer;
|
||||
import org.gcube.common.core.informationsystem.notifier.ISNotifier.GCUBENotificationTopic;
|
||||
import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent;
|
||||
import org.gcube.common.core.resources.GCUBECollection;
|
||||
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;
|
||||
|
@ -16,10 +16,11 @@ public class CollectionConsumer extends BaseNotificationConsumer{
|
|||
|
||||
private GCUBELog logger= new GCUBELog(GHNConsumer.class);
|
||||
|
||||
public static final GCUBENotificationTopic collectionTopic= new GCUBENotificationTopic(new QName("http://gcube-system.org/namespaces/informationsystem/registry","Collection"));
|
||||
public static final GCUBENotificationTopic collectionTopic= new GCUBENotificationTopic(new QName("http://gcube-system.org/namespaces/informationsystem/registry",GCUBEGenericResource.TYPE));
|
||||
|
||||
static{
|
||||
collectionTopic.setUseRenotifier(false);
|
||||
collectionTopic.setPrecondition("//profile[contains(.,'<SecondaryType>GCUBECollection</SecondaryType>') and contains(.,'<user>true</user>')]");
|
||||
}
|
||||
|
||||
private GCUBEScope scope;
|
||||
|
@ -38,7 +39,7 @@ public class CollectionConsumer extends BaseNotificationConsumer{
|
|||
|
||||
if (operation.compareTo("create")==0){
|
||||
logger.trace("adding a new Collection in DB");
|
||||
GCUBECollection collection= GHNContext.getImplementation(GCUBECollection.class);
|
||||
GCUBEGenericResource collection= GHNContext.getImplementation(GCUBEGenericResource.class);
|
||||
String profile=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();
|
||||
collection.load(new StringReader(profile));
|
||||
new CollectionHandler().add(collection);
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
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.notifier.ISNotifier.BaseNotificationConsumer;
|
||||
import org.gcube.common.core.informationsystem.notifier.ISNotifier.GCUBENotificationTopic;
|
||||
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 GCUBENotificationTopic mCollectionTopic=new GCUBENotificationTopic(new QName("http://gcube-system.org/namespaces/informationsystem/registry","MetadataCollection"));
|
||||
|
||||
static{
|
||||
mCollectionTopic.setUseRenotifier(false);
|
||||
}
|
||||
|
||||
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("notification 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(2).getChildNodes().item(0).getNodeValue();
|
||||
if (operation.compareTo("create")==0){
|
||||
logger.trace("adding a new MCollection in DB");
|
||||
String profile=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();
|
||||
GCUBEMCollection mCollection= GHNContext.getImplementation(GCUBEMCollection.class);
|
||||
mCollection.load(new StringReader(profile));
|
||||
new MCollectionHandler(mCollection.getRelCollection().getCollectionID()).add(mCollection);
|
||||
} else if (operation.compareTo("destroy")==0){
|
||||
logger.trace("removing a MCollection from DB");
|
||||
new MCollectionHandler(null).drop(id);
|
||||
}
|
||||
|
||||
}catch(Exception e){logger.error("error in notification received",e);}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -13,9 +13,6 @@ import org.gcube.vremanagement.vremodeler.resources.handlers.FunctionalityHandle
|
|||
import org.gcube.vremanagement.vremodeler.resources.handlers.GHNHandler;
|
||||
import org.gcube.vremanagement.vremodeler.resources.handlers.GenericResourceHandler;
|
||||
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;
|
||||
|
||||
|
||||
|
@ -68,10 +65,9 @@ public class IStoDBUtil {
|
|||
//DBInterface.deleteAll("VRERELATEDFUNCT");
|
||||
//DBInterface.deleteAll("VRERELATEDGHN");
|
||||
//DBInterface.deleteAll("VRE");
|
||||
DBInterface.deleteAll(NativeMetadataFormatHandler.tableName);
|
||||
//DBInterface.deleteAll(NativeMetadataFormatHandler.tableName);
|
||||
//DBInterface.deleteAll("derivablemdf");
|
||||
DBInterface.deleteAll(MetadataFormatHandler.tableName);
|
||||
DBInterface.deleteAll(MCollectionHandler.tableName);
|
||||
//DBInterface.deleteAll(MetadataFormatHandler.tableName);
|
||||
DBInterface.deleteAll(CollectionHandler.tableName);
|
||||
//DBInterface.deleteAll("relatedserviceid");
|
||||
DBInterface.deleteAll(GHNHandler.tableName);
|
||||
|
|
|
@ -1,21 +1,16 @@
|
|||
package org.gcube.vremanagement.vremodeler.impl;
|
||||
|
||||
import java.net.URI;
|
||||
import java.rmi.RemoteException;
|
||||
import java.sql.Date;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import org.gcube.common.core.faults.GCUBEFault;
|
||||
import org.gcube.common.core.faults.GCUBEUnrecoverableFault;
|
||||
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.deploy.DeployVRE;
|
||||
import org.gcube.vremanagement.vremodeler.impl.util.ModelerCollection;
|
||||
import org.gcube.vremanagement.vremodeler.impl.util.Util;
|
||||
import org.gcube.vremanagement.vremodeler.resources.MetadataFormat;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.CollectionArray;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.CollectionList;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.CollectionType;
|
||||
|
@ -25,8 +20,6 @@ import org.gcube.vremanagement.vremodeler.stubs.FunctionalityList;
|
|||
import org.gcube.vremanagement.vremodeler.stubs.GHNArray;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.GHNList;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.GHNType;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.MetadataFormatResponse;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.SetMDFormatArgs;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.Utils;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.VREDescription;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.deployreport.State;
|
||||
|
@ -174,10 +167,9 @@ public class ModelerService {
|
|||
|
||||
|
||||
ResultSet resRelated= DBInterface.queryDB("select collid from VRERELATEDCOLLECTION where VRERELATEDCOLLECTION.vreid='"+getResource().getId()+"';");
|
||||
while(resRelated.next()){
|
||||
while(resRelated.next())
|
||||
relatedCollection.add(resRelated.getString(1));
|
||||
}
|
||||
|
||||
|
||||
}catch(Exception e) {
|
||||
logger.error("error getting collections",e);
|
||||
throw new GCUBEFault(e);}
|
||||
|
@ -223,102 +215,6 @@ public class ModelerService {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the possibles metadata format for selected collection
|
||||
*
|
||||
* @param request void
|
||||
* @return a list of MetadataFormat
|
||||
* @throws GCUBEFault -
|
||||
*/
|
||||
public MetadataFormatResponse getMetadataRelatedToCollection(VOID var) throws GCUBEFault {
|
||||
|
||||
Hashtable<ModelerCollection, List<MetadataFormat>> nativeMetadataFormat;
|
||||
Hashtable<ModelerCollection, List<MetadataFormat>> selectedMetadataFormat;
|
||||
|
||||
try{
|
||||
DBInterface.connect();
|
||||
|
||||
//retrieve all possible metadataformat for the selected collection
|
||||
nativeMetadataFormat= new Hashtable<ModelerCollection, List<MetadataFormat>>();
|
||||
ResultSet allPossibleMDF= DBInterface.queryDB("select rel.collid, mdf.id, mdf.name, mdf.schemauri, mdf.language, coll.name, coll.description from COLLECTION as coll, VRERELATEDCOLLECTION as rel, MCOLLECTION as mcoll, METADATAFORMAT as mdf, NATIVEMDF as native where rel.vreid='"+getResource().getId()+"' and mcoll.relatedcollectionid=rel.collid and mdf.id=native.mdfid and native.mdcollid=mcoll.id and coll.id=rel.collid;");
|
||||
while (allPossibleMDF.next()){
|
||||
ModelerCollection collection= new ModelerCollection(allPossibleMDF.getString(1), allPossibleMDF.getString(7), allPossibleMDF.getString(6) );
|
||||
MetadataFormat mf= new MetadataFormat(allPossibleMDF.getString(2), allPossibleMDF.getString(3), new URI(allPossibleMDF.getString(4)), allPossibleMDF.getString(5));
|
||||
if (nativeMetadataFormat.containsKey(collection)){
|
||||
nativeMetadataFormat.get(collection).add(mf);
|
||||
}else {
|
||||
ArrayList<MetadataFormat> keyList=new ArrayList<MetadataFormat>();
|
||||
keyList.add(mf);
|
||||
nativeMetadataFormat.put(collection, keyList);
|
||||
}
|
||||
}
|
||||
|
||||
//retrieving selected metadaformat
|
||||
//hashtable <collectionId, MetadataFormat>
|
||||
selectedMetadataFormat= new Hashtable<ModelerCollection, List<MetadataFormat>>();
|
||||
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, METADATAFORMAT 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));
|
||||
|
||||
if (selectedMetadataFormat.containsKey(collection))
|
||||
selectedMetadataFormat.get(collection).add(mf);
|
||||
else {
|
||||
ArrayList<MetadataFormat> keyList=new ArrayList<MetadataFormat>();
|
||||
keyList.add(mf);
|
||||
selectedMetadataFormat.put(collection, keyList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}catch(Exception e) {
|
||||
logger.error("getMEtadataRelatedToCollection Error ",e);
|
||||
throw new GCUBEFault(e);
|
||||
}
|
||||
|
||||
|
||||
return Util.prepareMCFormat( nativeMetadataFormat ,selectedMetadataFormat);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Sets selected Metadata Format
|
||||
*
|
||||
* @param request
|
||||
* @return void
|
||||
* @throws GCUBEFault -
|
||||
*/
|
||||
public void setMetadataRelatedToCollection(SetMDFormatArgs request) throws GCUBEFault {
|
||||
try{
|
||||
DBInterface.ExecuteUpdate("DELETE FROM VRERELATEDMETADATAFORMAT WHERE VRERELATEDMETADATAFORMAT.vreid='"+getResource().getId()+"';");
|
||||
//String[] singleElement;
|
||||
String key=(String) getResource().getId();
|
||||
|
||||
//logger.debug(request.getCollectionIDArray().length+" "+request.getMdFormatIDArray().length+" "+request.getCheckedArray().length+" "+request.getCheckedArray(0).getCheckedRowElement().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++)
|
||||
{
|
||||
if (request.getCheckedArray(i).getCheckedRowElement(j)){
|
||||
row =new ArrayList<String>(3);
|
||||
row.add(key);
|
||||
row.add(request.getCollectionIDArray(i));
|
||||
row.add(request.getMdFormatIDArray(j));
|
||||
values.add(row.toArray(new String[3]));
|
||||
}
|
||||
}
|
||||
|
||||
DBInterface.insertInto("VRERELATEDMETADATAFORMAT", values.toArray(new String[0][0]));
|
||||
}catch(Exception e){
|
||||
logger.error("setMetadataRelateToCollection failed ",e);
|
||||
throw new GCUBEFault(e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an xml with the selectable functionalities
|
||||
* String
|
||||
|
|
|
@ -12,7 +12,6 @@ import org.gcube.common.core.scope.GCUBEScope;
|
|||
import org.gcube.vremanagement.vremodeler.consumers.CollectionConsumer;
|
||||
import org.gcube.vremanagement.vremodeler.consumers.GHNConsumer;
|
||||
import org.gcube.vremanagement.vremodeler.consumers.GenericResourceConsumer;
|
||||
import org.gcube.vremanagement.vremodeler.consumers.MCollectionConsumer;
|
||||
import org.gcube.vremanagement.vremodeler.consumers.RunningInstanceConsumer;
|
||||
import org.gcube.vremanagement.vremodeler.db.DBInterface;
|
||||
import org.gcube.vremanagement.vremodeler.db.IStoDBUtil;
|
||||
|
@ -92,10 +91,6 @@ public class ServiceContext extends GCUBEServiceContext{
|
|||
qnameList= new ArrayList<GCUBENotificationTopic>();
|
||||
qnameList.add(CollectionConsumer.collectionTopic);
|
||||
notifier.registerToISNotification(new CollectionConsumer(scope), qnameList, this, scope);
|
||||
//MCollectionNotification
|
||||
qnameList= new ArrayList<GCUBENotificationTopic>();
|
||||
qnameList.add(MCollectionConsumer.mCollectionTopic);
|
||||
notifier.registerToISNotification(new MCollectionConsumer(scope), qnameList, this, scope);
|
||||
//FunctionalityResource
|
||||
qnameList= new ArrayList<GCUBENotificationTopic>();
|
||||
qnameList.add(GenericResourceConsumer.functionalityTopic);
|
||||
|
@ -108,7 +103,6 @@ public class ServiceContext extends GCUBEServiceContext{
|
|||
topicToRemove.add(GHNConsumer.ghnTopic);
|
||||
topicToRemove.add(RunningInstanceConsumer.riTopic);
|
||||
topicToRemove.add(CollectionConsumer.collectionTopic);
|
||||
topicToRemove.add(MCollectionConsumer.mCollectionTopic);
|
||||
topicToRemove.add(GenericResourceConsumer.functionalityTopic);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.sql.SQLException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.transform.OutputKeys;
|
||||
|
@ -29,17 +28,12 @@ import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.Res
|
|||
import org.gcube.vremanagement.vremodeler.db.DBInterface;
|
||||
import org.gcube.vremanagement.vremodeler.impl.ModelerService;
|
||||
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
|
||||
import org.gcube.vremanagement.vremodeler.resources.MetadataFormat;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.CollectionType;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.CollectionTypeInfo;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityItem;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.GHNType;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.GHNTypeMemory;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.GHNTypeSite;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.MetadataFormatCollectionRelation;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.MetadataFormatItem;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.MetadataFormatRelation;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.MetadataFormatResponse;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.Report;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.RunningInstance;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.VREDescription;
|
||||
|
@ -135,47 +129,6 @@ public class Util {
|
|||
return tmpList;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param res
|
||||
* @return
|
||||
*/
|
||||
public static MetadataFormatResponse prepareMCFormat(Hashtable<ModelerCollection, List<MetadataFormat>> nativeMetadataFormat, Hashtable<ModelerCollection, List<MetadataFormat>> selectedMetadataFormat){
|
||||
|
||||
List<MetadataFormat> mdflistMultiple= new ArrayList<MetadataFormat>();
|
||||
for (List<MetadataFormat> mftmpList: nativeMetadataFormat.values())
|
||||
mdflistMultiple.addAll(mftmpList);
|
||||
List<MetadataFormat> totalMDF= getDistinctObjects(mdflistMultiple);
|
||||
|
||||
List<MetadataFormatItem> metadataFormatItemList= new ArrayList<MetadataFormatItem>();
|
||||
List<MetadataFormatCollectionRelation> metadataFormatRelationList= new ArrayList<MetadataFormatCollectionRelation>();
|
||||
|
||||
try{
|
||||
|
||||
for (MetadataFormat mf: totalMDF)
|
||||
metadataFormatItemList.add(new MetadataFormatItem( mf.getId(),mf.getLanguage(),mf.getName(),mf.getSchemaURI().toString()));
|
||||
|
||||
//setting the native MDF
|
||||
for(ModelerCollection key: nativeMetadataFormat.keySet()){
|
||||
MetadataFormatCollectionRelation mfCollectionRelation= new MetadataFormatCollectionRelation();
|
||||
mfCollectionRelation.setCollId(key.getId());
|
||||
mfCollectionRelation.setDescription(key.getDescription());
|
||||
mfCollectionRelation.setName(key.getName());
|
||||
|
||||
List<MetadataFormatRelation> mfList= new ArrayList<MetadataFormatRelation>();
|
||||
for(MetadataFormat mf: nativeMetadataFormat.get(key))
|
||||
if(selectedMetadataFormat.isEmpty() || ((selectedMetadataFormat.get(key)!=null) && selectedMetadataFormat.get(key).contains(mf)))
|
||||
mfList.add(new MetadataFormatRelation(mf.getId(),true, true));
|
||||
else mfList.add(new MetadataFormatRelation(mf.getId(),true, false));
|
||||
|
||||
mfCollectionRelation.setMfList(mfList.toArray(new MetadataFormatRelation[mfList.size()]));
|
||||
metadataFormatRelationList.add(mfCollectionRelation);
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.warn("error getting metadataFormats",e);
|
||||
}
|
||||
return new MetadataFormatResponse(metadataFormatRelationList.toArray(new MetadataFormatCollectionRelation[metadataFormatRelationList.size()]),metadataFormatItemList.toArray(new MetadataFormatItem[metadataFormatItemList.size()]));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -1,23 +1,24 @@
|
|||
package org.gcube.vremanagement.vremodeler.resources.handlers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
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.informationsystem.client.queries.GCUBEGenericResourceQuery;
|
||||
import org.gcube.common.core.resources.GCUBEGenericResource;
|
||||
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> {
|
||||
public class CollectionHandler implements ResourceHandler<GCUBEGenericResource> {
|
||||
|
||||
private static GCUBELog logger = new GCUBELog(CollectionHandler.class);
|
||||
|
||||
public static final String tableName="COLLECTION";
|
||||
|
||||
public void add(GCUBECollection resource) throws Exception {
|
||||
public void add(GCUBEGenericResource resource) throws Exception {
|
||||
this.insert(resource);
|
||||
|
||||
}
|
||||
|
@ -30,29 +31,27 @@ public class CollectionHandler implements ResourceHandler<GCUBECollection> {
|
|||
|
||||
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(query, ServiceContext.getContext().getScope());
|
||||
for (GCUBECollection collection:collectionList)
|
||||
//TODO: change when the new CM will return to GCUBECollection
|
||||
GCUBEGenericResourceQuery query=client.getQuery(GCUBEGenericResourceQuery.class);
|
||||
query.addAtomicConditions(new AtomicCondition("/Profile/Body/CollectionInfo/user","true"), new AtomicCondition("/Profile/SecondaryType", "GCUBECollection"));
|
||||
List<GCUBEGenericResource> collectionList= client.execute(query, ServiceContext.getContext().getScope());
|
||||
for (GCUBEGenericResource collection:collectionList)
|
||||
try{
|
||||
insert(collection);
|
||||
}catch(Exception e){logger.error("error inserting values in "+tableName, e);}
|
||||
}
|
||||
|
||||
|
||||
private void insert(GCUBECollection collection) throws Exception {
|
||||
if (!collection.isUserCollection()) return;
|
||||
private void insert(GCUBEGenericResource 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()+"");
|
||||
row.add("-1");
|
||||
row.add(System.currentTimeMillis()+"");
|
||||
row.add(System.currentTimeMillis()+"");
|
||||
DBInterface.connect();
|
||||
DBInterface.insertInto(tableName, row.toArray(new String[6]));
|
||||
MCollectionHandler mcollHandler= new MCollectionHandler(collection.getID());
|
||||
mcollHandler.initialize();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package org.gcube.vremanagement.vremodeler.resources.handlers;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import org.gcube.common.core.contexts.GHNContext.Status;
|
||||
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;
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
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(String resourceId) throws Exception {
|
||||
DBInterface.deleteElement(tableName, "ID='"+resourceId+"'");
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
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(String resourceId) 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
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(String resourceId) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
public void initialize() throws Exception {}
|
||||
|
||||
}
|
Loading…
Reference in New Issue