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


Java WasGeneratedBy类代码示例

本文整理汇总了Java中org.openprovenance.prov.model.WasGeneratedBy的典型用法代码示例。如果您正苦于以下问题:Java WasGeneratedBy类的具体用法?Java WasGeneratedBy怎么用?Java WasGeneratedBy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WasGeneratedBy类属于org.openprovenance.prov.model包,在下文中一共展示了WasGeneratedBy类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addGenerations

import org.openprovenance.prov.model.WasGeneratedBy; //导入依赖的package包/类
protected void addGenerations(Connection connection, String query, int param)
        throws SQLException, QueryException {
    assert (connection != null);
    assert (query != null);
    assert (param != -1);
    l.debug("Entering addGenerations()");

    PreparedStatement generatedStmt = null;
    ResultSet resultSet = null;

    try {
        generatedStmt = connection.prepareStatement(query);
        generatedStmt.setInt(1, param);
        resultSet = generatedStmt.executeQuery();

        while (resultSet.next()) {
            String genID = resultSet.getString("generation_id");
            int activityID = resultSet.getInt("activity_id");
            int entityID = resultSet.getInt("entity_id");
            String location = resultSet.getString("location");
            java.sql.Timestamp usedTime = resultSet.getTimestamp("generation_time");

            // check whether the relationship already exists, if yes, don't add it again
            String activityEntityId = getActivityEntityId(activityID, entityID);
            if (relationships.get(activityEntityId) != null) {
                continue;
            }

            Activity activity = activities.get(activityID);
            if (activity == null) {
                // this is a new activity, so populate it
                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));
            }
            Entity entity = entities.get(entityID);
            if (entity == null) {
                // this is a new entity, so populate it
                entities.put(entityID, createEntity("" + entityID, connection));
                // now the entity must be in the map
                entity = entities.get(entityID);
                unexpandedNodes.push(new GraphNode(GraphNode.NodeType.ENTITY, entityID));
            }
            WasGeneratedBy wasGeneratedBy = pFactory.newWasGeneratedBy(
                    getIdQName(QueryConstants.GENERATION_IDENTIFIER + genID),
                    entity.getId(), activity.getId());

            if (infoDetailLevel != null && infoDetailLevel.equals(DetailEnumType.FINE)) {
                // add attributes
                if (location != null) {
                    wasGeneratedBy.getLocation().add(pFactory.newLocation(location, Name.QNAME_XSD_STRING));
                    // TODO : check Role
                }
                if (usedTime != null) {
                    org.openprovenance.prov.xml.Other timeAtt = pFactory.newOther(getKomaduAttQName("generation-time"),
                            usedTime, Name.QNAME_XSD_DATETIME);
                    pFactory.addAttribute(wasGeneratedBy, timeAtt);
                }
                // add external attributes too
                addCustomAttributes(PROVSqlQuery.GET_EXE_GENERATION_ATTRIBUTES_BY_ID,
                        genID, wasGeneratedBy, connection);
            }
            // add the used element into the list of relationships
            relationships.put(activityEntityId, wasGeneratedBy);
        }
        l.debug("addGenerations() successful");
    } catch (SQLException e) {
        l.error("Exiting addGenerations() with error");
        l.error(e.toString());
    } finally {
        if (generatedStmt != null) {
            generatedStmt.close();
        }
        if (resultSet != null) {
            resultSet.close();
        }
    }
}
 
开发者ID:Data-to-Insight-Center,项目名称:komadu,代码行数:80,代码来源:NonContextGraphGenerator.java

示例2: addGenerations

import org.openprovenance.prov.model.WasGeneratedBy; //导入依赖的package包/类
private void addGenerations(Connection connection,
                           HashMap<String, Activity> activities,
                           HashMap<String, Entity> entities,
                           List<Statement> relationships,
                           String contextWorkflowURI,
                           DetailEnumType.Enum informationDetailLevel) throws SQLException {
    assert (connection != null);
    assert (contextWorkflowURI != null);
    l.debug("Entering addGenerations()");

    PreparedStatement generatedStmt = null;
    ResultSet resultSet = null;

    try {
        generatedStmt = connection.prepareStatement(PROVSqlQuery.GET_PROV_GENERATIONS);
        generatedStmt.setString(1, contextWorkflowURI);
        generatedStmt.setString(2, contextWorkflowURI);

        resultSet = generatedStmt.executeQuery();

        while (resultSet.next()) {
            String genID = resultSet.getString(1);
            String activityID = QueryConstants.ACTIVITY_IDENTIFIER + resultSet.getString(2);
            String entityID = resultSet.getString(3);
            String location = resultSet.getString(4);
            java.sql.Timestamp usedTime = resultSet.getTimestamp(5);

            Activity activity = activities.get(activityID);
            Entity entity = entities.get(entityID);
            if (activity == null || entity == null) {
                l.error("Activity or Entity is null. Inconsistent WasGeneratedBy relationship..");
                return;
            }
            WasGeneratedBy wasGeneratedBy = pFactory.newWasGeneratedBy(getIdQName(genID),
                    entity.getId(), activity.getId());

            if (informationDetailLevel != null
                    && informationDetailLevel.equals(DetailEnumType.FINE)) {
                // add attributes
                if (location != null) {
                    wasGeneratedBy.getLocation().add(pFactory.newLocation(location, Name.QNAME_XSD_STRING));
                    // TODO : check Role
                }
                if (usedTime != null) {
                    Other timeAtt = pFactory.newOther(getKomaduAttQName("generation-time"),
                            usedTime, Name.QNAME_XSD_DATETIME);
                    pFactory.addAttribute(wasGeneratedBy, timeAtt);
                }
                // add external attributes too
                addCustomAttributes(PROVSqlQuery.GET_EXE_GENERATION_ATTRIBUTES_BY_ID,
                        genID, wasGeneratedBy, connection);
            }
            // add the used element into the list of relationships
            relationships.add(wasGeneratedBy);
        }
        l.debug("addGenerations() successful");
    } catch (SQLException e) {
        l.error("Exiting addGenerations() with error");
        l.error(e.toString());
    } finally {
        if (generatedStmt != null) {
            generatedStmt.close();
        }

        if (resultSet != null) {
            resultSet.close();
        }
    }
}
 
开发者ID:Data-to-Insight-Center,项目名称:komadu,代码行数:70,代码来源:ContextGraphGenerator.java


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