1: <?php
2: /**
3: * Object Representation of DataCite IGSN Metadata
4: * Useage: build DataCite IGSN Metadata XML
5: * @author sfrenzel
6: */
7:
8: class DataCite_Sample_Metadata_Representation extends IGSN_Metadata_Base_Representation {
9:
10: /* Mandatory Properties */
11: const IDENTIFIERTYPE = 'identifierType';
12: const IDENTIFIERTYPEVALUE = 'DOI';
13: const CREATORS = 'creators';
14: const CREATOR = 'creator';
15: const CREATORNAME = 'creatorName';
16: const GIVENNAME = 'givenName';
17: const FAMILYNAME = 'familyName';
18: const NAMEIDENTIFIER = 'nameIdentifier';
19: const NAMEIDENTIFIERSCHEME = 'nameIdentifierScheme';
20: const ORCID = 'ORCID';
21: const PUBLICATIONYEAR = 'publicationYear';
22: const PUBLISHER = 'publisher';
23: const RESOURCETYPE = 'resourceType';
24: const RESOURCETYPEGENERAL = 'resourceTypeGeneral';
25: const RESOURCETYPEGENERALVALUE = 'PhysicalObject';
26: const IGSN = 'IGSN';
27: const IDENTICALTO = 'IsIdenticalTo';
28: const PARTOF = 'IsPartOf';
29: const SUBMITTED = 'Submitted';
30: const NAMETYPE = 'nameType';
31: const PERSONAL = "Personal";
32: const LOCAL = 'Local';
33:
34: /* Recommended Properties */
35: const CONTRIBUTORS = 'contributors';
36: const CONTRIBUTOR = 'contributor';
37: const DATE = 'date';
38: const TITLES = 'titles';
39: const TITLE = 'title';
40:
41: /* Mandatory Properties */
42: public Element $identifier;
43: public Element $creators;
44: public Element $titles;
45:
46: /* IGSNRegistration:registrant */
47: public Element $publisher;
48: public Element $publicationYear;
49: public Element $resourceType;
50: public Element $subject;
51: public Element $contributors;
52: public Element $dates;
53: public Element $relatedIdentifiers;
54: public Element $alternateIdentifiers;
55:
56: public Element $description;
57: public Element $geoLocations;
58:
59: public function __construct($publisher) {
60: $this->setPublisher($publisher);
61: $this->setResourceType();
62: }
63:
64: public function setIdentifier($identifier): void {
65: $this->identifier = $this->setbasicElement($identifier, self::TIDENTIFIER);
66: return;
67: }
68:
69: public function setIdentifier_withType($identifier, $identifierType): void {
70: $this->setIdentifier($identifier);
71: $Itype = $this->setAttribute(self::IDENTIFIERTYPE, $identifierType);
72: $this->identifier->insertAttributes($Itype);
73: }
74:
75: public function setTypeAddIdentifier($identifierType): void {
76: $Itype = $this->setAttribute(self::IDENTIFIERTYPE, $identifierType);
77: $this->identifier->insertAttributes($Itype);
78: }
79:
80: public function setPublisher($publisher): void {
81: $this->publisher = $this->setbasicElement($publisher, self::PUBLISHER);
82: }
83:
84: public function setPublicationYear($publicationYear) {
85: $this->publicationYear = $this->setbasicElement($publicationYear, self::PUBLICATIONYEAR);
86: return $this;
87: }
88:
89: public function set2Creators($creators) {
90: if (isset($this->creators)) {
91: $this->creators->insertChild($creators);
92: } else {
93: $this->creators = $this->setParentElement(self::CREATORS);
94: $this->creators->insertChild($creators);
95: }
96: }
97:
98: public function createCreator(): Element {
99: $creator = $this->setParentElement(self::CREATOR);
100: return $creator;
101: }
102:
103: //@todo redo Build Creator Objekt first vergleiche Contributer in Descriptive Metadaen
104: public function setCreatorname($creatornameele) {
105: $creatorname = $this->setbasicElement($creatornameele, self::CREATORNAME);
106: $this->set2Creators($creatorname);
107: }
108:
109: public function setCreatorname_typePERSONAL($creatornameele) {
110: $creator = $this->createCreator();
111: $creatorname = $this->setbasicElement($creatornameele, self::CREATORNAME);
112: $Itype = $this->setAttribute(self::NAMETYPE, self::PERSONAL);
113: $creatorname->insertAttributes($Itype);
114: $creator->insertChild($creatorname);
115: $this->set2Creators($creator);
116: }
117:
118: public function setCreatornames_typePERSONAL($creatornameele, $givenname, $familyname) {
119: $creator = $this->createCreator();
120: $creatorname = $this->setbasicElement($creatornameele, self::CREATORNAME);
121: $Itype = $this->setAttribute(self::NAMETYPE, self::PERSONAL);
122: $creatorname->insertAttributes($Itype);
123: $creator->insertChild($creatorname);
124: $creatorgivenname = $this->setbasicElement($givenname, self::GIVENNAME);
125: $creator->insertChild($creatorgivenname);
126: $creatorfamilyname = $this->setbasicElement($familyname, self::FAMILYNAME);
127: $creator->insertChild($creatorfamilyname);
128: $this->set2Creators($creator);
129: }
130:
131: public function setCreatornames_typePERSONALAffliattion($creatornameele, $givenname, $familyname, $aff) {
132: $creator = $this->createCreator();
133: $creatorname = $this->setbasicElement($creatornameele, self::CREATORNAME);
134: $Itype = $this->setAttribute(self::NAMETYPE, self::PERSONAL);
135: $creatorname->insertAttributes($Itype);
136: $creator->insertChild($creatorname);
137: $creatorgivenname = $this->setbasicElement($givenname, self::GIVENNAME);
138: $creator->insertChild($creatorgivenname);
139: $creatorfamilyname = $this->setbasicElement($familyname, self::FAMILYNAME);
140: $creator->insertChild($creatorfamilyname);
141: $creatoraff = $this->setbasicElement($aff, 'affiliation');
142: $creator->insertChild($creatoraff);
143: // var_dump($creator);
144: $this->set2Creators($creator);
145: }
146: public function setCreatornames_typePERSONALAffliattionORCIDROR($creatornameele, $givenname, $familyname, $aff, $orcid, $ror) {
147: $creator = $this->createCreator();
148: $creatorname = $this->setbasicElement($creatornameele, self::CREATORNAME);
149: $Itype = $this->setAttribute(self::NAMETYPE, self::PERSONAL);
150: $creatorname->insertAttributes($Itype);
151: $creator->insertChild($creatorname);
152: $creatorgivenname = $this->setbasicElement($givenname, self::GIVENNAME);
153: $creator->insertChild($creatorgivenname);
154: $creatorfamilyname = $this->setbasicElement($familyname, self::FAMILYNAME);
155: $creator->insertChild($creatorfamilyname);
156: $orc_id = $this->setbasicElement($orcid, self::NAMEIDENTIFIER);
157: $nameIdenScheme = $this->setAttribute('nameIdentifierScheme', 'ORCID');
158: $orc_id->insertAttributes($nameIdenScheme);
159: $schemeuri = $this->setAttribute('schemeURI', 'https://orcid.org');
160: $orc_id->insertAttributes($schemeuri);
161: $creator->insertChild($orc_id);
162: $creatoraff = $this->setbasicElement($aff, 'affiliation');
163: $affid = $this->setAttribute('affiliationIdentifier', $ror);
164: $creatoraff->insertAttributes($affid);
165: $affuri = $this->setAttribute('affiliationIdentifierScheme', 'ROR');
166: $creatoraff->insertAttributes($affuri);
167: $creator->insertChild($creatoraff);
168: $this->set2Creators($creator);
169: }
170:
171:
172:
173: public function setCreatornames_typeInstitutional($creatornameele, $aff) {
174: $creator = $this->createCreator();
175: $creatorname = $this->setbasicElement($creatornameele, self::CREATORNAME);
176: $Itype = $this->setAttribute(self::NAMETYPE,'Organizational');
177: $creatorname->insertAttributes($Itype);
178: $creator->insertChild($creatorname);
179: $creatoraff = $this->setbasicElement($aff, 'affiliation');
180: $creator->insertChild($creatoraff);
181: $this->set2Creators($creator);
182: }
183: public function setCreatornames_typeInstitutional_name($creatornameele) {
184: $creator = $this->createCreator();
185: $creatorname = $this->setbasicElement($creatornameele, self::CREATORNAME);
186: $Itype = $this->setAttribute(self::NAMETYPE,'Organizational');
187: $creatorname->insertAttributes($Itype);
188: $creator->insertChild($creatorname);
189: $this->set2Creators($creator);
190: }
191:
192:
193:
194: public function setCreatorGivenname($givenname) {
195: $givennameele = $this->setbasicElement($givenname, self::GIVENNAME);
196: $this->setCreator($givennameele);
197: }
198:
199: public function setCreatorLastname($familyname) {
200: $familynameele = $this->setbasicElement($familyname, self::FAMILYNAME);
201: $this->setCreator($familynameele);
202:
203: }
204:
205: public function setTitles($title) {
206: if (isset($this->titles)) {
207: $this->titles->insertChild($title);
208: } else {
209: $this->titles = $this->setParentElement(self::TITLES);
210: $this->titles->insertChild($title);
211: }
212: }
213:
214: public function setTitle($titleele) {
215: $title = $this->setbasicElement($titleele, self::TITLE);
216: $this->setTitles($title);
217: }
218:
219: public function setResourceType() {
220: $this->resourceType = $this->setbasicElement('material sample', self::RESOURCETYPE);
221: $resourceTypeGeneralt = $this->setAttribute(self::RESOURCETYPEGENERAL, self::RESOURCETYPEGENERALVALUE);
222: $this->resourceType->insertAttributes($resourceTypeGeneralt);
223: }
224:
225: public function setRelatedIdentifiers($relatedIdentifiers): void {
226: if (isset($this->relatedIdentifiers)) {
227: $this->relatedIdentifiers->insertChild($relatedIdentifiers);
228: } else {
229: $this->relatedIdentifiers = $this->setParentElement(self::RELATEDIDENTIFIERS);
230: $this->relatedIdentifiers->insertChild($relatedIdentifiers);
231: }
232: }
233:
234: public function setAlternateIdentifiers($alternateIdentifiers): void {
235: if (isset($this->alternateIdentifiers)) {
236: $this->alternateIdentifiers->insertChild($alternateIdentifiers);
237: } else {
238: $this->alternateIdentifiers = $this->setParentElement(self::ALTERNATEIDENTIFIERS);
239: $this->alternateIdentifiers->insertChild($alternateIdentifiers);
240: }
241: }
242:
243: public function setAlternateIdentifier($alternateIdentifier): void {
244: $alternateIdentifierele = $this->setbasicElement($alternateIdentifier, self::ALTERNATEIDENTIFIER);
245: $this->setAlternateIdentifiers($alternateIdentifierele);
246: }
247:
248: public function setAlternateIdentifier_type($alternateIdentifier, $type): void {
249: $alternateIdentifierele = $this->setbasicElement($alternateIdentifier, self::ALTERNATEIDENTIFIER);
250: $typeele = $this->setAttribute('alternateIdentifierType', $type);
251: $alternateIdentifierele->insertAttributes($typeele);
252: $this->setAlternateIdentifiers($alternateIdentifierele);
253: }
254:
255: //Recommended
256:
257:
258: public function setDates(Element $date) {
259: // $this->titles = $titles;
260: if (isset($this->dates)) {
261: $this->dates->insertChild($date);
262: } else {
263: $this->dates = $this->setParentElement('dates');
264: $this->dates->insertChild($date);
265: }
266: }
267:
268: public function setDate($dateele, $type) {
269: $date = $this->setbasicElement($dateele, 'date');
270: $typeele = $this->setAttribute('dateType', $type);
271: $date->insertAttributes($typeele);
272: $this->setDates($date);
273: }
274:
275: public function setDescription(Element $description) {
276: $this->description = $description;
277: return $this;
278: }
279:
280: public function getCreators(): Element {
281: return $this->creators;
282: }
283:
284: public function getTitles(): Element {
285: return $this->titles;
286: }
287:
288: public function getResourceType(): Element {
289: return $this->resourceType;
290: }
291:
292: public function getRelatedIdentifiers(): Element {
293: return $this->relatedIdentifiers;
294: }
295:
296: }
297: