Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// after this transformation we get {[key: string]: string} which is not perfect
const partialField =
_.mapValues(
predicates,
propertyPath =>
Rdf.getValueFromPropertyPath(propertyPath, pg)
.map(n => n.value)
.getOrElse(undefined)
);
const label = Rdf.getValuesFromPropertyPath([rdfs.label], pg).map(v => v as Rdf.Literal);
const domain = Rdf.getValuesFromPropertyPath([field.domain], pg).map(v => v.value);
const range = Rdf.getValuesFromPropertyPath([field.range], pg).map(v => v.value);
const defaultValues = Rdf.getValuesFromPropertyPath([field.default_value], pg).map(v => v.value);
const categories = Rdf.getValuesFromPropertyPath([field.category], pg);
const treePatterns = Rdf.getValueFromPropertyPath([field.tree_patterns], pg).chain(config => {
if (!(config.isLiteral() && config.datatype.equals(VocabPlatform.SyntheticJsonDatatype))) {
return Nothing();
}
try {
return Just(JSON.parse(config.value));
} catch (e) {
return Nothing();
}
}).getOrElse(undefined);
return {
id: fieldIri.value,
label,
...partialField,
categories,
domain,
function deserializeBeliefAdoption(pg: Rdf.PointedGraph): Kefir.Property {
const adoptedBeliefAssertion =
Rdf.getValueFromPropertyPath([rso.PX_adopted_assertion], pg);
if (adoptedBeliefAssertion.isJust) {
return Kefir.constant({
iri: Maybe.Just(pg.pointer),
argumentType: BeliefAdoptionType,
title: Rdf.getValueFromPropertyPath([rdfs.label], pg).map(v => v.value).getOrElse(''),
note: Rdf.getValueFromPropertyPath([crm.P3_has_note], pg).map(v => v.value).getOrElse(''),
belief: {
iri: adoptedBeliefAssertion,
beliefType: BeliefTypeArgumentsKind,
argumentBeliefType: ArgumentsBeliefTypeAssertionKind,
assertion: adoptedBeliefAssertion.get(),
belief: {
type: 'simple',
value: 'Agree',
}
function deserializeObservation(pg: Rdf.PointedGraph): Observation {
return {
iri: Maybe.Just(pg.pointer as Rdf.Iri),
argumentType: ObservationType,
title: Rdf.getValueFromPropertyPath([rdfs.label], pg).map(v => v.value).getOrElse(''),
note: Rdf.getValueFromPropertyPath([crm.P3_has_note], pg).map(v => v.value).getOrElse(''),
place: Rdf.getValueFromPropertyPath([crmsci.O21_has_found_at], pg).getOrElse(undefined),
date: Rdf.getValueFromPropertyPath(
[crm.P4_has_time_span, crm.P82a_begin_of_the_begin], pg
).getOrElse(undefined),
};
}
beliefIri => {
const beliefPg = Rdf.pg(beliefIri, graph);
return {
iri: Maybe.Just(beliefIri),
beliefType: AssertedBeliefTypeKind as typeof AssertedBeliefTypeKind,
target: target,
field: field,
targetValue: Rdf.getValueFromPropertyPath([rso.PX_asserts_value], beliefPg).getOrElse(undefined),
isCanonical: Rdf.getValueFromPropertyPath([rso.PX_is_canonical_value], beliefPg).map(v => v.value === 'true').getOrElse(false),
originRepository: 'default',
belief: {
type: 'simple' as 'simple',
value: Rdf.getValueFromPropertyPath([crminf.J5_holds_to_be], beliefPg).map(v => v.value).getOrElse(undefined) as any,
}
};
}
);
beliefType: BeliefTypeArgumentsKind,
argumentBeliefType: ArgumentsBeliefTypeAssertionKind,
assertion: assertion.get(),
belief: {
type: 'simple',
value: SimpleBeliefValue.Agree,
}
};
return Kefir.constant(assertionBelief);
} else {
const target =
Rdf.getValueFromPropertyPath([rso.PX_premise_target], pg).getOrElse(undefined);
const field =
Rdf.getValueFromPropertyPath([rso.PX_premise_field], pg).getOrElse(undefined);
const repository =
Rdf.getValueFromPropertyPath([rso.PX_premise_target_repository], pg)
.map(l => l.value).getOrElse(undefined);
return getArgumentsFieldDefinition(field).map(
fieldDefition => {
const fieldBelief: ArgumentsFieldBelief = {
iri: Maybe.Just(pg.pointer as Rdf.Iri),
beliefType: BeliefTypeArgumentsKind,
argumentBeliefType: ArgumentsBeliefTypeFieldKind,
target: target,
field: fieldDefition,
originRepository: repository,
belief: {
type: 'simple',
value: SimpleBeliefValue.Agree,
}
};
return fieldBelief;
function deserializeBelief(pg: Rdf.PointedGraph): Kefir.Property {
const assertion = Rdf.getValueFromPropertyPath([rso.PX_premise_assertion], pg);
if (assertion.isJust) {
const assertionBelief: ArgumentsAssertionBelief = {
iri: Maybe.Just(pg.pointer as Rdf.Iri),
beliefType: BeliefTypeArgumentsKind,
argumentBeliefType: ArgumentsBeliefTypeAssertionKind,
assertion: assertion.get(),
belief: {
type: 'simple',
value: SimpleBeliefValue.Agree,
}
};
return Kefir.constant(assertionBelief);
} else {
const target =
Rdf.getValueFromPropertyPath([rso.PX_premise_target], pg).getOrElse(undefined);
const field =
function deserializeAssertion(iri: Rdf.Iri, graph: Rdf.Graph): Kefir.Property {
const pg = Rdf.pg(iri, graph);
const target = Rdf.getValueFromPropertyPath([rso.targetsRecord], pg).getOrElse(undefined);
const fieldIri =
Rdf.getValueFromPropertyPath([rso.targetsField], pg).getOrElse(undefined);
return getArgumentsFieldDefinition(fieldIri).map(
field => {
const beliefRoots = Rdf.getValuesFromPropertyPath([rso.PX_asserts], pg);
const beliefs =
beliefRoots.map(
beliefIri => {
const beliefPg = Rdf.pg(beliefIri, graph);
return {
iri: Maybe.Just(beliefIri),
beliefType: AssertedBeliefTypeKind as typeof AssertedBeliefTypeKind,
target: target,
field: field,
targetValue: Rdf.getValueFromPropertyPath([rso.PX_asserts_value], beliefPg).getOrElse(undefined),
isCanonical: Rdf.getValueFromPropertyPath([rso.PX_is_canonical_value], beliefPg).map(v => v.value === 'true').getOrElse(false),
originRepository: 'default',
const assertion = Rdf.getValueFromPropertyPath([rso.PX_premise_assertion], pg);
if (assertion.isJust) {
const assertionBelief: ArgumentsAssertionBelief = {
iri: Maybe.Just(pg.pointer as Rdf.Iri),
beliefType: BeliefTypeArgumentsKind,
argumentBeliefType: ArgumentsBeliefTypeAssertionKind,
assertion: assertion.get(),
belief: {
type: 'simple',
value: SimpleBeliefValue.Agree,
}
};
return Kefir.constant(assertionBelief);
} else {
const target =
Rdf.getValueFromPropertyPath([rso.PX_premise_target], pg).getOrElse(undefined);
const field =
Rdf.getValueFromPropertyPath([rso.PX_premise_field], pg).getOrElse(undefined);
const repository =
Rdf.getValueFromPropertyPath([rso.PX_premise_target_repository], pg)
.map(l => l.value).getOrElse(undefined);
return getArgumentsFieldDefinition(field).map(
fieldDefition => {
const fieldBelief: ArgumentsFieldBelief = {
iri: Maybe.Just(pg.pointer as Rdf.Iri),
beliefType: BeliefTypeArgumentsKind,
argumentBeliefType: ArgumentsBeliefTypeFieldKind,
target: target,
field: fieldDefition,
originRepository: repository,
belief: {
type: 'simple',