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

Move deployment models to separate group to enable combining them with connectors #103

Merged
merged 6 commits into from
Oct 24, 2023
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 @@ -42,15 +42,6 @@ export function isExternalCapable(element) {
return is(element, "camunda:ExternalCapable");
}

/**
* Returns 'true'
*
* @return {boolean} true
*/
export function isDeploymentCapable() {
return true;
}

/**
* getServiceTaskLikeBusinessObject - Get a 'camunda:ServiceTaskLike' business object.
*
Expand Down Expand Up @@ -78,76 +69,6 @@ export function getServiceTaskLikeBusinessObject(element) {
return isServiceTaskLike(element) && getBusinessObject(element);
}

// /**
// * Returns the implementation type of the given element.
// *
// * Possible implementation types are:
// * - dmn
// * - connector
// * - external
// * - class
// * - expression
// * - delegateExpression
// * - script
// * - or undefined, when no matching implementation type is found
// *
// * @param {djs.model.Base} element
// *
// * @return {String} the implementation type
// */
// export function getImplementationType(element) {
//
// const businessObject = (
// getListenerBusinessObject(element) ||
// getServiceTaskLikeBusinessObject(element)
// );
//
// if (!businessObject) {
// return;
// }
//
// if (isDmnCapable(businessObject)) {
// const decisionRef = businessObject.get('camunda:decisionRef');
// if (typeof decisionRef !== 'undefined') {
// return 'dmn';
// }
// }
//
// if (isServiceTaskLike(businessObject)) {
// const connectors = getExtensionElementsList(businessObject, 'camunda:Connector');
// if (connectors.length) {
// return 'connector';
// }
// }
//
// if (isExternalCapable(businessObject)) {
// const type = businessObject.get('camunda:type');
// if (type === 'external') {
// return 'external';
// }
// }
//
// const cls = businessObject.get('camunda:class');
// if (typeof cls !== 'undefined') {
// return 'class';
// }
//
// const expression = businessObject.get('camunda:expression');
// if (typeof expression !== 'undefined') {
// return 'expression';
// }
//
// const delegateExpression = businessObject.get('camunda:delegateExpression');
// if (typeof delegateExpression !== 'undefined') {
// return 'delegateExpression';
// }
//
// const script = businessObject.get('script');
// if (typeof script !== 'undefined') {
// return 'script';
// }
// }

export function isListener(element) {
return this.isTaskListener(element) || this.isExecutionListener(element);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/**
* Copyright (c) 2023 Institute of Architecture of Application Systems -
* University of Stuttgart
*
* This program and the accompanying materials are made available under the
* terms the Apache Software License 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*/

import { connectRectangles } from "diagram-js/lib/layout/ManhattanLayout";

import { createLine } from "diagram-js/lib/util/RenderUtil";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/**
* Copyright (c) 2023 Institute of Architecture of Application Systems -
* University of Stuttgart
*
* This program and the accompanying materials are made available under the
* terms the Apache Software License 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*/

import { HeaderButton } from "@bpmn-io/properties-panel";
import React from "react";
import ArtifactModal from "./ArtifactUploadModal";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import { SelectEntry } from "@bpmn-io/properties-panel";
import React from "@bpmn-io/properties-panel/preact/compat";
import { useService } from "bpmn-js-properties-panel";
import { getModeler } from "../../../../editor/ModelerHandler";

/**
* Copyright (c) 2023 Institute of Architecture of Application Systems -
* University of Stuttgart
Expand All @@ -13,6 +8,12 @@ import { getModeler } from "../../../../editor/ModelerHandler";
*
* SPDX-License-Identifier: Apache-2.0
*/

import { SelectEntry } from "@bpmn-io/properties-panel";
import React from "@bpmn-io/properties-panel/preact/compat";
import { useService } from "bpmn-js-properties-panel";
import { getModeler } from "../../../../editor/ModelerHandler";

const yaml = require("js-yaml");
/**
* Entry to display the endpoints of the uploaded openapi specification for BPMN service task.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import { SelectEntry } from "@bpmn-io/properties-panel";
import React from "@bpmn-io/properties-panel/preact/compat";
import { useService } from "bpmn-js-properties-panel";
import { getImplementationType } from "../../../quantme/utilities/ImplementationTypeHelperExtension";

/**
* Copyright (c) 2023 Institute of Architecture of Application Systems -
* University of Stuttgart
Expand All @@ -14,6 +9,10 @@ import { getImplementationType } from "../../../quantme/utilities/Implementation
* SPDX-License-Identifier: Apache-2.0
*/

import { SelectEntry } from "@bpmn-io/properties-panel";
import React from "@bpmn-io/properties-panel/preact/compat";
import { useService } from "bpmn-js-properties-panel";

const jquery = require("jquery");

const QUANTME_NAMESPACE_PULL = "http://quantil.org/quantme/pull";
Expand All @@ -28,7 +27,7 @@ export function Deployment({ element, translate, wineryEndpoint }) {
const debounce = useService("debounceInput");

const selectOptions = function () {
const arrValues = [];
const arrValues = [{ label: "No CSAR", value: undefined }];
jquery.ajax({
url: wineryEndpoint + "/servicetemplates/?grouped",
method: "GET",
Expand All @@ -53,9 +52,6 @@ export function Deployment({ element, translate, wineryEndpoint }) {
},
async: false,
});
if (arrValues.length === 0) {
arrValues.push({ label: "No CSARs available", value: "" });
}
return arrValues;
};

Expand All @@ -65,20 +61,16 @@ export function Deployment({ element, translate, wineryEndpoint }) {

const setValue = function (value) {
return modeling.updateProperties(element, {
deploymentModelUrl: value || "",
deploymentModelUrl: value,
});
};

const validate = function (values) {
return values === undefined || values === ""
? translate("Must provide a CSAR")
: "";
const validate = function () {
return "";
};

const hidden = function () {
const implType = getImplementationType(element);
console.log("getImplementationType returns " + implType);
return !(implType === "deploymentModel");
return false;
};

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright (c) 2023 Institute of Architecture of Application Systems -
* University of Stuttgart
*
* This program and the accompanying materials are made available under the
* terms the Apache Software License 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*/

import { getServiceTaskLikeBusinessObject } from "../../../../editor/util/camunda-utils/ImplementationTypeUtils";
import { ArtifactUpload } from "./ArtifactUpload";
import { isTextFieldEntryEdited } from "@bpmn-io/properties-panel";
import { Deployment } from "./Deployment";

/**
* Properties group for service tasks. Extends the original implementation by adding a new selection option to the
* implementation entry: deployment.
*
* @param props
* @return {{component: function(*): preact.VNode<any>, isEdited: function(*): *, id: string}[]|*[]}
* @constructor
*/
export function DeploymentModelProps(props) {
const { element, wineryEndpoint, translate } = props;

// deployment models can only be defined for ServiceTasks
if (!getServiceTaskLikeBusinessObject(element)) {
return [];
}

// list of configuration options
const entries = [];

// field to define deployment models
entries.push({
id: "deployment",
element,
translate,
wineryEndpoint,
component: Deployment,
isEdited: isTextFieldEntryEdited,
});

entries.push({
id: "artifactUpload",
element,
translate,
component: ArtifactUpload,
isEdited: isTextFieldEntryEdited,
});

return entries;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/**
* Copyright (c) 2023 Institute of Architecture of Application Systems -
* University of Stuttgart
*
* This program and the accompanying materials are made available under the
* terms the Apache Software License 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*/

import { getBusinessObject } from "bpmn-js/lib/util/ModelUtil";

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/**
* Copyright (c) 2023 Institute of Architecture of Application Systems -
* University of Stuttgart
*
* This program and the accompanying materials are made available under the
* terms the Apache Software License 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*/

import {
isTextFieldEntryEdited,
TextFieldEntry,
Expand All @@ -8,24 +19,22 @@ import { useService } from "bpmn-js-properties-panel";
import { getImplementationType } from "../../../quantme/utilities/ImplementationTypeHelperExtension";
import { getServiceTaskLikeBusinessObject } from "../../../../editor/util/camunda-utils/ImplementationTypeUtils";
import { getExtensionElementsList } from "../../../../editor/util/camunda-utils/ExtensionElementsUtil";
import { Deployment } from "./Deployment";
import { Connector } from "./Connector";
import { YamlUpload } from "./YamlUpload";
import { ArtifactUpload } from "./ArtifactUpload";
import { Connector } from "./Connector";
import yaml from "js-yaml";

const yaml = require("js-yaml");
const QUANTME_NAMESPACE_PULL = "http://quantil.org/quantme/pull";

/**
* Properties group for service tasks. Extends the original implementation by adding a new selection option to the
* implementation entry: deployment.
* Properties group for implementations of service tasks.
*
* @param props
* @param element
* @return {{component: function(*): preact.VNode<any>, isEdited: function(*): *, id: string}[]|*[]}
* @constructor
*/
export function ImplementationProps(props) {
const { element, wineryEndpoint, translate } = props;
console.log("Rendering implementation properties for ServiceTask!");
const { element, translate } = props;

if (!getServiceTaskLikeBusinessObject(element)) {
return [];
Expand Down Expand Up @@ -77,44 +86,32 @@ export function ImplementationProps(props) {
isEdited: isTextFieldEntryEdited,
});

// custom extension
} else if (implementationType === "deploymentModel") {
entries.push({
id: "deployment",
element,
translate,
wineryEndpoint,
component: Deployment,
isEdited: isTextFieldEntryEdited,
});
entries.push({
id: "yamlUpload",
component: YamlUpload,
isEdited: isTextFieldEntryEdited,
});
if (
!element.businessObject.deploymentModelUrl ||
!element.businessObject.deploymentModelUrl.includes(
encodeURIComponent(encodeURIComponent(QUANTME_NAMESPACE_PULL))
) &&
element.businessObject.yaml !== undefined
)
) {
const urls = extractUrlsFromYaml(element.businessObject.yaml);
// field to upload an OpenAPI spec for automated connector generation
entries.push({
id: "connector",
element,
translate,
urls,
component: Connector,
id: "yamlUpload",
component: YamlUpload,
isEdited: isTextFieldEntryEdited,
});

// drop down to select endpoint from OpenAPI spec
if (element.businessObject.yaml !== undefined) {
const urls = extractUrlsFromYaml(element.businessObject.yaml);
entries.push({
id: "connector",
element,
translate,
urls,
component: Connector,
isEdited: isTextFieldEntryEdited,
});
}
}
entries.push({
id: "artifactUpload",
element,
translate,
component: ArtifactUpload,
isEdited: isTextFieldEntryEdited,
});
}

return entries;
Expand Down
Loading