diff --git a/common/src/main/java/com/msd/gin/halyard/common/TableConfig.java b/common/src/main/java/com/msd/gin/halyard/common/TableConfig.java index b4f3e861e..a37ec9339 100644 --- a/common/src/main/java/com/msd/gin/halyard/common/TableConfig.java +++ b/common/src/main/java/com/msd/gin/halyard/common/TableConfig.java @@ -13,7 +13,8 @@ public final class TableConfig { static final int VERSION_4_6_2 = 462; static final int VERSION_4_7 = 470; static final int VERSION_4_9 = 490; - static final int CURRENT_VERSION = VERSION_4_9; + static final int VERSION_4_9_1 = 491; + static final int CURRENT_VERSION = VERSION_4_9_1; public static final String ID_HASH = "halyard.id.hash"; public static final String ID_JAVA_HASH = "halyard.id.javaHash"; diff --git a/common/src/main/java/com/msd/gin/halyard/vocab/IntegerPairNamespace.java b/common/src/main/java/com/msd/gin/halyard/vocab/IntegerPairNamespace.java new file mode 100644 index 000000000..bc49c78bd --- /dev/null +++ b/common/src/main/java/com/msd/gin/halyard/vocab/IntegerPairNamespace.java @@ -0,0 +1,48 @@ +package com.msd.gin.halyard.vocab; + +import com.msd.gin.halyard.common.AbstractIRIEncodingNamespace; +import com.msd.gin.halyard.common.ValueIO; + +import java.nio.ByteBuffer; + +public class IntegerPairNamespace extends AbstractIRIEncodingNamespace { + private static final long serialVersionUID = 571723932297421854L; + + private final String sep1; + private final String sep2; + + IntegerPairNamespace(String prefix, String ns, String sep1, String sep2) { + super(prefix, ns); + this.sep1 = sep1; + this.sep2 = sep2; + } + + @Override + public ByteBuffer writeBytes(String localName, ByteBuffer b) { + int start1 = sep1.length(); + int end1 = localName.indexOf(sep2, start1); + if (end1 == -1) { + throw new IllegalArgumentException("Unexpected input: "+localName); + } + int start2 = end1 + sep2.length(); + int start = b.position(); + b = ValueIO.ensureCapacity(b, 1); + b.position(start + 1); + b = ValueIO.writeCompressedInteger(localName.substring(start1, end1), b); + int len1 = b.position() - start - 1; + b = ValueIO.writeCompressedInteger(localName.substring(start2), b); + b.put(start, (byte)len1); + return b; + } + + @Override + public String readBytes(ByteBuffer b) { + int len1 = b.get(); + int originalLimit = b.limit(); + b.limit(b.position() + len1); + String first = ValueIO.readCompressedInteger(b); + b.limit(originalLimit); + String second = ValueIO.readCompressedInteger(b); + return sep1 + first + sep2 + second; + } +} diff --git a/common/src/main/java/com/msd/gin/halyard/vocab/SEMOPENALEX.java b/common/src/main/java/com/msd/gin/halyard/vocab/SEMOPENALEX.java index 585f2e033..c3e91c32b 100644 --- a/common/src/main/java/com/msd/gin/halyard/vocab/SEMOPENALEX.java +++ b/common/src/main/java/com/msd/gin/halyard/vocab/SEMOPENALEX.java @@ -14,10 +14,18 @@ public final class SEMOPENALEX implements Vocabulary { public static final String WORK_NAMESPACE = "https://semopenalex.org/work/"; public static final String AUTHOR_NAMESPACE = "https://semopenalex.org/author/"; public static final String INSTITUTION_NAMESPACE = "https://semopenalex.org/institution/"; + public static final String AUTHOR_POSITION_NAMESPACE = "https://semopenalex.org/authorposition/"; + public static final String CONCEPT_SCORE_NAMESPACE = "https://semopenalex.org/conceptscore/"; + public static final String COUNTS_BY_YEAR_NAMESPACE = "https://semopenalex.org/countsbyyear/"; + public static final String LOCATION_NAMESPACE = "https://semopenalex.org/location/"; public static final Namespace CLASS_NS = new SimpleNamespace("soa_class", CLASS_NAMESPACE); public static final Namespace PROPERTY_NS = new SimpleNamespace("soa_prop", PROPERTY_NAMESPACE); public static final Namespace CONCEPT_NS = new PrefixedIntegerNamespace("soa_concept", CONCEPT_NAMESPACE, "C"); public static final Namespace WORK_NS = new PrefixedIntegerNamespace("soa_work", WORK_NAMESPACE, "W"); public static final Namespace AUTHOR_NS = new PrefixedIntegerNamespace("soa_auth", AUTHOR_NAMESPACE, "A"); public static final Namespace INSTITUTION_NS = new PrefixedIntegerNamespace("soa_inst", INSTITUTION_NAMESPACE, "I"); + public static final Namespace AUTHOR_POSITION_NS = new IntegerPairNamespace("soa_ap", AUTHOR_POSITION_NAMESPACE, "W", "A"); + public static final Namespace CONCEPT_SCORE_NS = new IntegerPairNamespace("soa_cs", CONCEPT_SCORE_NAMESPACE, "W", "C"); + public static final Namespace COUNTS_BY_YEAR_NS = new PrefixedIntegerNamespace("soa_cby", COUNTS_BY_YEAR_NAMESPACE, "P"); + public static final Namespace LOCATION_NS = new PrefixedIntegerNamespace("soa_loc", LOCATION_NAMESPACE, "W"); } diff --git a/common/src/test/java/com/msd/gin/halyard/common/IdValueFactoryExtendedTest.java b/common/src/test/java/com/msd/gin/halyard/common/IdValueFactoryExtendedTest.java index 6f76cc024..41263260c 100644 --- a/common/src/test/java/com/msd/gin/halyard/common/IdValueFactoryExtendedTest.java +++ b/common/src/test/java/com/msd/gin/halyard/common/IdValueFactoryExtendedTest.java @@ -1,6 +1,7 @@ package com.msd.gin.halyard.common; import com.msd.gin.halyard.vocab.HALYARD; +import com.msd.gin.halyard.vocab.SEMOPENALEX; import com.msd.gin.halyard.vocab.WIKIDATA; import java.io.ByteArrayInputStream; @@ -80,6 +81,7 @@ private static List createData(ValueFactory vf) { vf.createIRI(WIKIDATA.WDV_NAMESPACE, "400f9abd3fd761c62af23dbe8f8432158a6ce272"), vf.createIRI(WIKIDATA.WDV_NAMESPACE, "invalid"), vf.createIRI(WIKIDATA.WDV_NAMESPACE+"400f9abd3fd761c62af23dbe8f8432158a6ce272/"), + vf.createIRI(SEMOPENALEX.AUTHOR_POSITION_NAMESPACE+"W10986400A2001695"), vf.createIRI("urn:uuid:8104c873-b648-44de-aaee-cb65f1dcafbb") ); } diff --git a/common/src/test/java/com/msd/gin/halyard/common/RDFFactoryTest.java b/common/src/test/java/com/msd/gin/halyard/common/RDFFactoryTest.java index 3309783b1..8af3dffc6 100644 --- a/common/src/test/java/com/msd/gin/halyard/common/RDFFactoryTest.java +++ b/common/src/test/java/com/msd/gin/halyard/common/RDFFactoryTest.java @@ -1,6 +1,7 @@ package com.msd.gin.halyard.common; import com.msd.gin.halyard.vocab.HALYARD; +import com.msd.gin.halyard.vocab.SEMOPENALEX; import com.msd.gin.halyard.vocab.WIKIDATA; import java.math.BigDecimal; @@ -89,6 +90,7 @@ static List createData(ValueFactory vf) { new Object[] {vf.createIRI(WIKIDATA.WDV_NAMESPACE, "400f9abd3fd761c62af23dbe8f8432158a6ce272"), ValueIO.ENCODED_IRI_TYPE}, new Object[] {vf.createIRI(WIKIDATA.WDV_NAMESPACE, "invalid"), ValueIO.NAMESPACE_HASH_TYPE}, new Object[] {vf.createIRI(WIKIDATA.WDV_NAMESPACE+"400f9abd3fd761c62af23dbe8f8432158a6ce272/"), ValueIO.END_SLASH_ENCODED_IRI_TYPE}, + new Object[] {vf.createIRI(SEMOPENALEX.AUTHOR_POSITION_NAMESPACE+"W10986400A2001695"), ValueIO.ENCODED_IRI_TYPE}, new Object[] {vf.createIRI("urn:uuid:8104c873-b648-44de-aaee-cb65f1dcafbb"), ValueIO.ENCODED_IRI_TYPE} ); }