
com.tectonica.jonix.onix3.Publisher Maven / Gradle / Ivy
/*
* Copyright (C) 2012-2024 Zach Melamed
*
* Latest version available online at https://github.com/zach-m/jonix
* Contact me at [email protected]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tectonica.jonix.onix3;
import com.tectonica.jonix.common.JPU;
import com.tectonica.jonix.common.ListOfOnixComposite;
import com.tectonica.jonix.common.ListOfOnixDataComposite;
import com.tectonica.jonix.common.ListOfOnixDataCompositeWithKey;
import com.tectonica.jonix.common.OnixComposite.OnixSuperComposite;
import com.tectonica.jonix.common.codelist.NameIdentifierTypes;
import com.tectonica.jonix.common.codelist.RecordSourceTypes;
import com.tectonica.jonix.common.struct.JonixPublisherIdentifier;
import com.tectonica.jonix.common.struct.JonixWebsite;
import java.io.Serializable;
import java.util.function.Consumer;
/*
* NOTE: THIS IS AN AUTO-GENERATED FILE, DO NOT EDIT MANUALLY
*/
/**
* Publisher composite
*
* An optional group of data elements which together identify an entity which is associated with the publishing of a
* product. The composite allows additional publishing roles to be introduced without adding new fields. Each occurrence
* of the composite must carry a publishing role code and either a name identifier or a name or both, and the composite
* is repeatable in order to identify multiple entities.
*
*
*
* Reference name
* <Publisher>
*
*
* Short tag
* <publisher>
*
*
* Cardinality
* 0…n
*
*
*
* This tag may be included in the following composites:
*
* - <{@link PublishingDetail}>
*
*
* Possible placements within ONIX message:
*
* - {@link Product} ⯈ {@link PublishingDetail} ⯈ {@link Publisher}
*
*/
public class Publisher implements OnixSuperComposite, Serializable {
private static final long serialVersionUID = 1L;
public static final String refname = "Publisher";
public static final String shortname = "publisher";
/////////////////////////////////////////////////////////////////////////////////
// ATTRIBUTES
/////////////////////////////////////////////////////////////////////////////////
/**
* (type: dt.DateOrDateTime)
*/
public String datestamp;
/**
* (type: dt.NonEmptyString)
*/
public String sourcename;
public RecordSourceTypes sourcetype;
/////////////////////////////////////////////////////////////////////////////////
// CONSTRUCTION
/////////////////////////////////////////////////////////////////////////////////
private boolean initialized;
private final boolean exists;
private final org.w3c.dom.Element element;
public static final Publisher EMPTY = new Publisher();
public Publisher() {
exists = false;
element = null;
initialized = true; // so that no further processing will be done on this intentionally-empty object
}
public Publisher(org.w3c.dom.Element element) {
exists = true;
initialized = false;
this.element = element;
datestamp = JPU.getAttribute(element, "datestamp");
sourcename = JPU.getAttribute(element, "sourcename");
sourcetype = RecordSourceTypes.byCode(JPU.getAttribute(element, "sourcetype"));
}
@Override
public void _initialize() {
if (initialized) {
return;
}
initialized = true;
JPU.forElementsOf(element, e -> {
final String name = e.getNodeName();
switch (name) {
case PublishingRole.refname:
case PublishingRole.shortname:
publishingRole = new PublishingRole(e);
break;
case PublisherIdentifier.refname:
case PublisherIdentifier.shortname:
publisherIdentifiers = JPU.addToList(publisherIdentifiers, new PublisherIdentifier(e));
break;
case PublisherName.refname:
case PublisherName.shortname:
publisherName = new PublisherName(e);
break;
case Funding.refname:
case Funding.shortname:
fundings = JPU.addToList(fundings, new Funding(e));
break;
case Website.refname:
case Website.shortname:
websites = JPU.addToList(websites, new Website(e));
break;
default:
break;
}
});
}
/**
* @return whether this tag (<Publisher> or <publisher>) is explicitly provided in the ONIX XML
*/
@Override
public boolean exists() {
return exists;
}
public void ifExists(Consumer action) {
if (exists) {
action.accept(this);
}
}
@Override
public org.w3c.dom.Element getXmlElement() {
return element;
}
/////////////////////////////////////////////////////////////////////////////////
// MEMBERS
/////////////////////////////////////////////////////////////////////////////////
private PublishingRole publishingRole = PublishingRole.EMPTY;
/**
*
* An ONIX code which identifies a role played by an entity in the publishing of a product. Mandatory in each
* occurrence of the <Publisher> composite, and non-repeating.
*
* Jonix-Comment: this field is required
*/
public PublishingRole publishingRole() {
_initialize();
return publishingRole;
}
private ListOfOnixDataCompositeWithKey publisherIdentifiers = JPU.emptyListOfOnixDataCompositeWithKey(PublisherIdentifier.class);
/**
*
* An optional group of data elements which together define the identifier of a publisher name. Optional, but
* mandatory if the <Publisher> composite does not carry a <PublisherName>. The composite is repeatable
* in order to specify multiple identifiers for the same publisher.
*
* Jonix-Comment: this list is required to contain at least one item
*/
public ListOfOnixDataCompositeWithKey
publisherIdentifiers() {
_initialize();
return publisherIdentifiers;
}
private PublisherName publisherName = PublisherName.EMPTY;
/**
*
* The name of an entity associated with the publishing of a product. Mandatory if there is no publisher identifier
* in an occurrence of the <Publisher> composite, and optional if a publisher identifier is included.
* Non-repeating.
*
* Jonix-Comment: this field is optional
*/
public PublisherName publisherName() {
_initialize();
return publisherName;
}
private ListOfOnixComposite fundings = JPU.emptyListOfOnixComposite(Funding.class);
/**
*
* An optional group of data elements which together identify a grant or award provided by the entity specified as a
* funder in an occurence of the <Publisher> composite, to subsidise research or publication. Repeatable when
* the funder provides multiple grants or awards. Used only when <PublishingRole> indicates the role of a
* funder.
*
* Jonix-Comment: this list may be empty
*/
public ListOfOnixComposite fundings() {
_initialize();
return fundings;
}
private ListOfOnixDataComposite websites = JPU.emptyListOfOnixDataComposite(Website.class);
/**
*
* An optional group of data elements which together identify and provide a pointer to a website which is related to
* the publisher identified in an occurrence of the <Publisher> composite. Repeatable in order to provide
* links to multiple websites.
*
* Jonix-Comment: this list may be empty
*/
public ListOfOnixDataComposite websites() {
_initialize();
return websites;
}
}