Author: rwesten
Date: Tue Jul 3 08:45:23 2012
New Revision: 1356617
URL: http://svn.apache.org/viewvc?rev=1356617&view=rev
Log:
STANBOL-670: Refactored the Java Object Model for the ExecutionMetadata out of
the ContentItemResource (enhancer.jersey module) so that I can use the same
functionality for collecting statistics for the MultiThreadedTest.
Moved the Domain model in a new package of the enhancement servicesapi module.
Added:
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ChainExecution.java
(with props)
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/Execution.java
(with props)
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ExecutionMetadata.java
(with props)
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ExecutionNode.java
(with props)
Added:
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ChainExecution.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ChainExecution.java?rev=1356617&view=auto
==============================================================================
---
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ChainExecution.java
(added)
+++
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ChainExecution.java
Tue Jul 3 08:45:23 2012
@@ -0,0 +1,48 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.stanbol.enhancer.servicesapi.helper.execution;
+
+import org.apache.clerezza.rdf.core.NonLiteral;
+import org.apache.clerezza.rdf.core.TripleCollection;
+import org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper;
+import org.apache.stanbol.enhancer.servicesapi.helper.ExecutionMetadataHelper;
+import org.apache.stanbol.enhancer.servicesapi.rdf.ExecutionPlan;
+
+
+/**
+ * Parses the Chain
+ * @author westei
+ *
+ */
+public class ChainExecution extends Execution {
+
+ private final String chainName;
+
+ public ChainExecution(TripleCollection graph, NonLiteral node) {
+ super(null,graph,node);
+ NonLiteral ep = ExecutionMetadataHelper.getExecutionPlanNode(graph,
node);
+ if(ep != null){
+ chainName = EnhancementEngineHelper.getString(graph, ep,
ExecutionPlan.CHAIN);
+ } else {
+ chainName = null;
+ }
+ }
+
+ public String getChainName(){
+ return chainName;
+ }
+}
\ No newline at end of file
Propchange:
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ChainExecution.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/Execution.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/Execution.java?rev=1356617&view=auto
==============================================================================
---
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/Execution.java
(added)
+++
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/Execution.java
Tue Jul 3 08:45:23 2012
@@ -0,0 +1,145 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.stanbol.enhancer.servicesapi.helper.execution;
+
+import static
org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper.getReference;
+
+import java.util.Date;
+
+import org.apache.clerezza.rdf.core.NonLiteral;
+import org.apache.clerezza.rdf.core.TripleCollection;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.stanbol.enhancer.servicesapi.helper.ExecutionMetadataHelper;
+import org.apache.stanbol.enhancer.servicesapi.rdf.ExecutionMetadata;
+
+/**
+ * The Execution of an EnhancementEngine as defined by the {@link
#getExecutionNode()}
+ * @author Rupert Westenthaler
+ *
+ */
+public class Execution implements Comparable<Execution>{
+
+ protected final NonLiteral node;
+ private final ExecutionNode executionNode;
+ private final UriRef status;
+ protected final TripleCollection graph;
+ private final Date started;
+ private final Date completed;
+ private final Long duration;
+ private final ChainExecution chain;
+ public Execution(ChainExecution parent, TripleCollection graph, NonLiteral
node) {
+ this.chain = parent;
+ this.graph = graph;
+ this.node = node;
+ NonLiteral executionNode =
ExecutionMetadataHelper.getExecutionNode(graph, node);
+ if(executionNode != null){
+ this.executionNode = new ExecutionNode(graph, executionNode);
+ } else {
+ this.executionNode = null;
+ }
+ this.status = getReference(graph, node, ExecutionMetadata.STATUS);
+ this.started = ExecutionMetadataHelper.getStarted(graph, node);
+ this.completed = ExecutionMetadataHelper.getCompleted(graph, node);
+ if(started != null && completed != null){
+ this.duration = completed.getTime() - started.getTime();
+ } else {
+ this.duration = null;
+ }
+ }
+
+ /**
+ * The Status of the execution
+ * @return the status
+ */
+ public final UriRef getStatus() {
+ return status;
+ }
+
+ /**
+ * The start date of the Execution
+ * @return the started
+ */
+ public final Date getStarted() {
+ return started;
+ }
+
+ /**
+ * The duration of the Execution in milliseconds.
+ * @return the duration
+ */
+ public final Long getDuration() {
+ return duration;
+ }
+ /**
+ * @return the executionNode
+ */
+ public ExecutionNode getExecutionNode() {
+ return executionNode;
+ }
+
+ public Date getCompleted(){
+ return completed;
+ }
+ public boolean isFailed(){
+ return ExecutionMetadata.STATUS_FAILED.equals(status);
+ }
+ public boolean isCompleted(){
+ return ExecutionMetadata.STATUS_COMPLETED.equals(status);
+ }
+
+ @Override
+ public int hashCode() {
+ return node.hashCode();
+ }
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof ExecutionNode &&
((ExecutionNode)o).node.equals(node);
+ }
+ @Override
+ public int compareTo(Execution e2) {
+ if(started != null && e2.started != null){
+ int result = started.compareTo(e2.started);
+ if(result == 0){
+ if(completed != null && e2.completed != null){
+ result = started.compareTo(e2.completed);
+ if(result == 0){
+ return node.toString().compareTo(e2.toString());
+ } else {
+ return result;
+ }
+ } else if (completed == null && e2.completed == null){
+ return node.toString().compareTo(e2.toString());
+ } else {
+ return completed == null ? -1 : 1;
+ }
+ } else {
+ return result;
+ }
+ } else if (started == null && e2.started == null){
+ return node.toString().compareTo(e2.toString());
+ } else {
+ return started == null ? -1 : 1;
+ }
+ }
+
+ /**
+ * @return the chain
+ */
+ public ChainExecution getChain() {
+ return chain;
+ }
+}
\ No newline at end of file
Propchange:
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/Execution.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ExecutionMetadata.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ExecutionMetadata.java?rev=1356617&view=auto
==============================================================================
---
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ExecutionMetadata.java
(added)
+++
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ExecutionMetadata.java
Tue Jul 3 08:45:23 2012
@@ -0,0 +1,61 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.stanbol.enhancer.servicesapi.helper.execution;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.clerezza.rdf.core.NonLiteral;
+import org.apache.clerezza.rdf.core.TripleCollection;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.stanbol.enhancer.servicesapi.helper.ExecutionMetadataHelper;
+
+public class ExecutionMetadata {
+
+
+ private final ChainExecution chainExecution;
+ private final Map<String,Execution> engineExecutions;
+
+ public static ExecutionMetadata parseFrom(TripleCollection
executionMetadata, UriRef contentItemUri){
+ NonLiteral ce =
ExecutionMetadataHelper.getChainExecution(executionMetadata, contentItemUri);
+ ExecutionMetadata em;
+ if(ce != null){
+ em = new ExecutionMetadata(executionMetadata, contentItemUri,ce);
+ } else {
+ em = null;
+ }
+ return em;
+ }
+
+ private ExecutionMetadata(TripleCollection executionMetadata, UriRef
contentItemUri, NonLiteral ce){
+ chainExecution = new ChainExecution(executionMetadata, ce);
+ engineExecutions = new HashMap<String,Execution>();
+ for(NonLiteral ex :
ExecutionMetadataHelper.getExecutions(executionMetadata, ce)){
+ Execution execution = new
Execution(chainExecution,executionMetadata, ex);
+
engineExecutions.put(execution.getExecutionNode().getEngineName(),execution);
+ }
+ }
+
+ public ChainExecution getChainExecution(){
+ return chainExecution;
+ }
+
+ public Map<String,Execution> getEngineExecutions(){
+ return engineExecutions;
+ }
+}
Propchange:
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ExecutionMetadata.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ExecutionNode.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ExecutionNode.java?rev=1356617&view=auto
==============================================================================
---
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ExecutionNode.java
(added)
+++
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ExecutionNode.java
Tue Jul 3 08:45:23 2012
@@ -0,0 +1,64 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.stanbol.enhancer.servicesapi.helper.execution;
+
+import org.apache.clerezza.rdf.core.NonLiteral;
+import org.apache.clerezza.rdf.core.TripleCollection;
+import org.apache.stanbol.enhancer.servicesapi.helper.ExecutionPlanHelper;
+
+/**
+ * An ExecutionNode of the ExecutionPlan.
+ * @author Rupert Westenthaler
+ *
+ */
+public class ExecutionNode {
+
+ final NonLiteral node;
+ private final TripleCollection ep;
+ private final boolean optional;
+ private final String engineName;
+
+ public ExecutionNode(TripleCollection executionPlan, NonLiteral node) {
+ this.node = node;
+ this.ep = executionPlan;
+ this.optional = ExecutionPlanHelper.isOptional(ep, node);
+ this.engineName = ExecutionPlanHelper.getEngine(ep, node);
+ }
+ /**
+ * If the execution of this node is optional
+ * @return
+ */
+ public boolean isOptional() {
+ return optional;
+ }
+ /**
+ * The name of the Engine to be executed by this node
+ * @return
+ */
+ public String getEngineName() {
+ return engineName;
+ }
+
+ @Override
+ public int hashCode() {
+ return node.hashCode();
+ }
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof ExecutionNode &&
((ExecutionNode)o).node.equals(node);
+ }
+}
\ No newline at end of file
Propchange:
incubator/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/execution/ExecutionNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain