Opinion(final Opinion opinion, final HashMap<String, Term> terms) { this.id = opinion.id; if (opinion.opinionHolder != null) { this.opinionHolder = new OpinionHolder(opinion.opinionHolder, terms); } if (opinion.opinionTarget != null) { this.opinionTarget = new OpinionTarget(opinion.opinionTarget, terms); } if (opinion.opinionExpression != null) { this.opinionExpression = new OpinionExpression(opinion.opinionExpression, terms); } this.externalReferences = new ArrayList<ExternalRef>(); for (final ExternalRef externalRef : opinion.getExternalRefs()) { this.externalReferences.add(new ExternalRef(externalRef)); } }
private static List<ExternalRef> getRefs(final Object annotation) { List<ExternalRef> refs = ImmutableList.of(); if (annotation instanceof Term) { refs = ((Term) annotation).getExternalRefs(); } else if (annotation instanceof Entity) { refs = ((Entity) annotation).getExternalRefs(); } else if (annotation instanceof Predicate) { refs = ((Predicate) annotation).getExternalRefs(); } else if (annotation instanceof Role) { refs = ((Role) annotation).getExternalRefs(); } else if (annotation instanceof Opinion) { refs = ((Opinion) annotation).getExternalRefs(); } else if (annotation instanceof OpinionExpression) { refs = ((OpinionExpression) annotation).getExternalRefs(); } else if (annotation instanceof OpinionTarget) { refs = ((OpinionTarget) annotation).getExternalRefs(); } else if (annotation instanceof OpinionHolder) { refs = ((OpinionHolder) annotation).getExternalRefs(); } else { throw new IllegalArgumentException("Unsupported annotation object: " + annotation); } return refs; }
opinionElem.setAttribute("label", opinion.getLabel()); if (!opinion.getExternalRefs().isEmpty()) { opinionElem.addContent(externalReferencesToDOM(opinion.getExternalRefs()));