ProvidedCHO.scala 6.07 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * rico2edm
 * Copyright (C) 2021  UB Basel
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 */


21
package ch.memobase.rico2edm.edm.subjects
22

23
24
import ch.memobase.rico2edm.rdf.Helper
import ch.memobase.rico2edm.rdf.vocabularies.{EDMVocab, OreVocab}
25
26
27
import org.eclipse.rdf4j.model.Model
import org.eclipse.rdf4j.model.impl.SimpleValueFactory
import org.eclipse.rdf4j.model.util.Values.iri
28
import org.eclipse.rdf4j.model.vocabulary.{DC, DCTERMS, RDF, SKOS}
29
30
31
32
33
34

class ProvidedCHO (val id: String)  {

  import org.eclipse.rdf4j.model.util.Values.iri
  //import org.eclipse.rdf4j.model.util.Values.literal
  private val model = Helper.getModelWithEDMNamespaces
35
  model.add(iri(id),RDF.TYPE, EDMVocab.ProvidedCHO)
36
37
38
39
40
41
42
43
44
45
46
47
48

  private val factory = SimpleValueFactory.getInstance()

  def addDescription(desc: Option[String]): Unit =
    desc.map(t => model.add(iri(id),DC.DESCRIPTION,factory.createLiteral(t)))

  def addTitel(title: Option[String]): Unit = {
    title.map(t => model.add(iri(id),DC.TITLE,factory.createLiteral(t)))
  }

  def addCreationDate(createDate:Option[String]): Unit =
    createDate.map(t => model.add(iri(id),DC.DATE,factory.createLiteral(t)))

49
50
  def addCreator(creator:Option[String]): Unit =
    creator.map(t => model.add(iri(id),DC.CREATOR,factory.createLiteral(t)))
51
52
53
54
55


  def addContributor(contributor:Option[String]): Unit =
    contributor.map(t => model.add(iri(id),DC.CONTRIBUTOR,factory.createLiteral(t)))

56
57
  def addIdentifier(identifier:Option[String]): Unit =
    identifier.map(t => model.add(iri(id),DC.IDENTIFIER,factory.createLiteral(t)))
58

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  def addLanguage(language:Option[String]): Unit =
    language.map(t => model.add(iri(id),DC.LANGUAGE,factory.createLiteral(t)))

  def addPublisher(publisher:Option[String]): Unit =
    publisher.map(t => model.add(iri(id),DC.PUBLISHER,factory.createLiteral(t)))

  def addRights(rights:Option[String]): Unit =
    rights.map(t => model.add(iri(id),DC.RIGHTS,factory.createLiteral(t)))

  def addSource(source:Option[String]): Unit =
    source.map(t => model.add(iri(id),DC.SOURCE,factory.createLiteral(t)))

  def addSubject(subject:Option[String]): Unit =
    subject.map(t => model.add(iri(id),DC.SUBJECT,factory.createLiteral(t)))

  def addGenre(genre:Option[String]): Unit =
    genre.map(t => model.add(iri(id),DC.TYPE,factory.createLiteral(t)))
76

77
78
79
  def addDcTermsCreated(dctermsCreated:Option[String]): Unit =
    dctermsCreated.map(t => model.add(iri(id),DCTERMS.CREATED,factory.createLiteral(t)))

80
81
  def addDcTermsExtent(dctermsExtent:Option[String]): Unit =
    dctermsExtent.map(t => model.add(iri(id),DCTERMS.EXTENT,factory.createLiteral(t)))
82

83
84
85
86
87
88
89
90
91
92
93
  def addDcTermsIssued(dctermsIssued:Option[String]): Unit =
    dctermsIssued.map(t => model.add(iri(id),DCTERMS.ISSUED,factory.createLiteral(t)))

  def addDcTermsMedium(medium:Option[String]): Unit =
    medium.map(t => model.add(iri(id),DCTERMS.MEDIUM,factory.createLiteral(t)))

  def addDcTermsSpatial(spatial:Option[String]): Unit =
    spatial.map(t => model.add(iri(id),DCTERMS.SPATIAL,factory.createLiteral(t)))

  def addDcTermsTemporal(temporal:Option[String]): Unit =
    temporal.map(t => model.add(iri(id),DCTERMS.TEMPORAL,factory.createLiteral(t)))
94

95
96
97
98
  def addEdmType(edmtype:Option[String]): Unit =
    edmtype.map(t => model.add(iri(id),EDMVocab.TYPE,factory.createLiteral(t)))


99
100
101
102
103
104
  def getModel: Model = model

}

class WebResource (val id: String) {
  private val model = Helper.getModelWithEDMNamespaces
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
  private val factory = SimpleValueFactory.getInstance()



  model.add(iri(id),RDF.TYPE, EDMVocab.WebResource)

  def getModel: Model = model

}


class Aggregation(val id: String) {
  private val model = Helper.getModelWithEDMNamespaces
  model.add(iri(id),RDF.TYPE, OreVocab.AGGREGATION)

  private val factory = SimpleValueFactory.getInstance()

  def addSkosPrefLabel(skospreflabel:Option[String]): Unit =
    skospreflabel.map(t => model.add(iri(id),SKOS.PREF_LABEL,factory.createLiteral(t)))
124
125
126
127
128

  def getModel: Model = model

}

129
130
131
132
133
134
135
136
137
138
139
object Aggregation {

  //todo: GH discussion with Silvia 11.3.2021
  // we should use the Aggreagatuon subject already in the first prototype
  // although at the moment we do not know how to create a unique identifier so
  // so it is build a subject of it's own in the EDM document (so to say RDF graph for the
  // document
  def apply (id: String): Aggregation = new Aggregation(s"${id}_??")

}

140

141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185

class Concept(val id: String) {
  private val model = Helper.getModelWithEDMNamespaces
  model.add(iri(id),RDF.TYPE, SKOS.CONCEPT)

  private val factory = SimpleValueFactory.getInstance()

  def addSkosPrefLabel(skospreflabel:Option[String]): Unit =
    skospreflabel.map(t => model.add(iri(id),SKOS.PREF_LABEL,factory.createLiteral(t)))

  def getModel: Model = model

}


class TimeSpan(val id: String) {

  //not used so far in Silvia mapping
  private val model = Helper.getModelWithEDMNamespaces
  model.add(iri(id),RDF.TYPE, EDMVocab.TIMESPAN)
  private val factory = SimpleValueFactory.getInstance()

  def addSkosPrefLabel(skospreflabel:Option[String]): Unit =
    skospreflabel.map(t => model.add(iri(id),SKOS.PREF_LABEL,factory.createLiteral(t)))

  def getModel: Model = model

}

class Place(val id: String) {

  //not used so far in Silvia mapping
  private val model = Helper.getModelWithEDMNamespaces
  model.add(iri(id),RDF.TYPE, EDMVocab.PLACE)
  private val factory = SimpleValueFactory.getInstance()

  def addSkosPrefLabel(skospreflabel:Option[String]): Unit =
    skospreflabel.map(t => model.add(iri(id),SKOS.PREF_LABEL,factory.createLiteral(t)))

  def getModel: Model = model

}