コード例 #1
0
  private ItemIdValue processGDMResourceNode(final ResourceNode resourceNode) {

    final String resourceURI = resourceNode.getUri();

    return gdmResourceURIWikidataItemMap.computeIfAbsent(
        resourceURI,
        resourceURI1 -> {
          try {

            final List<MonolingualTextValue> labels = generateLabels(resourceURI);
            final List<MonolingualTextValue> descriptions = generateLabels(resourceURI);
            final List<MonolingualTextValue> aliases = new ArrayList<>();
            final List<StatementGroup> statementGroups = new ArrayList<>();
            final Map<String, SiteLink> siteLinkMap = new HashMap<>();

            // note: list of descriptions cannot be null
            // note: list of aliases cannot be null
            // note: list of statement groups cannot be null
            final ItemDocument wikidataItem =
                Datamodel.makeItemDocument(
                    null, labels, descriptions, aliases, statementGroups, siteLinkMap);

            return createWikidataItem(resourceURI1, wikidataItem);
          } catch (final WikidataImporterException e) {

            throw WikidataImporterError.wrap(e);
          }
        });
  }
コード例 #2
0
  private static String printGDMNode(final Node node) {

    final StringBuilder sb = new StringBuilder();

    final Long id = node.getId();

    sb.append("id = '");

    if (id != null) {

      sb.append(id);
    } else {

      sb.append("no node id available");
    }

    final NodeType nodeType = node.getType();

    switch (nodeType) {
      case Literal:
        sb.append("' :: ");

        final LiteralNode literalNode = (LiteralNode) node;
        final String value = literalNode.getValue();

        sb.append("value = '").append(value);

        break;
      case Resource:
        sb.append("' :: ");

        final ResourceNode resourceNode = (ResourceNode) node;
        final String resourceURI = resourceNode.getUri();

        sb.append("uri = '").append(resourceURI);

        break;
    }

    sb.append("' :: type = '").append(nodeType).append("'}");

    return sb.toString();
  }