From eed21603dfe7fb297f38ef7a7e7e7af05f438d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Malmesj=C3=B6?= Date: Fri, 17 Jul 2020 16:00:48 +0200 Subject: [PATCH] =?UTF-8?q?KSAM-233=20St=C3=B6d=20f=C3=B6r=20ItemInscripti?= =?UTF-8?q?on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lucene/BaseSamsokProtocolHandler.java | 6 +++ .../se/raa/ksamsok/lucene/ContentHelper.java | 2 + .../se/raa/ksamsok/lucene/SamsokProtocol.java | 2 + src/main/resources/ksamsok.xsd | 21 +++++++++- src/main/webapp/schema/ksamsok.owl | 39 +++++++++++++++++-- .../ksamsok/lucene/Protocol_1_11_Test.java | 30 +++++++++++++- src/test/resources/hjalm_1.11.rdf | 6 +++ 7 files changed, 101 insertions(+), 5 deletions(-) diff --git a/src/main/java/se/raa/ksamsok/lucene/BaseSamsokProtocolHandler.java b/src/main/java/se/raa/ksamsok/lucene/BaseSamsokProtocolHandler.java index ad5ad77..3570c5c 100644 --- a/src/main/java/se/raa/ksamsok/lucene/BaseSamsokProtocolHandler.java +++ b/src/main/java/se/raa/ksamsok/lucene/BaseSamsokProtocolHandler.java @@ -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; @@ -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; @@ -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 { @@ -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); diff --git a/src/main/java/se/raa/ksamsok/lucene/ContentHelper.java b/src/main/java/se/raa/ksamsok/lucene/ContentHelper.java index 85ede42..e317ab4 100755 --- a/src/main/java/se/raa/ksamsok/lucene/ContentHelper.java +++ b/src/main/java/se/raa/ksamsok/lucene/ContentHelper.java @@ -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"; @@ -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", diff --git a/src/main/java/se/raa/ksamsok/lucene/SamsokProtocol.java b/src/main/java/se/raa/ksamsok/lucene/SamsokProtocol.java index 6034c8e..8484df3 100644 --- a/src/main/java/se/raa/ksamsok/lucene/SamsokProtocol.java +++ b/src/main/java/se/raa/ksamsok/lucene/SamsokProtocol.java @@ -40,6 +40,7 @@ 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"); @@ -47,6 +48,7 @@ public class SamsokProtocol { 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"); diff --git a/src/main/resources/ksamsok.xsd b/src/main/resources/ksamsok.xsd index d2fc072..4a07659 100644 --- a/src/main/resources/ksamsok.xsd +++ b/src/main/resources/ksamsok.xsd @@ -48,6 +48,7 @@ + @@ -146,6 +147,11 @@ + + + + + @@ -374,7 +380,20 @@ + + + + + + + + + + + + + @@ -408,7 +427,7 @@ - + diff --git a/src/main/webapp/schema/ksamsok.owl b/src/main/webapp/schema/ksamsok.owl index 0695362..9aea961 100644 --- a/src/main/webapp/schema/ksamsok.owl +++ b/src/main/webapp/schema/ksamsok.owl @@ -120,6 +120,14 @@ + + + + + + + + @@ -544,7 +552,6 @@ - @@ -553,6 +560,13 @@ + + + + + + + @@ -562,8 +576,6 @@ - - @@ -1592,6 +1604,7 @@ + @@ -2327,6 +2340,26 @@ + + + + + + + 1 + + + + + + + 1 + + + + + + diff --git a/src/test/java/se/raa/ksamsok/lucene/Protocol_1_11_Test.java b/src/test/java/se/raa/ksamsok/lucene/Protocol_1_11_Test.java index 9732415..e188f23 100644 --- a/src/test/java/se/raa/ksamsok/lucene/Protocol_1_11_Test.java +++ b/src/test/java/se/raa/ksamsok/lucene/Protocol_1_11_Test.java @@ -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 relations = new LinkedList(); @@ -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 relations = new LinkedList<>(); + List 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 diff --git a/src/test/resources/hjalm_1.11.rdf b/src/test/resources/hjalm_1.11.rdf index ab81b17..9f54005 100644 --- a/src/test/resources/hjalm_1.11.rdf +++ b/src/test/resources/hjalm_1.11.rdf @@ -66,12 +66,18 @@ Ett märke + + Inristning + En inristning + + +