@finos/legend-application-studio
Version:
Legend Studio application core
216 lines • 8.61 kB
JavaScript
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DataProductLink, observe_AccessPoint, observe_Email, observe_SupportInfo, observer_DataProductLink, SupportInfo, observe_APG, observe_Expertise, observe_OperationalMetadata, DataProductOperationalMetadata, } from '@finos/legend-graph';
import { addUniqueEntry, deleteEntry, swapEntry } from '@finos/legend-shared';
import { action } from 'mobx';
export const dataProduct_deleteAccessPoint = action((group, accessPoint) => {
deleteEntry(group.accessPoints, accessPoint);
});
export const dataProduct_addAccessPoint = action((group, accessPoint) => {
addUniqueEntry(group.accessPoints, observe_AccessPoint(accessPoint));
});
export const accessPoint_setClassification = action((accessPoint, classification) => {
accessPoint.classification = classification;
});
export const accessPoint_setReproducible = action((accessPoint, reproducible) => {
accessPoint.reproducible = reproducible;
});
export const accessPoint_setDescription = action((accessPoint, description) => {
accessPoint.description = description;
});
export const accessPoint_setTitle = action((accessPoint, title) => {
accessPoint.title = title;
});
export const accessPointGroup_setDescription = action((group, description) => {
group.description = description;
});
export const accessPointGroup_setName = action((group, name) => {
group.id = name;
});
export const accessPointGroup_setTitle = action((group, title) => {
group.title = title;
});
export const modelAccessPointGroup_setMapping = action((group, mapping) => {
group.mapping = mapping;
});
export const modelAccessPointGroup_addElement = action((group, element) => {
addUniqueEntry(group.featuredElements, element);
});
export const modelAccessPointGroup_removeElement = action((group, element) => {
deleteEntry(group.featuredElements, element);
});
export const modelAccessPointGroup_setElementExclude = action((element, exclude) => {
element.exclude = exclude;
});
export const modelAccessPointGroup_addDiagram = action((group, diagram) => {
addUniqueEntry(group.diagrams, diagram);
});
export const modelAccessPointGroup_removeDiagram = action((group, diagram) => {
deleteEntry(group.diagrams, diagram);
});
export const dataProductDiagram_setTitle = action((diagram, title) => {
diagram.title = title;
});
export const dataProductDiagram_setDescription = action((diagram, desc) => {
diagram.description = desc;
});
export const runtimeInfo_setId = action((runtimeInfo, id) => {
runtimeInfo.id = id;
});
export const runtimeInfo_setDescription = action((runtimeInfo, desc) => {
runtimeInfo.description = desc;
});
export const accessPointGroup_swapAccessPoints = action((group, sourceAp, targetAp) => {
swapEntry(group.accessPoints, sourceAp, targetAp);
});
export const dataProduct_addAccessPointGroup = action((product, accessPointGroup) => {
const observedApg = observe_APG(accessPointGroup);
addUniqueEntry(product.accessPointGroups, observedApg);
});
export const dataProduct_deleteAccessPointGroup = action((product, accessPointGroup) => {
deleteEntry(product.accessPointGroups, accessPointGroup);
});
export const supportInfo_addExpertise = action((supportInfo, expertise) => {
const observedExpertise = observe_Expertise(expertise);
if (!supportInfo.expertise) {
supportInfo.expertise = [observedExpertise];
}
else {
addUniqueEntry(supportInfo.expertise, observedExpertise);
}
});
export const supportInfo_deleteExpertise = action((supportInfo, expertise) => {
if (supportInfo.expertise) {
deleteEntry(supportInfo.expertise, expertise);
}
});
export const dataProduct_deleteRelationElement = action((product, relationData, accessPointId) => {
const elementToDelete = relationData.relationElements.find((re) => re.paths[0] === accessPointId);
if (elementToDelete) {
deleteEntry(relationData.relationElements, elementToDelete);
if (relationData.relationElements.length === 0) {
product.sampleValues = undefined;
}
}
});
export const expertise_setDescription = action((expertise, desc) => {
expertise.description = desc;
});
export const expertise_addId = action((expertise, id) => {
if (expertise.expertIds) {
addUniqueEntry(expertise.expertIds, id);
}
else {
expertise.expertIds = [id];
}
});
export const expertise_deleteId = action((expertise, id) => {
if (expertise.expertIds) {
deleteEntry(expertise.expertIds, id);
}
});
export const dataProduct_swapAccessPointGroups = action((product, sourceGroup, targetGroup) => {
swapEntry(product.accessPointGroups, sourceGroup, targetGroup);
});
export const dataProduct_setTitle = action((product, title) => {
product.title = title;
});
export const dataProduct_setDescription = action((product, description) => {
product.description = description;
});
export const dataProduct_setType = action((product, type) => {
product.type = type;
});
export const externalType_setLinkURL = action((external, url) => {
external.link.url = url;
});
export const externalType_setLinkLabel = action((external, label) => {
external.link.label = label;
});
export const dataProduct_setIcon = action((product, icon) => {
product.icon = icon;
});
export const dataProduct_setSupportInfoIfAbsent = action((product) => {
if (!product.supportInfo) {
product.supportInfo = observe_SupportInfo(new SupportInfo());
}
});
export const supportInfo_setLinkLabel = action((link, label) => {
link.label = label;
});
export const supportInfo_setDocumentationUrl = action((supportInfo, documentationUrl) => {
if (!supportInfo.documentation) {
supportInfo.documentation = observer_DataProductLink(new DataProductLink(documentationUrl));
}
else {
supportInfo.documentation.url = documentationUrl;
}
});
export const supportInfo_setWebsite = action((supportInfo, website) => {
if (!supportInfo.website) {
supportInfo.website = observer_DataProductLink(new DataProductLink(website));
}
else {
supportInfo.website.url = website;
}
});
export const supportInfo_setFaqUrl = action((supportInfo, faqUrl) => {
if (!supportInfo.faqUrl) {
supportInfo.faqUrl = observer_DataProductLink(new DataProductLink(faqUrl));
}
else {
supportInfo.faqUrl.url = faqUrl;
}
});
export const supportInfo_setSupportUrl = action((supportInfo, supportUrl) => {
if (!supportInfo.supportUrl) {
supportInfo.supportUrl = observer_DataProductLink(new DataProductLink(supportUrl));
}
else {
supportInfo.supportUrl.url = supportUrl;
}
});
export const supportInfo_addEmail = action((supportInfo, email) => {
addUniqueEntry(supportInfo.emails, observe_Email(email));
});
export const supportInfo_deleteEmail = action((supportInfo, email) => {
const index = supportInfo.emails.indexOf(email);
if (index !== -1) {
supportInfo.emails.splice(index, 1);
}
});
export const dataProduct_setOperationalMetadataIfAbsent = action((product) => {
if (!product.operationalMetadata) {
product.operationalMetadata = observe_OperationalMetadata(new DataProductOperationalMetadata());
}
});
export const operationalMetadata_setUpdateFrequency = action((operationalMetadata, updateFrequency) => {
operationalMetadata.updateFrequency = updateFrequency;
});
export const operationalMetadata_addCoverageRegion = action((operationalMetadata, region) => {
if (!operationalMetadata.coverageRegions) {
operationalMetadata.coverageRegions = [region];
}
else {
addUniqueEntry(operationalMetadata.coverageRegions, region);
}
});
export const operationalMetadata_deleteCoverageRegion = action((operationalMetadata, region) => {
if (operationalMetadata.coverageRegions) {
deleteEntry(operationalMetadata.coverageRegions, region);
}
});
//# sourceMappingURL=DSL_DataProduct_GraphModifierHelper.js.map