Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated first pattern #23

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import dev.ikm.tinkar.composer.Composer;
import dev.ikm.tinkar.composer.Session;
import dev.ikm.tinkar.composer.assembler.ConceptAssembler;
import dev.ikm.tinkar.composer.assembler.PatternAssembler;
import dev.ikm.tinkar.composer.template.FullyQualifiedName;
import dev.ikm.tinkar.composer.template.Identifier;
import dev.ikm.tinkar.composer.template.StatedAxiom;
Expand Down Expand Up @@ -48,6 +49,7 @@ public class Sept2024ConnectathonStarterData {
private final UUIDUtility uuidUtility = new UUIDUtility();

private final Composer composer = new Composer("Sept 2024 Connectathon Starter Data");
private final Session session;

public Sept2024ConnectathonStarterData(File exportDataStore, File exportFile) {
this.exportFile = exportFile;
Expand All @@ -61,21 +63,19 @@ public Sept2024ConnectathonStarterData(File exportDataStore, File exportFile) {
TinkarTerm.PRIMORDIAL_MODULE,
TinkarTerm.PRIMORDIAL_PATH);

session = composer.open(State.ACTIVE, TinkarTerm.USER, TinkarTerm.PRIMORDIAL_MODULE, TinkarTerm.PRIMORDIAL_PATH);

createComposerConcepts();
configureConceptsAndPatterns();

composer.commitSession(session);

starterData.build();
exportStarterData();

starterData.shutdown();
}

private void createComposerConcepts() {
Session session = composer.open(State.ACTIVE,
System.currentTimeMillis(),
TinkarTerm.USER,
TinkarTerm.PRIMORDIAL_MODULE,
TinkarTerm.PRIMORDIAL_PATH);

Concept performance = Concept.make("Performance", UUID.fromString("395cc864-7c51-4072-b3e7-f9195b40053a"));
session.compose((ConceptAssembler conceptAssembler) -> conceptAssembler
.concept(performance)
Expand All @@ -95,7 +95,7 @@ private void createComposerConcepts() {
.attach((StatedAxiom axiom) -> axiom
.isA(TinkarTerm.MODEL_CONCEPT))
);
composer.commitSession(session);

}

private void configureConceptsAndPatterns() {
Expand Down Expand Up @@ -154,15 +154,35 @@ private void configureConnectathonPatterns() {

private void createInvalidCovidTestResultPattern() {
Concept invalid = Concept.make("Invalid", UuidUtil.fromSNOMED("455371000124106"));
starterData.concept(invalid)
.synonym("Invalid", TinkarTerm.PREFERRED)
.identifier(TinkarTerm.UNIVERSALLY_UNIQUE_IDENTIFIER, invalid.asUuidArray()[0].toString())
.build();

starterData.pattern(EntityProxy.Pattern.make("Invalid Covid Test Result Pattern", uuidUtility.createUUID("Invalid Covid Test Result Pattern")))
session.compose((ConceptAssembler conceptAssembler) -> conceptAssembler
.concept(invalid)
.attach((FullyQualifiedName fqn) -> fqn
.language(ENGLISH_LANGUAGE)
.text("Invalid")
.caseSignificance(DESCRIPTION_NOT_CASE_SENSITIVE)
.attach((USDialect usDialect) -> usDialect.acceptability(TinkarTerm.PREFERRED)))
.attach((Synonym synonym) -> synonym
.text("Invalid")
.language(ENGLISH_LANGUAGE)
.caseSignificance(DESCRIPTION_NOT_CASE_SENSITIVE)
.attach((USDialect usDialect) -> usDialect.acceptability(TinkarTerm.PREFERRED)))
.attach((Identifier identifier) -> identifier
.source(TinkarTerm.UNIVERSALLY_UNIQUE_IDENTIFIER)
.identifier(invalid.asUuidArray()[0].toString()))
);

session.compose((PatternAssembler patternAssembler) -> patternAssembler
.pattern(EntityProxy.Pattern.make("Invalid Covid Test Result Pattern", uuidUtility.createUUID("Invalid Covid Test Result Pattern")))
.meaning(invalid)
.purpose(TinkarTerm.MEMBERSHIP_SEMANTIC)
.build();
.attach((Synonym synonym) -> synonym
.text("Invalid Covid Test Result Pattern")
.language(ENGLISH_LANGUAGE)
.caseSignificance(DESCRIPTION_NOT_CASE_SENSITIVE)
.attach((USDialect usDialect) -> usDialect.acceptability(TinkarTerm.PREFERRED)))
);

}

private void createUndeterminedCovidTestResultPattern() {
Expand Down
25 changes: 15 additions & 10 deletions src/main/java/dev/ikm/tinkar/starterdata/ConceptUtility.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package dev.ikm.tinkar.starterdata;

import dev.ikm.tinkar.entity.*;
import dev.ikm.tinkar.entity.ConceptRecord;
import dev.ikm.tinkar.entity.ConceptRecordBuilder;
import dev.ikm.tinkar.entity.ConceptVersionRecord;
import dev.ikm.tinkar.entity.ConceptVersionRecordBuilder;
import dev.ikm.tinkar.entity.Entity;
import dev.ikm.tinkar.entity.EntityVersion;
import dev.ikm.tinkar.entity.RecordListBuilder;
import dev.ikm.tinkar.terms.EntityProxy;
import dev.ikm.tinkar.terms.TinkarTerm;

import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.UUID;

class ConceptUtility {

private static final Logger LOG = LoggerFactory.getLogger(ConceptUtility.class.getSimpleName());
Expand All @@ -19,19 +24,19 @@ public ConceptUtility(UUIDUtility uuidUtility) {
}

protected Entity<? extends EntityVersion> createConcept(EntityProxy.Concept concept,
Entity<? extends EntityVersion> stampEntity){
Entity<? extends EntityVersion> stampEntity) {
UUID uuid = concept.asUuidArray()[0];

long[] additionalUuidLongsArr = null;
if (concept.asUuidArray().length > 1) {
additionalUuidLongsArr = new long[(concept.asUuidArray().length-1)*2];
for (int i=1; i < concept.asUuidArray().length; i++) {
additionalUuidLongsArr[(i*2)-2] = concept.asUuidArray()[i].getMostSignificantBits();
additionalUuidLongsArr[(i*2)-1] = concept.asUuidArray()[i].getLeastSignificantBits();
additionalUuidLongsArr = new long[(concept.asUuidArray().length - 1) * 2];
for (int i = 1; i < concept.asUuidArray().length; i++) {
additionalUuidLongsArr[(i * 2) - 2] = concept.asUuidArray()[i].getMostSignificantBits();
additionalUuidLongsArr[(i * 2) - 1] = concept.asUuidArray()[i].getLeastSignificantBits();
}
}

LOG.info("Building Concept");
LOG.debug("Building Concept");
RecordListBuilder<ConceptVersionRecord> versions = RecordListBuilder.make();
ConceptRecord conceptRecord = ConceptRecordBuilder.builder()
.nid(concept.nid())
Expand Down
22 changes: 14 additions & 8 deletions src/main/java/dev/ikm/tinkar/starterdata/PatternUtility.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package dev.ikm.tinkar.starterdata;

import dev.ikm.tinkar.entity.*;
import dev.ikm.tinkar.entity.Entity;
import dev.ikm.tinkar.entity.EntityVersion;
import dev.ikm.tinkar.entity.FieldDefinitionRecord;
import dev.ikm.tinkar.entity.PatternRecord;
import dev.ikm.tinkar.entity.PatternRecordBuilder;
import dev.ikm.tinkar.entity.PatternVersionRecord;
import dev.ikm.tinkar.entity.PatternVersionRecordBuilder;
import dev.ikm.tinkar.entity.RecordListBuilder;
import dev.ikm.tinkar.terms.EntityProxy;
import org.eclipse.collections.api.list.ImmutableList;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -18,11 +24,11 @@ public PatternUtility(UUIDUtility uuidUtility) {
}

protected Entity<? extends EntityVersion> createPattern(EntityProxy.Pattern pattern,
EntityProxy.Concept meaningConcept,
EntityProxy.Concept purposeConcept,
Entity<? extends EntityVersion> authoringSTAMP,
ImmutableList<FieldDefinitionRecord> fieldDefinitions){
LOG.info("Building " + pattern.description() + " Chronology");
EntityProxy.Concept meaningConcept,
EntityProxy.Concept purposeConcept,
Entity<? extends EntityVersion> authoringSTAMP,
ImmutableList<FieldDefinitionRecord> fieldDefinitions) {
LOG.debug("Building " + pattern.description() + " Chronology");

RecordListBuilder<PatternVersionRecord> versions = RecordListBuilder.make();
PatternRecord patternRecord = PatternRecordBuilder.builder()
Expand All @@ -33,7 +39,7 @@ protected Entity<? extends EntityVersion> createPattern(EntityProxy.Pattern patt
.versions(versions.toImmutable())
.build();

LOG.info("Building " + pattern.description() + " Version");
LOG.debug("Building " + pattern.description() + " Version");
versions.add(PatternVersionRecordBuilder.builder()
.chronology(patternRecord)
.stampNid(authoringSTAMP.nid())
Expand Down
Loading
Loading