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

nl.vpro.domain.media.update.PersonUpdate Maven / Gradle / Ivy

Go to download

The basic domain classes for 'media', the core of POMS. Also, the 'update' XML bindings for it. It also contains some closely related domain classes like the enum to contain NICAM kijkwijzer settings.

There is a newer version: 8.3.1
Show newest version
package nl.vpro.domain.media.update;

import lombok.Getter;
import lombok.ToString;

import java.net.URI;

import jakarta.validation.constraints.*;
import jakarta.xml.bind.annotation.*;

import nl.vpro.domain.Xmlns;
import nl.vpro.domain.media.*;
import nl.vpro.validation.WeakWarningValidatorGroup;


/**
 * Copy/paste code from {@link Person}. Mainly to get it in a different namespace.
 *
 * @see nl.vpro.domain.media.update
 * @see nl.vpro.domain.media.Person
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "personUpdateType",
         propOrder = {"givenName",
                      "familyName"})
@XmlRootElement(name = "person")
@ToString(of = { "givenName", "familyName" }, callSuper = true)
public class PersonUpdate extends CreditsUpdate {

    @XmlAttribute
    @Getter
    @NotNull(groups = WeakWarningValidatorGroup.class)
    @nl.vpro.validation.URI(schemes = {"http"}, mustHaveScheme = true, hosts = {"data.beeldengeluid.nl"}, patterns = {"http://data\\.beeldengeluid\\.nl/gtaa/\\d+"})
    private String gtaaUri;

    @XmlElement(namespace = Xmlns.UPDATE_NAMESPACE)
    @Getter
    @Null(groups = WeakWarningValidatorGroup.class)
    protected String givenName;

    @XmlElement(namespace = Xmlns.UPDATE_NAMESPACE)
    @Getter
    @Null(groups = WeakWarningValidatorGroup.class)
    protected String familyName;

    public PersonUpdate(String gtaaUri, RoleType role) {
        super(role);
        this.gtaaUri = gtaaUri;
    }

    public PersonUpdate(String givenName, String familyName, RoleType role) {
        super(role);
        this.givenName = givenName;
        this.familyName = familyName;
    }

    public PersonUpdate(Person p) {
        if (p.getGtaaUri() != null) {
            this.gtaaUri = p.getGtaaUri();
        } else {
            this.givenName = p.getGivenName();
            this.familyName = p.getFamilyName();
        }
        this.role = p.getRole();
    }

    public PersonUpdate() {
        // needed for jaxb
    }

    @Override
    public Credits toCredits() {
        if (gtaaUri != null) {
            return Person.builder()
                .uri(URI.create(gtaaUri))
                .role(role)
                .build();
        } else {
            return Person.builder()
                .givenName(givenName)
                .familyName(familyName)
                .role(role)
                .build();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy