Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return ImageApi.queryImageBounds(serviceUrl, imageInfo.imageId).flatMap(bounds =>
// we've got image size, we can create manifest
// but instead we are starting to fetch for regions
LdpRegionService.search(imageInfo.imageIRI).flatMap(annotations =>
// and lastly we're creating manifest and putting it all together
createManifest([{
baseIri: imageInfo.iri,
imageIri: imageInfo.imageIRI,
imageServiceUri: serviceRequestUri,
canvasSize: bounds,
}]).map(manifest => ({manifest, imageInfo, annotations}))
)
);
}));
return Kefir.zip(metadataTasks);
}
const delta: Delta = (action$, state$) =>
Kefir.zip([action$, state$]).flatMap(respond);
private onSubmit = () => {
this.setState({status: Status.Updating});
const workflowsUpdating = this.props.iris.map(iri => {
const {workflowState} = this.state;
const originalGraph = this.originalWorkflowGraphs.get(iri);
return this.workflowService.updateWorkflowInstantiation({
workflowIri: Rdf.iri(iri),
originalGraph,
workflowState,
});
});
this.cancellation.map(
Kefir.zip(workflowsUpdating)
).observe({
value: () => {
this.setState({status: Status.Ready});
addNotification({
level: 'success',
message: 'The workflow instantiations has been updated.',
});
this.fetchWorkflowInstantiations(this.props);
},
error: error => {
console.error(error);
this.setState({status: Status.Ready});
addNotification({
level: 'error',
message: 'Error occurred while updating the workflow instantiations.',
});
const querying = iris.map(iri => {
const sparql = SparqlClient.setBindings(parsedQuery, {[BINDING_VARIABLE]: Rdf.iri(iri)});
const requests = repositories.map(repository =>
SparqlClient.select(sparql, {context: {repository}}).map(
({results}) => ({iri, images: results.bindings.map(({image}) => image.value)})
)
);
return Kefir.zip(requests);
});
this.queryingCancellation = this.cancellation.deriveAndCancel(this.queryingCancellation);
const imageInfo = this.state.info.get(imageIri);
const iiifImageId = this.state.iiifImageId.get(imageIri);
if (!imageInfo || !iiifImageId) { return Kefir.constant(undefined); }
const imageServiceUri = ImageApi.constructServiceRequestUri(iiifServerUrl, iiifImageId);
return ImageApi.queryImageBounds(iiifServerUrl, iiifImageId).flatMap(canvasSize =>
Kefir.constant({
baseIri: imageInfo.isRegion ? imageInfo.imageIRI : Rdf.iri(iri),
imageIri: imageInfo.imageIRI,
imageServiceUri,
canvasSize,
})
).flatMapErrors(() =>
Kefir.constant(undefined)
);
});
return Kefir.zip(queryingImagesInfo).toProperty();
}
function zipImmutableMap(
map: Immutable.Map>
): Kefir.Property> {
const mapAsArray = map.map((kefirValue, key) => {
return kefirValue.map(value => ({key, value}));
}).toArray();
if (mapAsArray.length > 0) {
return Kefir.zip(mapAsArray).map(values =>
Immutable.Map().withMutations(newMap => {
for (const {key, value} of values) {
newMap.set(key, value);
}
})
).toProperty();
} else {
return Kefir.constant(Immutable.Map());
}
}
function lookForDefaultValues(
def: FieldDefinition, mapping: InputMapping
): Kefir.Property {
const {defaultValue, defaultValues} = mapping.element.props;
if (defaultValue || defaultValues) {
const values = defaultValue ? [defaultValue] : defaultValues;
const fieldValues = values.map(value => parseDefaultValue(value, def));
if (fieldValues.length > 0) {
return Kefir.zip(fieldValues).toProperty();
}
} else if (def.defaultValues.length > 0) {
const fieldValues = def.defaultValues.map(value => parseDefaultValue(value, def));
return Kefir.zip(fieldValues).toProperty();
}
return Kefir.constant([]);
}
?canvasURI exif:width ?canvasWidth;
exif:height ?canvasHeight.
} WHERE {
BIND(STR(${baseIri}) as ?baseStr)
BIND(URI(CONCAT(?baseStr, "/manifest.json")) as ?manifestURI)
BIND(URI(CONCAT(?baseStr, "/sequence")) as ?sequenceURI)
BIND(STR(?imageIri) as ?imageStr)
BIND(URI(CONCAT(?imageStr, "")) as ?canvasURI)
BIND(URI(CONCAT(?imageStr, "/imageanno/anno-1")) as ?imageannoURI)
BIND(URI(CONCAT(?imageStr, "/imgresource")) as ?imageResourceURI)
}`;
const iris = params.map(({imageIri}) => imageIri);
const queryingDisplayLabel = getLabel(baseIri);
const queryingImagesLabels = getLabels(iris);
return Kefir.zip([queryingDisplayLabel, queryingImagesLabels]).flatMap(
([displayLabel, labels]) => {
const parameters = params.map(param => ({
displayLabel: Rdf.literal(displayLabel),
imageIri: param.imageIri,
service: Rdf.iri(param.imageServiceUri),
canvasWidth: Rdf.literal(param.canvasSize.width.toString(), xsd.integer),
canvasHeight: Rdf.literal(param.canvasSize.height.toString(), xsd.integer),
label: Rdf.literal(labels.get(param.imageIri)),
}));
return SparqlClient.prepareQuery(sparql, parameters);
}
).map(query =>
SparqlUtil.serializeQuery(query)
).toProperty();
}
loadState(props: Props) {
const tasks = props.selection
.map(iri => typeof iri === 'string' ? Rdf.iri(iri) : iri)
.map(iri => queryIIIFImageOrRegion(iri, props.imageIdPattern, props.repositories));
return Kefir.zip(tasks).map(metadata => ({
metadata: Immutable.List(metadata),
}));
}