All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nedap.archie.rm.demographic.Party Maven / Gradle / Ivy

There is a newer version: 3.11.0
Show newest version
package com.nedap.archie.rm.demographic;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.nedap.archie.rm.archetyped.Locatable;
import com.nedap.archie.rm.datastructures.ItemStructure;
import com.nedap.archie.rm.datavalues.DvText;
import com.nedap.archie.rm.support.identification.LocatableRef;
import com.nedap.archie.rminfo.RMPropertyIgnore;

import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * Created by pieter.bos on 08/07/16.
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name="PARTY", propOrder = {
        "identities",
        "contacts",
        "relationships",
        "reverseRelationships",
        "details"
})
public abstract class Party extends Locatable {

    private List identities = new ArrayList<>();
    @Nullable
    private List contacts = new ArrayList<>();
    @Nullable
    private ItemStructure details;
    @Nullable
    @XmlElement(name="reverse_relationships")
    private List reverseRelationships = new ArrayList<>();
    @Nullable
    private List relationships = new ArrayList<>();

    //TODO: uid is redefined here as HIER_OBJECT_ID...


    public List getIdentities() {
        return identities;
    }

    public void setIdentities(List identities) {
        this.identities = identities;
        setThisAsParent(identities, "identities");
    }

    @Nullable
    public List getContacts() {
        return contacts;
    }

    public void setContacts(@Nullable List contacts) {
        this.contacts = contacts;
        setThisAsParent(contacts, "contacts");
    }

    public void addContact(Contact contact) {
        this.contacts.add(contact);
        this.setThisAsParent(contact, "contacts");

    }

    @Nullable
    public ItemStructure getDetails() {
        return details;
    }

    public void setDetails(@Nullable ItemStructure details) {
        this.details = details;
        setThisAsParent(details, "details");
    }

    @Nullable
    public List getReverseRelationships() {
        return reverseRelationships;
    }

    public void setReverseRelationships(@Nullable List reverseRelationships) {
        this.reverseRelationships = reverseRelationships;
    }

    public void addReverseRelationship(LocatableRef reverseRelationship) {
        this.reverseRelationships.add(reverseRelationship);
    }

    @Nullable
    public List getRelationships() {
        return relationships;
    }

    public void setRelationships(@Nullable List relationships) {
        this.relationships = relationships;
        setThisAsParent(relationships, "relationships");
    }

    public void addRelationship(PartyRelationship relationship) {
        this.relationships.add(relationship);
        this.setThisAsParent(relationship, "relationships");
    }

    /**
     * Type of party, such as PERSON, ORGANISATION, etc. Role name, e.g. general practitioner , nurse , private citizen . Taken from inherited name attribute.
     */
    @JsonIgnore
    @XmlTransient
    public DvText getType() {
        return getName();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        Party party = (Party) o;
        return Objects.equals(identities, party.identities) &&
                Objects.equals(contacts, party.contacts) &&
                Objects.equals(details, party.details) &&
                Objects.equals(reverseRelationships, party.reverseRelationships) &&
                Objects.equals(relationships, party.relationships);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), identities, contacts, details, reverseRelationships, relationships);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy