当前位置: 首页>>代码示例>>Java>>正文


Java WasAssociatedWith类代码示例

本文整理汇总了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();
        }
    }
}
 
开发者ID:Data-to-Insight-Center,项目名称:komadu,代码行数:75,代码来源:NonContextGraphGenerator.java

示例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();
        }
    }
}
 
开发者ID:Data-to-Insight-Center,项目名称:komadu,代码行数:62,代码来源:ContextGraphGenerator.java


注:本文中的org.openprovenance.prov.model.WasAssociatedWith类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。