Skip to content

Commit 314918d

Browse files
committed
Register output files to use in metaworkflows
1 parent 6fc5fc6 commit 314918d

File tree

12 files changed

+712
-127
lines changed

12 files changed

+712
-127
lines changed

server/src/main/java/org/diskproject/server/adapters/AirFlowAdapter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,10 @@ public String getDataUri(String id) {
133133
// Auto-generated method stub
134134
return null;
135135
}
136+
137+
@Override
138+
public boolean registerData (String id, String type) {
139+
// Auto-generated method stub
140+
return false;
141+
}
136142
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package org.diskproject.server.adapters;
2+
3+
import java.util.ArrayList;
4+
import java.util.HashMap;
5+
import java.util.List;
6+
import java.util.Map;
7+
8+
import org.diskproject.server.repository.WingsAdapter;
9+
import org.diskproject.server.util.Config;
10+
import org.diskproject.server.util.Config.MethodAdapterConfig;
11+
import org.diskproject.server.util.ConfigKeys;
12+
import org.diskproject.shared.classes.adapters.MethodAdapter;
13+
import org.diskproject.shared.classes.workflow.Workflow;
14+
import org.diskproject.shared.classes.workflow.WorkflowVariable;
15+
16+
public class MethodAdapterManager {
17+
protected Map<String, MethodAdapter> byUrl, byName;
18+
19+
public MethodAdapterManager () {
20+
this.byUrl = new HashMap<String, MethodAdapter>();
21+
this.byName = new HashMap<String, MethodAdapter>();
22+
// Read Config
23+
for (MethodAdapterConfig ma: Config.get().methodAdapters) {
24+
MethodAdapter curAdapter = null;
25+
switch (ma.type) {
26+
case ConfigKeys.METHOD_TYPE_WINGS:
27+
curAdapter = new WingsAdapter(ma.name, ma.endpoint, ma.username, ma.password, ma.domain, ma.internalServer);
28+
break;
29+
case ConfigKeys.METHOD_TYPE_AIRFLOW:
30+
curAdapter = new AirFlowAdapter(ma.name, ma.endpoint, ma.username, ma.password);
31+
break;
32+
default:
33+
System.out.println("Error: Method adapter type not found: '" + ma.type + "'");
34+
break;
35+
}
36+
if (curAdapter != null) {
37+
if (ma.version != null)
38+
curAdapter.setVersion(ma.version);
39+
this.byUrl.put(ma.endpoint, curAdapter);
40+
}
41+
}
42+
43+
// Check method adapters:
44+
if (this.byUrl.size() == 0) {
45+
System.err.println("WARNING: No method adapters found on configuration file.");
46+
} else
47+
for (MethodAdapter curAdp : this.byUrl.values()) {
48+
this.byName.put(curAdp.getName(), curAdp);
49+
if (!curAdp.ping()) {
50+
System.err.println("ERROR: Could not connect with " + curAdp.getEndpointUrl());
51+
}
52+
}
53+
}
54+
55+
public MethodAdapter getMethodAdapterByUrl (String url) {
56+
if (this.byUrl.containsKey(url))
57+
return this.byUrl.get(url);
58+
return null;
59+
}
60+
61+
public MethodAdapter getMethodAdapterByName (String name) {
62+
if (this.byName.containsKey(name))
63+
return this.byName.get(name);
64+
return null;
65+
}
66+
67+
public List<Workflow> getWorkflowList () {
68+
List<Workflow> list = new ArrayList<Workflow>();
69+
for (MethodAdapter adapter : this.byUrl.values()) {
70+
for (Workflow wf : adapter.getWorkflowList()) {
71+
list.add(wf);
72+
}
73+
}
74+
return list;
75+
}
76+
77+
public List<WorkflowVariable> getWorkflowVariablesByName (String sourceName, String id) {
78+
MethodAdapter cur = this.getMethodAdapterByName(sourceName);
79+
if (cur != null)
80+
return cur.getWorkflowVariables(id);
81+
return null;
82+
}
83+
84+
public List<WorkflowVariable> getWorkflowVariablesByUrl (String sourceUrl, String id) {
85+
MethodAdapter cur = this.getMethodAdapterByUrl(sourceUrl);
86+
if (cur != null)
87+
return cur.getWorkflowVariables(id);
88+
return null;
89+
}
90+
91+
public String toString () {
92+
String txt = "";
93+
for (String name: byName.keySet()) {
94+
txt += name + " -> " + byName.get(name).getEndpointUrl() + "\n";
95+
}
96+
return txt;
97+
}
98+
}

server/src/main/java/org/diskproject/server/api/impl/DiskResource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public void deleteTriggeredLOI(
353353
public List<Workflow> listWorkflows() {
354354
Gson response_error = new Gson();
355355
try {
356-
return this.repo.getWorkflowList();
356+
return this.repo.methodAdapters.getWorkflowList();
357357
} catch (Exception e) {
358358
try {
359359
// Create Json error response
@@ -381,7 +381,7 @@ public List<Workflow> listWorkflows() {
381381
public List<WorkflowVariable> getWorkflowVariables(
382382
@PathParam("source") String source,
383383
@PathParam("id") String id) {
384-
return this.repo.getWorkflowVariables(source, id);
384+
return this.repo.methodAdapters.getWorkflowVariablesByName(source, id);
385385
}
386386

387387
@GET

0 commit comments

Comments
 (0)