Skip to content

Commit

Permalink
Merge pull request gchq#141 from gchq/gchqgh-140-update-gaffer
Browse files Browse the repository at this point in the history
gchqgh-140 - updated to gaffer 0.7.6
  • Loading branch information
p013570 committed Jul 13, 2017
2 parents 757ec6b + 732637b commit 5bad32b
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 56 deletions.
2 changes: 1 addition & 1 deletion NOTICES
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gaffer tools is built using maven. This process will automatically pull in depen
projects below.


Gaffer (uk.gov.gchq.gaffer:gaffer2:0.7.5):
Gaffer (uk.gov.gchq.gaffer:gaffer2:0.7.6):

- Apache License, Version 2.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ public static void reinitialiseGraph(final TemporaryFolder testFolder, final Str

try (OutputStream out = new FileOutputStream(testFolder.newFile("store.properties"))) {
storeProperties.getProperties()
.store(out, "This is an optional header comment string");
.store(out, "This is an optional header comment string");
}

// set properties for REST service
System.setProperty(uk.gov.gchq.gaffer.rest.SystemProperty.GRAPH_ID, "graph1");
System.setProperty(SystemProperty.STORE_PROPERTIES_PATH, testFolder.getRoot() + "/store.properties");
System.setProperty(SystemProperty.SCHEMA_PATHS, testFolder.getRoot() + "/schema.json");
}
Expand All @@ -99,23 +100,23 @@ public static Response executeServerOperationChain(final String url, final Opera

public static Response executeOperation(final Operation operation) throws IOException {
return client.target(FED_URI)
.path("/graph/doOperation")
.request()
.post(Entity.entity(JSON_SERIALISER.serialise(new OperationChain<>(operation)), APPLICATION_JSON_TYPE));
.path("/graph/doOperation")
.request()
.post(Entity.entity(JSON_SERIALISER.serialise(new OperationChain<>(operation)), APPLICATION_JSON_TYPE));
}

public static Response executeOperationChain(final OperationChain opChain) throws IOException {
return client.target(FED_URI)
.path("/graph/doOperation")
.request()
.post(Entity.entity(JSON_SERIALISER.serialise(opChain), APPLICATION_JSON_TYPE));
.path("/graph/doOperation")
.request()
.post(Entity.entity(JSON_SERIALISER.serialise(opChain), APPLICATION_JSON_TYPE));
}

public static Response executeOperationChainChunked(final OperationChain opChain) throws IOException {
return client.target(FED_URI)
.path("/graph/doOperation/chunked")
.request()
.post(Entity.entity(JSON_SERIALISER.serialise(opChain), APPLICATION_JSON_TYPE));
.path("/graph/doOperation/chunked")
.request()
.post(Entity.entity(JSON_SERIALISER.serialise(opChain), APPLICATION_JSON_TYPE));
}

public static void startServer(final String name, final String url) {
Expand Down
2 changes: 0 additions & 2 deletions federated-rest/src/test/resources/store.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

gaffer.store.class=uk.gov.gchq.gaffer.accumulostore.SingleUseMockAccumuloStore
gaffer.store.properties.class=uk.gov.gchq.gaffer.accumulostore.AccumuloProperties
accumulo.instance=someInstanceName
accumulo.zookeepers=aZookeeper
accumulo.table=table1
accumulo.user=user01
accumulo.password=password
gaffer.federated-rest-admin-auth=admin
1 change: 1 addition & 0 deletions graffer-ql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ An example can be seen in graphql.gaffer.GrafferQlTest.
Create a Gaffer graph in the normal way

Graph graph = new Graph.Builder()
.graphId("aUniqueIdForYourGraph")
.storeProperties(...stuff...)
.addSchemas(...stuff...)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public void before() {

// Setup graph
graph = new Graph.Builder()
.graphId("graph1")
.storeProperties(StreamUtil.openStream(DemoData.class, "mockaccumulo.properties"))
.addSchemas(StreamUtil.openStreams(ElementGroup.class, "schema"))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void test() throws Exception {

// Setup graph
final Graph graph = new Graph.Builder()
.graphId("graph1")
.storeProperties(StreamUtil.openStream(DemoData.class, "mockaccumulo.properties"))
.addSchemas(StreamUtil.openStreams(ElementGroup.class, "schema"))
.build();
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>uk.gov.gchq.gaffer</groupId>
<artifactId>gaffer2</artifactId>
<version>0.7.5</version>
<version>0.7.6</version>
</parent>

<artifactId>gaffer-tools</artifactId>
Expand All @@ -38,7 +38,7 @@
</modules>

<properties>
<gaffer.version>0.7.5</gaffer.version>
<gaffer.version>0.7.6</gaffer.version>
<scm.url>
https://github.com/gchq/gaffer-tools
</scm.url>
Expand Down
2 changes: 1 addition & 1 deletion python-shell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ This creates a distributable Python wheel which can installed locally to provide
The wheel file is install using pip:

```bash
pip3 install gaffer_shell-0.7.5-py2.py3-none-any.whl
pip3 install gaffer_shell-0.7.6-py2.py3-none-any.whl
```

After installation the shell can be imported into an application as below:
Expand Down
2 changes: 1 addition & 1 deletion python-shell/src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.7.5"
__version__ = "0.7.6"

__title__ = "gafferpy"
__description__ = "Gaffer Python Shell"
Expand Down
2 changes: 1 addition & 1 deletion python-shell/src/gafferpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.7.5"
__version__ = "0.7.6"

__title__ = "gafferpy"
__description__ = "Gaffer Python Shell"
Expand Down
47 changes: 35 additions & 12 deletions python-shell/src/gafferpy/gaffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,21 @@ def to_gaffer_objects(result):
result_item['directed'])
if 'properties' in result_item:
element.properties = result_item['properties']
if 'matchedVertex' in result_item:
element.matched_vertex = result_item[
'matchedVertex']
objs.append(element)
elif result_item[
'class'] == 'uk.gov.gchq.gaffer.operation.data.EntitySeed':
objs.append(EntitySeed(result_item['vertex']))
elif result_item[
'class'] == 'uk.gov.gchq.gaffer.operation.data.EdgeSeed':
objs.append(EdgeSeed(result_item['source'],
result_item['destination'],
result_item['directed']))
seed = EdgeSeed(result_item['source'],
result_item['destination'],
result_item['directed'])
if 'matchedVertex' in result_item:
seed.matched_vertex = result_item['matchedVertex']
objs.append(seed)
else:
raise TypeError(
'Element type is not recognised: ' + str(
Expand Down Expand Up @@ -116,7 +122,7 @@ def to_json_wrapped(self):


class EdgeSeed(ElementSeed):
def __init__(self, source, destination, directed):
def __init__(self, source, destination, directed, matched_vertex=None):
super().__init__()
self.source = source
self.destination = destination
Expand All @@ -126,21 +132,33 @@ def __init__(self, source, destination, directed):
self.directed = DirectedType.DIRECTED
else:
self.directed = DirectedType.UNDIRECTED
self.matched_vertex = matched_vertex

def to_json(self):
return {
seed = {
'class': 'uk.gov.gchq.gaffer.operation.data.EdgeSeed',
'source': self.source,
'destination': self.destination,
'directed': self.directed}
'directed': self.directed
}

if self.matched_vertex is not None:
seed['matchedVertex'] = self.matched_vertex

return seed

def to_json_wrapped(self):
seed = {
'source': self.source,
'destination': self.destination,
'directed': self.directed
}

if self.matched_vertex is not None:
seed['matchedVertex'] = self.matched_vertex

return {
'uk.gov.gchq.gaffer.operation.data.EdgeSeed': {
'source': self.source,
'destination': self.destination,
'directed': self.directed
}
'uk.gov.gchq.gaffer.operation.data.EdgeSeed': seed
}


Expand Down Expand Up @@ -230,7 +248,8 @@ def to_json(self):


class Edge(Element):
def __init__(self, group, source, destination, directed, properties=None):
def __init__(self, group, source, destination, directed, properties=None,
matched_vertex=None):
super().__init__('uk.gov.gchq.gaffer.data.element.Edge', group,
properties)
# Validate the arguments
Expand All @@ -239,12 +258,16 @@ def __init__(self, group, source, destination, directed, properties=None):
self.source = source
self.destination = destination
self.directed = directed
self.matched_vertex = matched_vertex

def to_json(self):
edge = super().to_json()
edge['source'] = self.source
edge['destination'] = self.destination
edge['directed'] = self.directed
if self.matched_vertex is not None:
edge['matchedVertex'] = self.matched_vertex

return edge


Expand Down
3 changes: 2 additions & 1 deletion python-shell/src/test/test_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def test_execute_operation(self):
)

self.assertEqual(
[g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", True, {})],
[g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", True, {},
"SOURCE")],
elements)


Expand Down
50 changes: 29 additions & 21 deletions python-shell/src/test/test_gaffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,23 @@ def test_edge_seed(self):
'class': 'uk.gov.gchq.gaffer.operation.data.EdgeSeed',
'source': 'src',
'destination': 'dest',
'directed': 'DIRECTED'
'directed': 'DIRECTED',
'matchedVertex': 'SOURCE'
},
g.EdgeSeed("src", "dest", g.DirectedType.DIRECTED).to_json()
g.EdgeSeed("src", "dest", g.DirectedType.DIRECTED,
"SOURCE").to_json()
)

self.assertEqual(
{
'class': 'uk.gov.gchq.gaffer.operation.data.EdgeSeed',
'source': 'src',
'destination': 'dest',
'directed': 'UNDIRECTED'
'directed': 'UNDIRECTED',
'matchedVertex': 'DESTINATION'
},
g.EdgeSeed("src", "dest", g.DirectedType.UNDIRECTED).to_json()
g.EdgeSeed("src", "dest", g.DirectedType.UNDIRECTED,
"DESTINATION").to_json()
)

self.assertEqual(
Expand Down Expand Up @@ -193,10 +197,12 @@ def test_edge(self):
'group': 'group',
'source': 'source',
'destination': 'destination',
'directed': True

'directed': True,
'matchedVertex': 'SOURCE',
'properties': {}
},
g.Edge("group", "source", "destination", True).to_json()
g.Edge("group", "source", "destination", True, {},
"SOURCE").to_json()
)

self.assertEqual(
Expand All @@ -205,10 +211,11 @@ def test_edge(self):
'group': 'group',
'source': 'source',
'destination': 'destination',
'directed': False

'directed': False,
'matchedVertex': 'DESTINATION'
},
g.Edge("group", "source", "destination", False).to_json()
g.Edge("group", "source", "destination", False, None,
"DESTINATION").to_json()
)

self.assertEqual(
Expand Down Expand Up @@ -302,7 +309,7 @@ def test_element_definition(self):
'transientProperties': {'test_prop': 'test_prop_class'},
'preAggregationFilterFunctions':
[{'predicate': {'class':
'test_filter_class',
'test_filter_class',
'value': {
'test_value_class': 1}},
'selection': ['test_selection']}]
Expand All @@ -323,13 +330,13 @@ def test_element_definition(self):
'transientProperties': {'test_prop': 'test_prop_class'},
'preAggregationFilterFunctions':
[{'predicate': {'class':
'test_filter_class',
'test_filter_class',
'value': {
'test_value_class': 1}},
'selection': ['test_selection']}],
'postAggregationFilterFunctions':
[{'predicate': {'class':
'test_filter_class_1',
'test_filter_class_1',
'value': {
'test_value_class_1': 1}},
'selection': ['test_selection_1']}]
Expand All @@ -355,13 +362,13 @@ def test_element_definition(self):
'transientProperties': {'test_prop': 'test_prop_class'},
'preAggregationFilterFunctions':
[{'predicate': {'class':
'test_filter_class',
'test_filter_class',
'value': {
'test_value_class': 1}},
'selection': ['test_selection']}],
'postAggregationFilterFunctions':
[{'predicate': {'class':
'test_filter_class_1',
'test_filter_class_1',
'value': {
'test_value_class_1': 1}},
'selection': ['test_selection_1']}],
Expand Down Expand Up @@ -399,13 +406,13 @@ def test_element_definition(self):
'transientProperties': {'test_prop': 'test_prop_class'},
'preAggregationFilterFunctions':
[{'predicate': {'class':
'test_filter_class',
'test_filter_class',
'value': {
'test_value_class': 1}},
'selection': ['test_selection']}],
'postAggregationFilterFunctions':
[{'predicate': {'class':
'test_filter_class_1',
'test_filter_class_1',
'value': {
'test_value_class_1': 1}},
'selection': ['test_selection_1']}],
Expand All @@ -416,7 +423,7 @@ def test_element_definition(self):
['src', 'dest',
'count']}],
'postTransformFilterFunctions': [{'function': {'class':
'test_class_1'},
'test_class_1'},
'projection':
['description'],
'selection':
Expand Down Expand Up @@ -506,7 +513,7 @@ def test_transform_function(self):
'projection': 'projection'
},
g.TransformFunction("test_class", "selection", "projection")
.to_json()
.to_json()
)

self.assertEqual(
Expand Down Expand Up @@ -690,7 +697,7 @@ def test_generate_elements(self):
},
g.GenerateElements("generate_class_elements",
view=g.View(), options={"option1": "option"})
.to_json()
.to_json()
)

def test_generate_objects(self):
Expand Down Expand Up @@ -722,7 +729,8 @@ def test_generate_objects(self):
'group': 'group',
'vertex': 'vertex'}]
},
g.GenerateObjects("test_class_name", elements=[g.Entity("group", "vertex")]).to_json()
g.GenerateObjects("test_class_name",
elements=[g.Entity("group", "vertex")]).to_json()
)

self.assertEqual(
Expand Down
Loading

0 comments on commit 5bad32b

Please sign in to comment.