Skip to content

Commit ca53b3b

Browse files
authored
Merge pull request #7 from openworm/development
Release 0.3.1
2 parents df5648c + 28ed02c commit ca53b3b

8 files changed

Lines changed: 300 additions & 100 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>org.geppetto</groupId>
66
<artifactId>datasources</artifactId>
77
<name>Geppetto Data Sources bundle</name>
8-
<version>0.3.0</version>
8+
<version>0.3.1</version>
99
<packaging>bundle</packaging>
1010
<properties>
1111
<spring.version>3.1.3.RELEASE</spring.version>

src/main/java/META-INF/spring/osgi-config.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
<aop:scoped-proxy proxy-target-class="false"/>
1919
</bean>
2020

21+
<osgi:service id="AmberOWLDataSourceExporter" ref="amberOWLDataSource"
22+
interface="org.geppetto.core.datasources.IDataSourceService">
23+
</osgi:service>
24+
<bean id="amberOWLDataSource" scope="prototype" class="org.geppetto.datasources.AmberOWLDataSourceService">
25+
<aop:scoped-proxy proxy-target-class="false"/>
26+
</bean>
27+
2128

2229
<bean id="eventListenerBean" class="org.geppetto.core.services.registry.ApplicationListenerBean" />
2330

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*******************************************************************************
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2011 - 2015 OpenWorm.
5+
* http://openworm.org
6+
*
7+
* All rights reserved. This program and the accompanying materials
8+
* are made available under the terms of the MIT License
9+
* which accompanies this distribution, and is available at
10+
* http://opensource.org/licenses/MIT
11+
*
12+
* Contributors:
13+
* OpenWorm - http://openworm.org/people.html
14+
*
15+
* Permission is hereby granted, free of charge, to any person obtaining a copy
16+
* of this software and associated documentation files (the "Software"), to deal
17+
* in the Software without restriction, including without limitation the rights
18+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19+
* copies of the Software, and to permit persons to whom the Software is
20+
* furnished to do so, subject to the following conditions:
21+
*
22+
* The above copyright notice and this permission notice shall be included in
23+
* all copies or substantial portions of the Software.
24+
*
25+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
28+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
29+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
30+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
31+
* USE OR OTHER DEALINGS IN THE SOFTWARE.
32+
*******************************************************************************/
33+
package org.geppetto.datasources;
34+
35+
import org.geppetto.core.datasources.ADataSourceService;
36+
import org.geppetto.core.datasources.ExecuteQueryVisitor;
37+
import org.geppetto.core.datasources.GeppettoDataSourceException;
38+
import org.geppetto.core.datasources.IDataSourceService;
39+
import org.geppetto.core.datasources.IQueryListener;
40+
import org.geppetto.model.Query;
41+
import org.geppetto.model.QueryResults;
42+
import org.geppetto.model.util.GeppettoModelTraversal;
43+
import org.geppetto.model.util.GeppettoVisitingException;
44+
import org.geppetto.model.variables.Variable;
45+
import org.geppetto.model.variables.VariablesFactory;
46+
47+
/**
48+
* @author matteocantarelli
49+
*
50+
*/
51+
public class AmberOWLDataSourceService extends ADataSourceService implements IDataSourceService
52+
{
53+
54+
public AmberOWLDataSourceService()
55+
{
56+
super("/templates/amberOWL/queryTemplate.vm");
57+
}
58+
59+
/*
60+
* (non-Javadoc)
61+
*
62+
* @see org.geppetto.core.model.QueryProvider#getNumberOfResults(org.geppetto.core.model.Query, org.geppetto.model.variables.Variable)
63+
*/
64+
@Override
65+
public int getNumberOfResults(Query query, Variable variable) throws GeppettoDataSourceException
66+
{
67+
Query fetchVariableQuery = getConfiguration().getFetchVariableQuery();
68+
ExecuteQueryVisitor runQueryVisitor = new ExecuteQueryVisitor(this.getConfiguration(), getTemplate(), variable, getGeppettoModelAccess(), true, ConnectionType.GET);
69+
try
70+
{
71+
GeppettoModelTraversal.apply(fetchVariableQuery, runQueryVisitor);
72+
73+
}
74+
catch(GeppettoVisitingException e)
75+
{
76+
throw new GeppettoDataSourceException(e);
77+
}
78+
79+
return runQueryVisitor.getCount();
80+
}
81+
82+
/*
83+
* (non-Javadoc)
84+
*
85+
* @see org.geppetto.core.model.QueryProvider#getNumberOfResults(org.geppetto.core.model.Query, org.geppetto.model.variables.Variable, org.geppetto.core.model.QueryResults)
86+
*/
87+
@Override
88+
public int getNumberOfResults(Query query, Variable variable, QueryResults results) throws GeppettoDataSourceException
89+
{
90+
// TODO Auto-generated method stub
91+
return 0;
92+
}
93+
94+
/*
95+
* (non-Javadoc)
96+
*
97+
* @see org.geppetto.core.model.QueryProvider#execute(org.geppetto.core.model.Query, org.geppetto.model.variables.Variable, org.geppetto.core.model.QueryListener)
98+
*/
99+
@Override
100+
public QueryResults execute(Query query, Variable variable, IQueryListener listener) throws GeppettoDataSourceException
101+
{
102+
// TODO Auto-generated method stub
103+
return null;
104+
}
105+
106+
/*
107+
* (non-Javadoc)
108+
*
109+
* @see org.geppetto.core.model.QueryProvider#execute(org.geppetto.core.model.Query, org.geppetto.model.variables.Variable, org.geppetto.core.model.QueryResults,
110+
* org.geppetto.core.model.QueryListener)
111+
*/
112+
@Override
113+
public QueryResults execute(Query query, Variable variable, QueryResults results, IQueryListener listener) throws GeppettoDataSourceException
114+
{
115+
// TODO Auto-generated method stub
116+
return null;
117+
}
118+
119+
/*
120+
* (non-Javadoc)
121+
*
122+
* @see org.geppetto.core.model.IDataSource#fetchVariable(java.lang.String)
123+
*/
124+
@Override
125+
public void fetchVariable(String variableId) throws GeppettoDataSourceException
126+
{
127+
Variable fetchedVariable = VariablesFactory.eINSTANCE.createVariable();
128+
fetchedVariable.setId(variableId);
129+
getGeppettoModelAccess().addVariable(fetchedVariable);
130+
Query fetchVariableQuery = getConfiguration().getFetchVariableQuery();
131+
ExecuteQueryVisitor runQueryVisitor = new ExecuteQueryVisitor(this.getConfiguration(), getTemplate(), fetchedVariable, getGeppettoModelAccess(), ConnectionType.GET);
132+
try
133+
{
134+
GeppettoModelTraversal.apply(fetchVariableQuery, runQueryVisitor);
135+
136+
}
137+
catch(GeppettoVisitingException e)
138+
{
139+
throw new GeppettoDataSourceException(e);
140+
}
141+
}
142+
143+
}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/*******************************************************************************
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2011 - 2015 OpenWorm.
5+
* http://openworm.org
6+
*
7+
* All rights reserved. This program and the accompanying materials
8+
* are made available under the terms of the MIT License
9+
* which accompanies this distribution, and is available at
10+
* http://opensource.org/licenses/MIT
11+
*
12+
* Contributors:
13+
* OpenWorm - http://openworm.org/people.html
14+
*
15+
* Permission is hereby granted, free of charge, to any person obtaining a copy
16+
* of this software and associated documentation files (the "Software"), to deal
17+
* in the Software without restriction, including without limitation the rights
18+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19+
* copies of the Software, and to permit persons to whom the Software is
20+
* furnished to do so, subject to the following conditions:
21+
*
22+
* The above copyright notice and this permission notice shall be included in
23+
* all copies or substantial portions of the Software.
24+
*
25+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
28+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
29+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
30+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
31+
* USE OR OTHER DEALINGS IN THE SOFTWARE.
32+
*******************************************************************************/
33+
package org.geppetto.datasources;
34+
35+
import org.geppetto.core.datasources.ADataSourceService;
36+
import org.geppetto.core.datasources.GeppettoDataSourceException;
37+
import org.geppetto.core.datasources.IDataSourceService;
38+
import org.geppetto.core.datasources.IQueryListener;
39+
import org.geppetto.model.DataSource;
40+
import org.geppetto.model.DataSourceLibraryConfiguration;
41+
import org.geppetto.model.GeppettoLibrary;
42+
import org.geppetto.model.Query;
43+
import org.geppetto.model.QueryResults;
44+
import org.geppetto.model.types.ImportType;
45+
import org.geppetto.model.types.TypesFactory;
46+
import org.geppetto.model.variables.Variable;
47+
import org.geppetto.model.variables.VariablesFactory;
48+
49+
/**
50+
* @author matteocantarelli
51+
*
52+
*/
53+
public class DummyDataSourceService extends ADataSourceService implements IDataSourceService
54+
{
55+
56+
public DummyDataSourceService()
57+
{
58+
super("");
59+
}
60+
61+
/*
62+
* (non-Javadoc)
63+
*
64+
* @see org.geppetto.core.model.QueryProvider#getNumberOfResults(org.geppetto.core.model.Query, org.geppetto.model.variables.Variable)
65+
*/
66+
@Override
67+
public int getNumberOfResults(Query query, Variable variable) throws GeppettoDataSourceException
68+
{
69+
// TODO Auto-generated method stub
70+
return 0;
71+
}
72+
73+
/*
74+
* (non-Javadoc)
75+
*
76+
* @see org.geppetto.core.model.QueryProvider#getNumberOfResults(org.geppetto.core.model.Query, org.geppetto.model.variables.Variable, org.geppetto.core.model.QueryResults)
77+
*/
78+
@Override
79+
public int getNumberOfResults(Query query, Variable variable, QueryResults results) throws GeppettoDataSourceException
80+
{
81+
// TODO Auto-generated method stub
82+
return 0;
83+
}
84+
85+
/*
86+
* (non-Javadoc)
87+
*
88+
* @see org.geppetto.core.model.QueryProvider#execute(org.geppetto.core.model.Query, org.geppetto.model.variables.Variable, org.geppetto.core.model.QueryListener)
89+
*/
90+
@Override
91+
public QueryResults execute(Query query, Variable variable, IQueryListener listener) throws GeppettoDataSourceException
92+
{
93+
// TODO Auto-generated method stub
94+
return null;
95+
}
96+
97+
/*
98+
* (non-Javadoc)
99+
*
100+
* @see org.geppetto.core.model.QueryProvider#execute(org.geppetto.core.model.Query, org.geppetto.model.variables.Variable, org.geppetto.core.model.QueryResults,
101+
* org.geppetto.core.model.QueryListener)
102+
*/
103+
@Override
104+
public QueryResults execute(Query query, Variable variable, QueryResults results, IQueryListener listener) throws GeppettoDataSourceException
105+
{
106+
// TODO Auto-generated method stub
107+
return null;
108+
}
109+
110+
/*
111+
* (non-Javadoc)
112+
*
113+
* @see org.geppetto.core.model.IDataSource#fetchVariable(java.lang.String)
114+
*/
115+
@Override
116+
public void fetchVariable(String variableId) throws GeppettoDataSourceException
117+
{
118+
Variable fetchedVariable = VariablesFactory.eINSTANCE.createVariable();
119+
fetchedVariable.setId(variableId);
120+
getGeppettoModelAccess().addVariable(fetchedVariable);
121+
ImportType importType = TypesFactory.eINSTANCE.createImportType();
122+
importType.setId("Type"+variableId); //an SWC for instance
123+
importType.setUrl(""); //an SWC for instance
124+
fetchedVariable.getTypes().add(importType);
125+
importType.setModelInterpreterId("swcModelInterpreter");
126+
getGeppettoModelAccess().addTypeToLibrary(importType, getLibraryFor(getConfiguration(),"swc"));
127+
128+
}
129+
130+
/**
131+
* @param dataSource
132+
* @param format
133+
* @return
134+
*/
135+
private GeppettoLibrary getLibraryFor(DataSource dataSource, String format)
136+
{
137+
for(DataSourceLibraryConfiguration lc: dataSource.getLibraryConfigurations()){
138+
if(lc.getFormat().equals(format))
139+
{
140+
return lc.getLibrary();
141+
}
142+
}
143+
return null;
144+
}
145+
146+
}

src/main/java/org/geppetto/datasources/Neo4jDataSourceService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public Neo4jDataSourceService()
6565
public int getNumberOfResults(Query query, Variable variable) throws GeppettoDataSourceException
6666
{
6767
Query fetchVariableQuery = getConfiguration().getFetchVariableQuery();
68-
ExecuteQueryVisitor runQueryVisitor = new ExecuteQueryVisitor(this.getConfiguration(), getTemplate(), variable, getGeppettoModelAccess(), true);
68+
ExecuteQueryVisitor runQueryVisitor = new ExecuteQueryVisitor(this.getConfiguration(), getTemplate(), variable, getGeppettoModelAccess(), true, ConnectionType.POST);
6969
try
7070
{
7171
GeppettoModelTraversal.apply(fetchVariableQuery, runQueryVisitor);
@@ -128,7 +128,7 @@ public void fetchVariable(String variableId) throws GeppettoDataSourceException
128128
fetchedVariable.setId(variableId);
129129
getGeppettoModelAccess().addVariable(fetchedVariable);
130130
Query fetchVariableQuery = getConfiguration().getFetchVariableQuery();
131-
ExecuteQueryVisitor runQueryVisitor = new ExecuteQueryVisitor(this.getConfiguration(), getTemplate(), fetchedVariable, getGeppettoModelAccess());
131+
ExecuteQueryVisitor runQueryVisitor = new ExecuteQueryVisitor(this.getConfiguration(), getTemplate(), fetchedVariable, getGeppettoModelAccess(), ConnectionType.POST);
132132
try
133133
{
134134
GeppettoModelTraversal.apply(fetchVariableQuery, runQueryVisitor);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$QUERY

0 commit comments

Comments
 (0)