Skip to content

Commit

Permalink
Merge pull request #80 in KSAM/ksamsok from feature/KSAM-233-lagg-til…
Browse files Browse the repository at this point in the history
…l-iteminscription-2 to master

* commit 'eed21603dfe7fb297f38ef7a7e7e7af05f438d00':
  KSAM-233 Stöd för ItemInscription
  • Loading branch information
stefanmalmesjo committed Aug 19, 2020
2 parents e35b318 + eed2160 commit df776f3
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import static se.raa.ksamsok.lucene.ContentHelper.IX_ITEMCLASSNAME;
import static se.raa.ksamsok.lucene.ContentHelper.IX_ITEMCOLOR;
import static se.raa.ksamsok.lucene.ContentHelper.IX_ITEMDESCRIPTION;
import static se.raa.ksamsok.lucene.ContentHelper.IX_ITEMINSCRIPTION;
import static se.raa.ksamsok.lucene.ContentHelper.IX_ITEMKEYWORD;
import static se.raa.ksamsok.lucene.ContentHelper.IX_ITEMLABEL;
import static se.raa.ksamsok.lucene.ContentHelper.IX_ITEMLICENSE;
Expand Down Expand Up @@ -127,6 +128,7 @@
import static se.raa.ksamsok.lucene.SamsokProtocol.uri_rItemClassName;
import static se.raa.ksamsok.lucene.SamsokProtocol.uri_rItemColor;
import static se.raa.ksamsok.lucene.SamsokProtocol.uri_rItemDescription;
import static se.raa.ksamsok.lucene.SamsokProtocol.uri_rItemInscription;
import static se.raa.ksamsok.lucene.SamsokProtocol.uri_rItemKeyWord;
import static se.raa.ksamsok.lucene.SamsokProtocol.uri_rItemLabel;
import static se.raa.ksamsok.lucene.SamsokProtocol.uri_rItemLicense;
Expand Down Expand Up @@ -176,6 +178,7 @@
import static se.raa.ksamsok.lucene.SamsokProtocol.uri_r__Form;
import static se.raa.ksamsok.lucene.SamsokProtocol.uri_r__Name;
import static se.raa.ksamsok.lucene.SamsokProtocol.uri_r__Spec;
import static se.raa.ksamsok.lucene.SamsokProtocol.uri_r__Text;

public abstract class BaseSamsokProtocolHandler implements SamsokProtocolHandler, RelationToIndexMapper {

Expand Down Expand Up @@ -429,6 +432,9 @@ protected void extractItemInformation() throws Exception {
// hämta ut itemMark, resursnod (0m)
ip.setCurrent(IX_ITEMMARK); // fritext
extractValue(model, subject, getURIRef(uri_rItemMark), getURIRef(uri_r__Form), ip);
// hämta ut itemInscription, resursnod (0m)
ip.setCurrent(IX_ITEMINSCRIPTION); // fritext
extractValue(model, subject, getURIRef(uri_rItemInscription), getURIRef(uri_r__Text), ip);
// hämta ut itemDescription, resursnod (0m)
ip.setCurrent(IX_ITEMDESCRIPTION); // fritext
extractValue(model, subject, getURIRef(uri_rItemDescription), getURIRef(uri_r__Desc), ip);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/se/raa/ksamsok/lucene/ContentHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public abstract class ContentHelper {
public static final String IX_ITEMTITLE = "itemTitle";
public static final String IX_ITEMLABEL = "itemLabel";
public static final String IX_ITEMMARK = "itemMark";
public static final String IX_ITEMINSCRIPTION = "itemInscription";
public static final String IX_ITEMDESCRIPTION = "itemDescription";
public static final String IX_ITEMKEYWORD = "itemKeyWord";
public static final String IX_ITEMMOTIVEWORD = "itemMotiveWord";
Expand Down Expand Up @@ -362,6 +363,7 @@ public abstract class ContentHelper {
addIndex(IX_ITEMLABEL, "Huvudsaklig beskrivning av objektet - klassifikation, sakord el dyl",
IndexType.TOLOWERCASE);
addIndex(IX_ITEMMARK, "Fritext i item mark", IndexType.ANALYZED, true, false);
addIndex(IX_ITEMINSCRIPTION, "Fritext i item inscription", IndexType.ANALYZED, true, false);
addIndex(IX_ITEMDESCRIPTION, "Fritext i beskrivningsfält", IndexType.ANALYZED, true, false);
addIndex(IX_ITEMKEYWORD, "Nyckelord", IndexType.TOLOWERCASE, true, false);
addIndex(IX_ITEMMOTIVEWORD, "Ord som förekommer som beskrivning av ett motiv i ett bild- eller målningsobjekt",
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/se/raa/ksamsok/lucene/SamsokProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ public class SamsokProtocol {
static final URI uri_rItemColor = URI.create(uriPrefixKSamsok + "itemColor");
static final URI uri_rItemNumber = URI.create(uriPrefixKSamsok + "itemNumber");
static final URI uri_rItemMark = URI.create(uriPrefixKSamsok + "itemMark");
static final URI uri_rItemInscription = URI.create(uriPrefixKSamsok + "itemInscription");
static final URI uri_rItemDescription = URI.create(uriPrefixKSamsok + "itemDescription");
static final URI uri_rItemLicense = URI.create(uriPrefixKSamsok + "itemLicense");
static final URI uri_rSubject = URI.create(uriPrefixKSamsok + "subject");
static final URI uri_rCollection = URI.create(uriPrefixKSamsok + "collection");
static final URI uri_rDataQuality = URI.create(uriPrefixKSamsok + "dataQuality");
static final URI uri_rMediaType = URI.create(uriPrefixKSamsok + "mediaType");
static final URI uri_r__Form = URI.create(uriPrefixKSamsok + "form");
static final URI uri_r__Text = URI.create(uriPrefixKSamsok + "text");
static final URI uri_r__Desc = URI.create(uriPrefixKSamsok + "desc");
static final URI uri_r__Name = URI.create(uriPrefixKSamsok + "name");
static final URI uri_r__Spec = URI.create(uriPrefixKSamsok + "spec");
Expand Down
21 changes: 20 additions & 1 deletion src/main/resources/ksamsok.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<xs:element ref="ksamsok:itemSpecification" maxOccurs="unbounded" />
<xs:element ref="ksamsok:itemTitle" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="ksamsok:itemMark" minOccurs="0" maxOccurs="unbounded" />
<xs:element ref="ksamsok:itemInscription" minOccurs="0" maxOccurs="unbounded" />
<xs:element ref="ksamsok:itemDescription" minOccurs="0" maxOccurs="unbounded" />
<xs:element ref="ksamsok:itemKeyWord" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="ksamsok:itemMotiveWord" minOccurs="0" maxOccurs="unbounded"/>
Expand Down Expand Up @@ -146,6 +147,11 @@
<xs:attribute ref="rdf:nodeID" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="itemInscription">
<xs:complexType>
<xs:attribute ref="rdf:nodeID" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="itemDescription">
<xs:complexType>
<xs:attribute ref="rdf:nodeID" use="required"/>
Expand Down Expand Up @@ -374,7 +380,20 @@
<xs:attribute ref="rdf:nodeID" use="required"/>
</xs:complexType>
</xs:element>

<xs:element name="ItemInscription">
<xs:complexType>
<xs:sequence>
<xs:element ref="ksamsok:type"/>
<xs:element ref="ksamsok:text"/>
</xs:sequence>
<xs:attribute ref="rdf:nodeID" use="required"/>
</xs:complexType>
</xs:element>

<xs:element name="form" type="xs:string"/>

<xs:element name="text" type="xs:string"/>

<xs:element name="ItemDescription">
<xs:complexType>
Expand Down Expand Up @@ -408,7 +427,7 @@
<xs:attribute ref="rdf:resource" use="optional"/>
</xs:complexType>
</xs:element>

<xs:element name="type" type="xs:string"/>

<!-- Används där man vill ha datum med YYYY-MM-DD -->
Expand Down
39 changes: 36 additions & 3 deletions src/main/webapp/schema/ksamsok.owl
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@
<rdfs:range rdf:resource="http://kulturarvsdata.se/ksamsok#ItemMark"/>
</owl:ObjectProperty>

<!-- http://kulturarvsdata.se/ksamsok#itemInscription -->

<owl:ObjectProperty rdf:about="http://kulturarvsdata.se/ksamsok#itemInscription">
<rdfs:comment></rdfs:comment>
<rdfs:domain rdf:resource="http://kulturarvsdata.se/ksamsok#Entity"/>
<rdfs:range rdf:resource="http://kulturarvsdata.se/ksamsok#ItemInscription"/>
</owl:ObjectProperty>

<!-- http://kulturarvsdata.se/ksamsok#itemDescription -->

<owl:ObjectProperty rdf:about="http://kulturarvsdata.se/ksamsok#itemDescription">
Expand Down Expand Up @@ -544,7 +552,6 @@
<rdfs:range rdf:resource="&xsd;anyURI"/>
</owl:DatatypeProperty>


<!-- http://kulturarvsdata.se/ksamsok#form -->

<owl:DatatypeProperty rdf:about="http://kulturarvsdata.se/ksamsok#form">
Expand All @@ -553,6 +560,13 @@
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>

<!-- http://kulturarvsdata.se/ksamsok#text -->

<owl:DatatypeProperty rdf:about="http://kulturarvsdata.se/ksamsok#text">
<rdfs:comment></rdfs:comment>
<rdfs:domain rdf:resource="http://kulturarvsdata.se/ksamsok#ItemInscription"/>
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>

<!-- http://kulturarvsdata.se/ksamsok#desc -->

Expand All @@ -562,8 +576,6 @@
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>



<!-- http://kulturarvsdata.se/ksamsok#description -->

<owl:DatatypeProperty rdf:about="http://kulturarvsdata.se/ksamsok#description">
Expand Down Expand Up @@ -1592,6 +1604,7 @@

<owl:DatatypeProperty rdf:about="http://kulturarvsdata.se/ksamsok#type">
<rdfs:domain rdf:resource="http://kulturarvsdata.se/ksamsok#ItemMark"/>
<rdfs:domain rdf:resource="http://kulturarvsdata.se/ksamsok#ItemInscription"/>
<rdfs:domain rdf:resource="http://kulturarvsdata.se/ksamsok#ItemDescription"/>
<rdfs:domain rdf:resource="http://kulturarvsdata.se/ksamsok#ItemMaterial"/>
<rdfs:domain rdf:resource="http://kulturarvsdata.se/ksamsok#ItemMeasurement"/>
Expand Down Expand Up @@ -2327,6 +2340,26 @@
<rdfs:comment></rdfs:comment>
</owl:Class>

<!-- http://kulturarvsdata.se/ksamsok#ItemInscription -->

<owl:Class rdf:about="http://kulturarvsdata.se/ksamsok#ItemInscription">
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="http://kulturarvsdata.se/ksamsok#text"/>
<owl:qualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:qualifiedCardinality>
<owl:onDataRange rdf:resource="&xsd;string"/>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="http://kulturarvsdata.se/ksamsok#type"/>
<owl:qualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:qualifiedCardinality>
<owl:onDataRange rdf:resource="&xsd;string"/>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:comment></rdfs:comment>
</owl:Class>

<!-- http://kulturarvsdata.se/ksamsok#ItemDescription -->

<owl:Class rdf:about="http://kulturarvsdata.se/ksamsok#ItemDescription">
Expand Down
30 changes: 29 additions & 1 deletion src/test/java/se/raa/ksamsok/lucene/Protocol_1_11_Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void testItemMark() throws Exception {
}
s = iter.next().getSubject();
}
SamsokProtocolHandler handler = new SamsokProtocolHandler_1_1(model, s);
SamsokProtocolHandler handler = new SamsokProtocolHandler_1_11(model, s);
HarvestService service = new HarvestServiceImpl();
service.setId("TESTID");
LinkedList<String> relations = new LinkedList<String>();
Expand All @@ -114,6 +114,34 @@ public void testItemMark() throws Exception {
assertEquals("Felaktig värde för itemMark", "Märke i hjälmen", doc.getFieldValue(ContentHelper.IX_ITEMMARK));
}

@Test
public void testItemInscription() throws Exception {
String rdf = loadTestFileAsString("hjalm_1.11.rdf");
Model model = RDFUtil.parseModel(rdf);
assertNotNull("Ingen graf, fel på rdf:en?", model);

Property rdfType = ResourceFactory.createProperty(SamsokProtocol.uri_rdfType.toString());
Resource samsokEntity = ResourceFactory.createResource(SamsokProtocol.uri_samsokEntity.toString());
SimpleSelector selector = new SimpleSelector (null, rdfType, samsokEntity);

Resource s = null;
StmtIterator iter = model.listStatements(selector);
while (iter.hasNext()){
if (s != null) {
throw new Exception("Ska bara finnas en entity i rdf-grafen");
}
s = iter.next().getSubject();
}
SamsokProtocolHandler handler = new SamsokProtocolHandler_1_11(model, s);
HarvestService service = new HarvestServiceImpl();
service.setId("TESTID");
LinkedList<String> relations = new LinkedList<>();
List<String> gmlGeometries = new LinkedList<>();
SolrInputDocument doc = handler.handle(service, new Date(), relations, gmlGeometries);
assertNotNull("Inget doc tillbaka", doc);
assertEquals("Felaktig värde för itemInscription", "Inristning", doc.getFieldValue(ContentHelper.IX_ITEMINSCRIPTION));
}



@Test
Expand Down
6 changes: 6 additions & 0 deletions src/test/resources/hjalm_1.11.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,18 @@
<ns5:type>Ett märke</ns5:type>
<rdf:type rdf:resource="http://kulturarvsdata.se/ksamsok#ItemMark"/>
</rdf:Description>
<rdf:Description rdf:nodeID="bNode_8">
<ns5:form>Inristning</ns5:form>
<ns5:type>En inristning</ns5:type>
<rdf:type rdf:resource="http://kulturarvsdata.se/ksamsok#ItemInscription"/>
</rdf:Description>
<rdf:Description rdf:about="http://kulturarvsdata.se/raa/test/1">
<ns5:context rdf:nodeID="bNode_2"/>
<ns5:context rdf:nodeID="bNode_3"/>
<ns5:media rdf:nodeID="bNode_4"/>
<ns5:image rdf:nodeID="bNode_5"/>
<ns5:itemMark rdf:nodeID="bNode_7"/>
<ns5:itemInscription rdf:nodeID="bNode_8"/>
<ns5:itemDescription rdf:nodeID="bNode_1"/>
<ns5:itemName rdf:nodeID="bNode_0"/>
</rdf:Description>
Expand Down

0 comments on commit df776f3

Please sign in to comment.