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

feat: provenance to model to doc #1921

Merged
merged 25 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 21 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 @@ -84,7 +84,6 @@
<tera-related-documents
:asset-type="ResourceType.DATASET"
:documents="documents"
:related-documents="relatedDocuments"
:assetId="assetId"
@enriched="fetchDataset"
/>
Expand Down Expand Up @@ -336,7 +335,6 @@ const documents = computed(
id: document.id
})) ?? []
);
const relatedDocuments = computed(() => []);

const emit = defineEmits(['close-preview', 'asset-loaded']);
const newCsvContent: any = ref(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
<template #header>Related publications</template>
<tera-related-documents
:documents="documents"
:related-documents="relatedDocuments"
:asset-type="ResourceType.MODEL"
:assetId="model.id"
@enriched="fetchAsset"
Expand Down Expand Up @@ -545,7 +544,6 @@ const documents = computed(
id: document.id
})) ?? []
);
const relatedDocuments = computed(() => []);
const time = computed(() =>
props.model?.semantics?.ode?.time ? [props.model?.semantics.ode.time] : []
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,20 @@

<script setup lang="ts">
import { isEmpty } from 'lodash';
import { ref, onMounted, computed } from 'vue';
import { ref, computed } from 'vue';
import TeraModelDiagram from '@/components/model/petrinet/model-diagrams/tera-model-diagram.vue';
import TeraModelEquation from '@/components/model/petrinet/tera-model-equation.vue';
import TeraModelObservable from '@/components/model/petrinet/tera-model-observable.vue';
import TeraModelConfigurations from '@/components/model/petrinet/tera-model-configurations.vue';
import { FeatureConfig, ResultType } from '@/types/common';
import { Document, Dataset, Model, ProvenanceType, ModelConfiguration } from '@/types/Types';
import { Document, Dataset, Model, ModelConfiguration } from '@/types/Types';
import Accordion from 'primevue/accordion';
import AccordionTab from 'primevue/accordiontab';
import Column from 'primevue/column';
import DataTable from 'primevue/datatable';
import { getRelatedArtifacts } from '@/services/provenance';
import { isModel, isDataset, isDocument } from '@/utils/data-util';

const props = defineProps<{
defineProps<{
model: Model;
modelConfigurations: ModelConfiguration[];
featureConfig: FeatureConfig;
Expand Down Expand Up @@ -99,11 +98,4 @@ function updateConfiguration(updatedConfiguration: ModelConfiguration, index: nu
function addConfiguration(configuration: ModelConfiguration) {
emit('add-configuration', configuration);
}

onMounted(async () => {
relatedTerariumArtifacts.value = await getRelatedArtifacts(
props.model.id,
ProvenanceType.ModelRevision
);
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
</p>
<ul>
<li v-for="document in relatedDocuments" :key="document.id">
{{ document.name }}
<a @click="openAsset({ assetId: document.id!, pageType: AssetType.Documents })">{{
document.name
YohannParis marked this conversation as resolved.
Show resolved Hide resolved
}}</a>
</li>
</ul>
<Button
Expand Down Expand Up @@ -77,12 +79,12 @@
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { onMounted, ref, watch } from 'vue';
import Button from 'primevue/button';
import Dialog from 'primevue/dialog';
import DataTable from 'primevue/datatable';
import Column from 'primevue/column';
import { ResourceType } from '@/types/common';
import { AssetRoute, ResourceType } from '@/types/common';
import {
profileDataset,
profileModel,
Expand All @@ -92,10 +94,14 @@ import {
} from '@/services/knowledge';
import { PollerResult } from '@/api/api';
import { isEmpty } from 'lodash';
import { AssetType, DocumentAsset, ProvenanceType } from '@/types/Types';
import router from '@/router';
import { RouteName } from '@/router/routes';
import { getRelatedArtifacts } from '@/services/provenance';
import { isDocumentAsset } from '@/utils/data-util';

const props = defineProps<{
documents?: Array<{ name: string | undefined; id: string | undefined }>;
relatedDocuments?: Array<{ name: string; id: string | undefined }>;
assetType: ResourceType;
assetId: string;
}>();
Expand All @@ -106,6 +112,7 @@ const selectedResources = ref();
const dialogType = ref<'enrich' | 'align'>('enrich');
const aligning = ref(false);
const enriching = ref(false);
const relatedDocuments = ref<Array<{ name: string | undefined; id: string | undefined }>>([]);

const sendForEnrichments = async (/* _selectedResources */) => {
const jobIds: (string | null)[] = [];
Expand Down Expand Up @@ -136,6 +143,7 @@ const sendForEnrichments = async (/* _selectedResources */) => {

enriching.value = false;
emit('enriched');
getRelatedDocuments();
};

const sendToAlignModel = async () => {
Expand All @@ -153,8 +161,52 @@ const sendToAlignModel = async () => {

aligning.value = false;
emit('enriched');
getRelatedDocuments();
}
};

const openAsset = (assetRoute: AssetRoute) => {
router.push({
name: RouteName.Project,
params: assetRoute
});
};

onMounted(() => {
getRelatedDocuments();
});

watch(
() => props.assetId,
() => {
getRelatedDocuments();
}
);

async function getRelatedDocuments() {
if (!props.assetType) return;
let provenanceType;
if (props.assetType === ResourceType.MODEL) {
provenanceType = ProvenanceType.Model;
}
if (props.assetType === ResourceType.DATASET) {
provenanceType = ProvenanceType.Dataset;
}
YohannParis marked this conversation as resolved.
Show resolved Hide resolved

if (!provenanceType) return;

const provenanceNodes = await getRelatedArtifacts(props.assetId, provenanceType, [
ProvenanceType.Publication
]);

relatedDocuments.value =
(provenanceNodes.filter((res) => isDocumentAsset(res)) as DocumentAsset[]).map(
blanchco marked this conversation as resolved.
Show resolved Hide resolved
(documentAsset) => ({
name: documentAsset.name,
id: documentAsset.id
})
) ?? [];
}
</script>

<style scoped>
Expand Down
4 changes: 2 additions & 2 deletions packages/client/hmi-client/src/services/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ const getDocumentById = async (docid: string): Promise<Document | null> => {
return null;
};

const getBulkDocuments = async (docIDs: string[]) => {
const getBulkXDDDocuments = async (docIDs: string[]) => {
const result: Document[] = [];
const promiseList = [] as Promise<Document | null>[];
docIDs.forEach((docId) => {
Expand Down Expand Up @@ -684,7 +684,7 @@ export {
searchXDDDocuments,
getAssets,
getDocumentById,
getBulkDocuments,
getBulkXDDDocuments,
getRelatedDocuments,
getRelatedTerms,
getAutocomplete
Expand Down
16 changes: 16 additions & 0 deletions packages/client/hmi-client/src/services/document-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,21 @@ async function getDocumentFileAsText(documentId: string, fileName: string): Prom
return response.data;
}

async function getBulkDocumentAssets(docIDs: string[]) {
const result: DocumentAsset[] = [];
const promiseList = [] as Promise<DocumentAsset | null>[];
docIDs.forEach((docId) => {
promiseList.push(getDocumentAsset(docId));
});
const responsesRaw = await Promise.all(promiseList);
responsesRaw.forEach((r) => {
if (r) {
result.push(r);
}
});
return result;
}

async function createDocumentFromXDD(
document: Document,
projectId: string
Expand All @@ -195,6 +210,7 @@ export {
downloadDocumentAsset,
createNewDocumentFromGithubFile,
getDocumentFileAsText,
getBulkDocumentAssets,
createDocumentFromXDD,
createNewDocumentAsset
};
4 changes: 2 additions & 2 deletions packages/client/hmi-client/src/services/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function getDocument(docId: string): Promise<ExternalPublication | null> {
* @docId string array - represents a list of specific project asset/doc id
* @return ExternalPublication[]|null - the specific document info including its xdd url, or null if none returned by API
*/
async function getBulkDocumentAssets(docIDs: string[]) {
async function getBulkExternalPublications(docIDs: string[]) {
const result: ExternalPublication[] = [];
const promiseList = [] as Promise<ExternalPublication | null>[];
docIDs.forEach((docId) => {
Expand All @@ -46,4 +46,4 @@ async function addDocuments(body: ExternalPublication): Promise<{ id: string } |
return response?.data ?? null;
}

export { getDocument, getBulkDocumentAssets, addDocuments };
export { getDocument, getBulkExternalPublications, addDocuments };
Loading