Skip to content

Commit

Permalink
pushing 'attribution' down to top-level entities: code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
stoicflame committed Sep 19, 2012
1 parent b03aa16 commit c7265b0
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 187 deletions.
31 changes: 2 additions & 29 deletions gedcomx-model/src/main/java/org/gedcomx/conclusion/Conclusion.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@
* @author Ryan Heaton
*/
@XmlType ( name = "Conclusion" )
public abstract class Conclusion implements Attributable, ReferencesSources, HasNotes, SupportsExtensionElements {
public abstract class Conclusion implements ReferencesSources, HasNotes, SupportsExtensionElements {

private String id;
private URI confidence;
private List<SourceReference> sources;
private List<Note> notes;
private Attribution attribution;
protected List<Object> extensionElements;

/**
Expand Down Expand Up @@ -175,26 +174,6 @@ public void addNote(Note note) {
}
}

/**
* Attribution metadata for a conclusion.
*
* @return Attribution metadata for a conclusion.
*/
@Override
public Attribution getAttribution() {
return attribution;
}

/**
* Attribution metadata for a conclusion.
*
* @param attribution Attribution metadata for a conclusion.
*/
@Override
public void setAttribution(Attribution attribution) {
this.attribution = attribution;
}

/**
* Custom extension elements for a conclusion.
*
Expand Down Expand Up @@ -273,13 +252,7 @@ public <E> List<E> findExtensionsOfType(Class<E> clazz) {
*/
@Override
public String toString() {
StringBuilder s = new StringBuilder((getId() == null) ? "" : getId());

if (getAttribution() != null) {
s.append(": ").append(getAttribution().toString());
}

return s.toString();
return (getId() == null) ? "" : getId();
}

}
28 changes: 26 additions & 2 deletions gedcomx-model/src/main/java/org/gedcomx/conclusion/Document.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.gedcomx.conclusion;

import org.gedcomx.common.Attributable;
import org.gedcomx.common.Attribution;
import org.gedcomx.common.HasText;
import org.gedcomx.common.TextValue;

Expand All @@ -24,10 +26,32 @@
/**
* An abstract document that contains derived (conclusionary) text -- for example, a transcription or researcher analysis.
*/
@XmlType(name = "Document")
public abstract class Document extends Conclusion implements HasText {
@XmlType(name = "Document", propOrder = { "attribution", "text" })
public abstract class Document extends Conclusion implements HasText, Attributable {

private Attribution attribution;
private TextValue text;

/**
* Attribution metadata for a conclusion.
*
* @return Attribution metadata for a conclusion.
*/
@Override
public Attribution getAttribution() {
return attribution;
}

/**
* Attribution metadata for a conclusion.
*
* @param attribution Attribution metadata for a conclusion.
*/
@Override
public void setAttribution(Attribution attribution) {
this.attribution = attribution;
}

/**
* The document text.
*
Expand Down
27 changes: 25 additions & 2 deletions gedcomx-model/src/main/java/org/gedcomx/conclusion/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.codehaus.enunciate.json.JsonName;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.gedcomx.common.Attributable;
import org.gedcomx.common.Attribution;
import org.gedcomx.common.URI;
import org.gedcomx.rt.json.JsonElementWrapper;
import org.gedcomx.types.EventType;
Expand All @@ -33,10 +35,11 @@
*/
@XmlRootElement
@JsonElementWrapper (name = "events")
@XmlType ( name = "Event", propOrder = { "date", "place", "roles" } )
public class Event extends Conclusion implements HasDateAndPlace {
@XmlType ( name = "Event", propOrder = { "attribution", "date", "place", "roles" } )
public class Event extends Conclusion implements HasDateAndPlace, Attributable {

private URI type;
private Attribution attribution;
private Date date;
private Place place;
private List<EventRole> roles;
Expand Down Expand Up @@ -109,6 +112,26 @@ public void setKnownType(org.gedcomx.types.EventType knownType) {
setType(knownType == null ? null : URI.create(org.codehaus.enunciate.XmlQNameEnumUtil.toURIValue(knownType)));
}

/**
* Attribution metadata for a conclusion.
*
* @return Attribution metadata for a conclusion.
*/
@Override
public Attribution getAttribution() {
return attribution;
}

/**
* Attribution metadata for a conclusion.
*
* @param attribution Attribution metadata for a conclusion.
*/
@Override
public void setAttribution(Attribution attribution) {
this.attribution = attribution;
}

/**
* The date of this event.
*
Expand Down
27 changes: 25 additions & 2 deletions gedcomx-model/src/main/java/org/gedcomx/conclusion/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.codehaus.enunciate.json.JsonName;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.gedcomx.common.Attributable;
import org.gedcomx.common.Attribution;
import org.gedcomx.common.URI;
import org.gedcomx.rt.json.JsonElementWrapper;
import org.gedcomx.types.FactType;
Expand All @@ -40,15 +42,36 @@
*/
@XmlRootElement
@JsonElementWrapper (name = "persons")
@XmlType ( name = "Person", propOrder = { "identifiers", "living", "gender", "names", "facts" } )
public class Person extends Conclusion implements HasFacts {
@XmlType ( name = "Person", propOrder = { "attribution", "identifiers", "living", "gender", "names", "facts" } )
public class Person extends Conclusion implements HasFacts, Attributable {

private Attribution attribution;
private List<Identifier> identifiers;
private Boolean living;
private Gender gender;
private List<Name> names;
private List<Fact> facts;

/**
* Attribution metadata for a conclusion.
*
* @return Attribution metadata for a conclusion.
*/
@Override
public Attribution getAttribution() {
return attribution;
}

/**
* Attribution metadata for a conclusion.
*
* @param attribution Attribution metadata for a conclusion.
*/
@Override
public void setAttribution(Attribution attribution) {
this.attribution = attribution;
}

/**
* Find the long-term, persistent identifier for this person from the list of identifiers.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.codehaus.enunciate.json.JsonName;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.gedcomx.common.Attributable;
import org.gedcomx.common.Attribution;
import org.gedcomx.common.ResourceReference;
import org.gedcomx.common.URI;
import org.gedcomx.rt.RDFRange;
Expand All @@ -37,10 +39,11 @@
*/
@XmlRootElement
@JsonElementWrapper ( name = "relationships" )
@XmlType ( name = "Relationship", propOrder = { "person1", "person2", "facts" } )
public class Relationship extends Conclusion implements HasFacts {
@XmlType ( name = "Relationship", propOrder = { "attribution", "person1", "person2", "facts" } )
public class Relationship extends Conclusion implements HasFacts, Attributable {

private URI type;
private Attribution attribution;
private ResourceReference person1;
private ResourceReference person2;
private List<Fact> facts;
Expand Down Expand Up @@ -85,6 +88,26 @@ public void setKnownType(RelationshipType type) {
setType(type == null ? null : URI.create(org.codehaus.enunciate.XmlQNameEnumUtil.toURIValue(type)));
}

/**
* Attribution metadata for a conclusion.
*
* @return Attribution metadata for a conclusion.
*/
@Override
public Attribution getAttribution() {
return attribution;
}

/**
* Attribution metadata for a conclusion.
*
* @param attribution Attribution metadata for a conclusion.
*/
@Override
public void setAttribution(Attribution attribution) {
this.attribution = attribution;
}

/**
* A reference to a person in the relationship. The name "person1" is used only to distinguish it from
* the other person in this relationship and implies neither order nor role. When the relationship type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,11 @@
@XmlRootElement ( name = "sourceReference" )
@JsonElementWrapper ( name = "source-references" )
@XmlType ( name = "SourceReference" )
public class SourceReference implements Attributable, SupportsExtensionElements {
public class SourceReference implements SupportsExtensionElements {

private ResourceReference sourceDescription;
private Attribution attribution;
private List<Object> extensionElements;

/**
* The attribution metadata for this source reference.
*
* @return The attribution metadata for this source reference.
*/
public Attribution getAttribution() {
return attribution;
}

/**
* The attribution metadata for this source reference.
*
* @param attribution The attribution metadata for this source reference.
*/
public void setAttribution(Attribution attribution) {
this.attribution = attribution;
}

/**
* A reference to a description of the source being referenced.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public void testAbstractDocument() throws Exception {
document.addExtensionElement(new CustomEntity("1234"));
document.addExtensionElement(new CustomEntity("2345"));

assertEquals(document.toString(), "DDDD-DDD: urn:contributor-id");
assertEquals(document.getId(), "DDDD-DDD");
assertEquals(document.getText().getLang(), "en-US");
assertEquals(document.getText().getValue(), "(The text of the document abstract goes here.)");
Expand Down
Loading

0 comments on commit c7265b0

Please sign in to comment.