-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…104) #92 Provide task metadata to event consumer. Expose in debug script. Co-authored-by: marcin.szymura <marcin.szymura@cognifide.com> Co-authored-by: Tomasz Michalak <tomek.michalak@gmail.com> Co-authored-by: Voycawojka <filip.artur.kowalski@gmail.com>
- Loading branch information
1 parent
444b0a9
commit ffa6866
Showing
48 changed files
with
3,318 additions
and
333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
handler/core/src/main/java/io/knotx/fragments/engine/NodeMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright (C) 2019 Knot.x Project | ||
* | ||
* Licensed 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 io.knotx.fragments.engine; | ||
|
||
import io.knotx.fragments.engine.api.node.NodeType; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class NodeMetadata { | ||
|
||
private String nodeId; | ||
private String label; | ||
private NodeType type; | ||
private Map<String, String> transitions; | ||
private List<String> nestedNodes; | ||
private OperationMetadata operation; | ||
|
||
public static NodeMetadata single(String nodeId, String label, Map<String, String> transitions, OperationMetadata operation) { | ||
return new NodeMetadata(nodeId, label, NodeType.SINGLE, transitions, Collections.emptyList(), operation); | ||
} | ||
|
||
public static NodeMetadata composite(String nodeId, String label, Map<String, String> transitions, | ||
List<String> nestedNodes, OperationMetadata operation) { | ||
return new NodeMetadata(nodeId, label, NodeType.COMPOSITE, transitions, nestedNodes, operation); | ||
} | ||
|
||
private NodeMetadata(String nodeId, String label, NodeType type, Map<String, String> transitions, | ||
List<String> nestedNodes, OperationMetadata operation) { | ||
this.nodeId = nodeId; | ||
this.label = label; | ||
this.type = type; | ||
this.transitions = transitions; | ||
this.nestedNodes = nestedNodes; | ||
this.operation = operation; | ||
} | ||
|
||
public String getNodeId() { | ||
return nodeId; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public NodeType getType() { | ||
return type; | ||
} | ||
|
||
/** | ||
* @return transition name to node id map | ||
*/ | ||
public Map<String, String> getTransitions() { | ||
return transitions; | ||
} | ||
|
||
/** | ||
* @return list of composite nodes identifiers | ||
*/ | ||
public List<String> getNestedNodes() { | ||
return nestedNodes; | ||
} | ||
|
||
public OperationMetadata getOperation() { | ||
return operation; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "NodeMetadata{" + | ||
"nodeId='" + nodeId + '\'' + | ||
", label='" + label + '\'' + | ||
", type=" + type + | ||
", transitions=" + transitions + | ||
", nestedNodes=" + nestedNodes + | ||
", operation=" + operation + | ||
'}'; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
handler/core/src/main/java/io/knotx/fragments/engine/OperationMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2019 Knot.x Project | ||
* | ||
* Licensed 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 io.knotx.fragments.engine; | ||
|
||
import io.vertx.core.json.JsonObject; | ||
|
||
public class OperationMetadata { | ||
|
||
private final String factory; | ||
|
||
private final JsonObject data; | ||
|
||
public OperationMetadata(String factory) { | ||
this(factory, new JsonObject()); | ||
} | ||
|
||
public OperationMetadata(String factory, JsonObject data) { | ||
this.factory = factory; | ||
this.data = data; | ||
} | ||
|
||
public String getFactory() { | ||
return factory; | ||
} | ||
|
||
public JsonObject getData() { | ||
return data; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "OperationMetadata{" + | ||
"factory='" + factory + '\'' + | ||
", data=" + data + | ||
'}'; | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
handler/core/src/main/java/io/knotx/fragments/engine/TaskMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (C) 2019 Knot.x Project | ||
* | ||
* Licensed 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 io.knotx.fragments.engine; | ||
|
||
import io.knotx.fragments.handler.ExecutionPlan; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class TaskMetadata { | ||
|
||
private final String taskName; | ||
private final String rootNodeId; | ||
private final Map<String, NodeMetadata> nodesMetadata; | ||
|
||
private TaskMetadata(String taskName, String rootNodeId, Map<String, NodeMetadata> nodesMetadata) { | ||
this.taskName = taskName; | ||
this.rootNodeId = rootNodeId; | ||
this.nodesMetadata = nodesMetadata; | ||
} | ||
|
||
public static TaskMetadata create(String taskName, String rootNodeId, Map<String, NodeMetadata> nodesMetadata) { | ||
return new TaskMetadata(taskName, rootNodeId, nodesMetadata); | ||
} | ||
|
||
public static TaskMetadata noMetadata(String taskName, String rootNodeId) { | ||
return new TaskMetadata(taskName, rootNodeId, new HashMap<>()); | ||
} | ||
|
||
public static TaskMetadata notDefined() { | ||
return noMetadata(ExecutionPlan.UNDEFINED_TASK, ""); | ||
} | ||
|
||
public String getTaskName() { | ||
return taskName; | ||
} | ||
|
||
public String getRootNodeId() { | ||
return rootNodeId; | ||
} | ||
|
||
public Map<String, NodeMetadata> getNodesMetadata() { | ||
return nodesMetadata; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "TaskMetadata{" + | ||
"taskName='" + taskName + '\'' + | ||
", rootNodeId='" + rootNodeId + '\'' + | ||
", nodesMetadata=" + nodesMetadata + | ||
'}'; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
handler/core/src/main/java/io/knotx/fragments/engine/TaskWithMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (C) 2019 Knot.x Project | ||
* | ||
* Licensed 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 io.knotx.fragments.engine; | ||
|
||
import io.knotx.fragments.engine.api.Task; | ||
|
||
public class TaskWithMetadata { | ||
|
||
private final Task task; | ||
private final TaskMetadata metadata; | ||
|
||
public TaskWithMetadata(Task task, TaskMetadata taskMetadata) { | ||
this.task = task; | ||
this.metadata = taskMetadata; | ||
} | ||
|
||
public Task getTask() { | ||
return task; | ||
} | ||
|
||
public TaskMetadata getMetadata() { | ||
return metadata; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "TaskWithMetadata{" + | ||
"task=" + task + | ||
", taskMetadata=" + metadata + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.