本文整理汇总了Java中org.openprovenance.prov.model.WasAssociatedWith类的典型用法代码示例。如果您正苦于以下问题:Java WasAssociatedWith类的具体用法?Java WasAssociatedWith怎么用?Java WasAssociatedWith使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WasAssociatedWith类属于org.openprovenance.prov.model包,在下文中一共展示了WasAssociatedWith类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addAssociations
import org.openprovenance.prov.model.WasAssociatedWith; //导入依赖的package包/类
protected void addAssociations(Connection connection, String query, int param)
throws SQLException, QueryException {
assert (connection != null);
assert (query != null);
assert (param != -1);
l.debug("Entering addAssociations()");
PreparedStatement stmt = null;
ResultSet resultSet = null;
try {
stmt = connection.prepareStatement(query);
stmt.setInt(1, param);
resultSet = stmt.executeQuery();
while (resultSet.next()) {
String associationID = resultSet.getString("association_id");
int activityID = resultSet.getInt("activity_id");
int agentID = resultSet.getInt("agent_id");
String planID = resultSet.getString("plan_id");
// check whether the relationship already exists, if yes, don't add it again
String activityAgentId = getActivityAgentId(activityID, agentID);
if (relationships.get(activityAgentId) != null) {
continue;
}
Activity activity = activities.get(activityID);
if (activity == null) {
// this means, we've found a new activity. so we have to populate
// it and add it to unexpanded list
createActivity(connection, PROVSqlQuery.GET_ACTIVITIES_BY_ACTIVITY_ID, "" + activityID);
// now the activity must be in the map
activity = activities.get(activityID);
unexpandedNodes.push(new GraphNode(GraphNode.NodeType.ACTIVITY, activityID));
}
Agent agent = agents.get(agentID);
if (agent == null) {
// this means, we've found a new agent. so we have to populate
// it and add it to unexpanded list
createAgent(connection, PROVSqlQuery.GET_AGENTS_BY_AGENT_ID, "" + agentID);
// now the agent must be in the map
agent = agents.get(agentID);
unexpandedNodes.push(new GraphNode(GraphNode.NodeType.AGENT, agentID));
}
// create association
WasAssociatedWith wasAssociatedWith = pFactory.newWasAssociatedWith(
getIdQName(QueryConstants.ASSOCIATION_IDENTIFIER + associationID), activity, agent);
if (infoDetailLevel != null && infoDetailLevel.equals(DetailEnumType.FINE)) {
// add attributes
if (planID != null) {
// TODO : handle plan
}
// add external attributes too
addCustomAttributes(PROVSqlQuery.GET_EXE_ASSOCIATION_ATTRIBUTES_BY_ID,
associationID, wasAssociatedWith, connection);
}
// add the used element into the list of relationships
relationships.put(activityAgentId, wasAssociatedWith);
}
l.debug("addAssociations() successful");
} catch (SQLException e) {
l.error("Exiting addAssociations() with error", e);
} finally {
if (stmt != null) {
stmt.close();
}
if (resultSet != null) {
resultSet.close();
}
}
}
示例2: addAssociations
import org.openprovenance.prov.model.WasAssociatedWith; //导入依赖的package包/类
private void addAssociations(Connection connection,
HashMap<String, Activity> activities,
HashMap<String, Agent> agents,
List<Statement> relationships,
String contextWorkflowURI,
DetailEnumType.Enum informationDetailLevel) throws SQLException {
assert (connection != null);
assert (contextWorkflowURI != null);
l.debug("Entering addAssociations()");
PreparedStatement stmt = null;
ResultSet resultSet = null;
try {
stmt = connection.prepareStatement(PROVSqlQuery.GET_PROV_ASSOCIATIONS);
stmt.setString(1, contextWorkflowURI);
stmt.setString(2, contextWorkflowURI);
resultSet = stmt.executeQuery();
while (resultSet.next()) {
String associationID = resultSet.getString(1);
String activityID = QueryConstants.ACTIVITY_IDENTIFIER + resultSet.getString(2);
String agentID = resultSet.getString(3);
String planID = resultSet.getString(4);
Activity activity = activities.get(activityID);
Agent agent = agents.get(QueryConstants.AGENT_IDENTIFIER + agentID);
if (activity == null || agent == null) {
l.error("Activity or Agent is null. Inconsistent WasAssociatedWith relationship..");
return;
}
WasAssociatedWith wasAssociatedWith = pFactory.newWasAssociatedWith(getIdQName(associationID),
activity, agent);
if (informationDetailLevel != null
&& informationDetailLevel.equals(DetailEnumType.FINE)) {
// add attributes
if (planID != null) {
// TODO : handle plan
}
// add external attributes too
addCustomAttributes(PROVSqlQuery.GET_EXE_ASSOCIATION_ATTRIBUTES_BY_ID,
associationID, wasAssociatedWith, connection);
}
// add the used element into the list of relationships
relationships.add(wasAssociatedWith);
}
l.debug("addAssociations() successful");
} catch (SQLException e) {
l.error("Exiting addAssociations() with error", e);
} finally {
if (stmt != null) {
stmt.close();
}
if (resultSet != null) {
resultSet.close();
}
}
}