Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What exactly is "Attribution" for, and what Classes need one? #192

Merged
merged 4 commits into from
Sep 25, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 4 additions & 46 deletions gedcomx-model/src/main/java/org/gedcomx/common/Attribution.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,24 @@
import org.gedcomx.rt.RDFRange;
import org.gedcomx.rt.RDFSubPropertyOf;
import org.gedcomx.rt.SupportsExtensionElements;
import org.gedcomx.types.ConfidenceLevel;

import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
* Attribution for genealogical information. Attribution is used to model the who is contributing/modifying information,
* when they contributited it, why they are making the contribution/modification, and a statement about their confidence
* in the information being provided.
* Attribution for genealogical information. Attribution is used to model <strong>who</strong> is contributing/modifying
* information, <strong>when</strong> they contributed it, and <strong>why</strong> they are making the
* contribution/modification.
*/
@XmlType ( name = "Attribution", propOrder = { "contributor", "modified", "confidence", "changeMessage", "extensionElements" } )
@XmlType ( name = "Attribution", propOrder = { "contributor", "modified", "changeMessage", "extensionElements" } )
@SuppressWarnings("gedcomx:no_id")
public final class Attribution implements SupportsExtensionElements {

private ResourceReference contributor;
private URI confidence;
private Date modified;
private String changeMessage;
private List<Object> extensionElements;
Expand All @@ -64,45 +61,6 @@ public void setContributor(ResourceReference contributor) {
this.contributor = contributor;
}

/**
* The level of confidence the contributor has about the data.
*
* @return The level of confidence the contributor has about the data.
*/
public URI getConfidence() {
return confidence;
}

/**
* The level of confidence the contributor has about the data.
*
* @param confidence The level of confidence the contributor has about the data.
*/
public void setConfidence(URI confidence) {
this.confidence = confidence;
}

/**
* The value of a the known confidence level, or {@link org.gedcomx.types.ConfidenceLevel#OTHER} if not known.
*
* @return The value of a the known confidence level, or {@link org.gedcomx.types.ConfidenceLevel#OTHER} if not known.
*/
@XmlTransient
@JsonIgnore
public ConfidenceLevel getKnownConfidenceLevel() {
return getConfidence() == null ? null : ConfidenceLevel.fromQNameURI(getConfidence());
}

/**
* Set the confidence level from a known enumeration of confidence levels.
*
* @param level The known level.
*/
@JsonIgnore
public void setKnownConfidenceLevel(ConfidenceLevel level) {
setConfidence(level == null ? null : URI.create(org.codehaus.enunciate.XmlQNameEnumUtil.toURIValue(level)));
}

/**
* The modified timestamp for the attributed data.
*
Expand Down
77 changes: 44 additions & 33 deletions gedcomx-model/src/main/java/org/gedcomx/conclusion/Conclusion.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@
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.HasNotes;
import org.gedcomx.common.Note;
import org.gedcomx.common.*;
import org.gedcomx.rt.SupportsExtensionElements;
import org.gedcomx.source.ReferencesSources;
import org.gedcomx.source.SourceReference;
import org.gedcomx.types.ConfidenceLevel;

import javax.xml.bind.annotation.*;
import java.util.ArrayList;
Expand All @@ -37,12 +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 All @@ -65,6 +63,45 @@ public void setId(String id) {
this.id = id;
}

/**
* The level of confidence the contributor has about the data.
*
* @return The level of confidence the contributor has about the data.
*/
public URI getConfidence() {
return confidence;
}

/**
* The level of confidence the contributor has about the data.
*
* @param confidence The level of confidence the contributor has about the data.
*/
public void setConfidence(URI confidence) {
this.confidence = confidence;
}

/**
* The value of a the known confidence level, or {@link org.gedcomx.types.ConfidenceLevel#OTHER} if not known.
*
* @return The value of a the known confidence level, or {@link org.gedcomx.types.ConfidenceLevel#OTHER} if not known.
*/
@XmlTransient
@JsonIgnore
public ConfidenceLevel getKnownConfidenceLevel() {
return getConfidence() == null ? null : ConfidenceLevel.fromQNameURI(getConfidence());
}

/**
* Set the confidence level from a known enumeration of confidence levels.
*
* @param level The known level.
*/
@JsonIgnore
public void setKnownConfidenceLevel(ConfidenceLevel level) {
setConfidence(level == null ? null : URI.create(org.codehaus.enunciate.XmlQNameEnumUtil.toURIValue(level)));
}

/**
* The source references for a conclusion.
*
Expand Down Expand Up @@ -137,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 @@ -235,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
Loading