/** * Create a date/place fact with the passed in type and values. * * @param factType the fact type. * @param date The date of applicability of this fact. * @param place The place of applicability of this fact. */ public Fact(FactType factType, String date, String place) { this(factType, new Date().original(date), new PlaceReference().original(place), null); }
public Date normalizeDate(String date, StateTransitionOption... options) { Link normalizedDateLink = getLink(Rel.NORMALIZED_DATE); if (normalizedDateLink == null || normalizedDateLink.getTemplate() == null) { return null; } String template = normalizedDateLink.getTemplate(); String uri; try { uri = UriTemplate.fromTemplate(template).set("date", date).expand(); } catch (VariableExpansionException e) { throw new GedcomxApplicationException(e); } catch (MalformedUriTemplateException e) { throw new GedcomxApplicationException(e); } ClientRequest request = createRequest().accept(MediaType.TEXT_PLAIN).build(URI.create(uri), HttpMethod.GET); ClientResponse response = invoke(request, options); Date dateValue = new Date(); dateValue.setOriginal(date); dateValue.addNormalizedExtension(new TextValue(response.getEntity(String.class))); if (response.getHeaders()!= null) { dateValue.setFormal(response.getHeaders().getFirst("Location")); dateValue.getNormalizedExtensions().get(0).setLang(response.getHeaders().getFirst("Content-Language")); } return dateValue; }