本文整理匯總了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();
}
}
}