-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd6ba1a
commit f2d7898
Showing
26 changed files
with
568 additions
and
363 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
bpmnlint-plugin-custom/rules/controller-must-exist-once-and-only-once.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
bpmnlint-plugin-custom/rules/dpo-must-exist-once-and-only-once.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const {getTiltFromElementIfExists, tiltMustExistOnlyOnce} = require("../tilt-rule-helper"); | ||
|
||
module.exports = function() { | ||
function check(node, reporter) { | ||
let check_passed = false; | ||
let tilt_type = "tilt:DataProtectionOfficer"; | ||
if (getTiltFromElementIfExists(node, tilt_type)) { | ||
check_passed = tiltMustExistOnlyOnce(tilt_type) | ||
if(!check_passed){ | ||
reporter.report(node.id, `[ TILT ]\t ${tilt_type} must exist only once.`); | ||
} | ||
} | ||
} | ||
|
||
return { | ||
check: check | ||
}; | ||
}; |
32 changes: 32 additions & 0 deletions
32
bpmnlint-plugin-custom/rules/fields-must-exist-once-and-only-once.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const {getTiltFromElementIfExists, tiltMustExistOnlyOnce} = require("../tilt-rule-helper"); | ||
const tiltToExistOnce = [ | ||
"tilt:Controller", | ||
"tilt:DataProtectionOfficer", | ||
"tilt:Meta", | ||
"tilt:AccessAndDataPortability", | ||
"tilt:RightToInformation", | ||
"tilt:RightToRectificationOrDeletion", | ||
"tilt:RightToDataPortability", | ||
"tilt:RightToWithdrawConsent", | ||
"tilt:RightToComplain", | ||
"tilt:ChangesOfPurpose" | ||
] | ||
|
||
module.exports = function() { | ||
function check(node, reporter) { | ||
let check_passed = false; | ||
for(let x in tiltToExistOnce){ | ||
debugger; | ||
if (getTiltFromElementIfExists(node, tiltToExistOnce[x])) { | ||
check_passed = tiltMustExistOnlyOnce(tiltToExistOnce[x]) | ||
if(!check_passed){ | ||
reporter.report(node.id, `[ TILT ]\t ${tiltToExistOnce[x]} must exist only once.`); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return { | ||
check: check | ||
}; | ||
}; |
18 changes: 18 additions & 0 deletions
18
bpmnlint-plugin-custom/rules/meta-must-exist-once-and-only-once.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const {getTiltFromElementIfExists, tiltMustExistOnlyOnce} = require("../tilt-rule-helper"); | ||
|
||
module.exports = function() { | ||
function check(node, reporter) { | ||
let check_passed = false; | ||
let tilt_type = "tilt:Meta"; | ||
if (getTiltFromElementIfExists(node, tilt_type)) { | ||
check_passed = tiltMustExistOnlyOnce(tilt_type) | ||
if(!check_passed){ | ||
reporter.report(node.id, `[ TILT ]\t ${tilt_type} must exist only once.`); | ||
} | ||
} | ||
} | ||
|
||
return { | ||
check: check | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,157 +1,26 @@ | ||
import React, { Fragment, PureComponent } from 'camunda-modeler-plugin-helpers/react'; | ||
import { Fill } from 'camunda-modeler-plugin-helpers/components'; | ||
import tiltIcon from "../../assets/tilt.svg" | ||
const { getBusinessObject } = require('bpmn-js/lib/util/ModelUtil'); | ||
import { v4 as uuidv4 } from 'uuid'; | ||
|
||
import classNames from 'classnames'; | ||
import {getPropertyFromModdle } from '../tilt-properties/props/moddle-property-io'; | ||
import TILT from "../descriptors/tilt.json" | ||
import { buildTiltDocument } from './extractor'; | ||
import { saveFile } from './extractor'; | ||
|
||
export default class ExtractButton extends PureComponent { | ||
constructor() { | ||
super(); | ||
this._buttonRef = React.createRef(); | ||
} | ||
|
||
getTiltElements(element = null) { | ||
// if(!element){ | ||
// element = getBusinessObject(canvas.getRootElement()); | ||
// } | ||
var element_properties = []; | ||
var tilt_properties = []; | ||
|
||
if(element instanceof Object && !(element instanceof Array || element instanceof Function)){ | ||
element_properties = Object.getOwnPropertyNames(element); | ||
element_properties = element_properties.filter(e => | ||
!e.startsWith("$") && | ||
!['di','messageFlows','sourceRef','targetRef','incoming','outgoing','flowNodeRef'].includes(e)) | ||
|
||
}else if(Array.isArray(element)){ | ||
for(let i in element){ | ||
tilt_properties.push(...this.getTiltElements(element[i])); | ||
} | ||
return tilt_properties; | ||
|
||
}else{ | ||
return tilt_properties; | ||
|
||
} | ||
|
||
if(element.hasOwnProperty("$type") && element.$type.startsWith("tilt")){ | ||
tilt_properties.push(element); | ||
//console.log(element) | ||
return tilt_properties; | ||
|
||
} | ||
|
||
for(let p in element_properties){ | ||
|
||
if(element[element_properties[p]] instanceof Object && typeof(element[element_properties[p]]) != "string"){ | ||
tilt_properties.push(...this.getTiltElements(element[element_properties[p]])); | ||
|
||
} | ||
} | ||
return tilt_properties; | ||
}; | ||
|
||
getMeta(tilt_elements = []){ | ||
tilt_elements = tilt_elements.filter(e => e.$type == "tilt:Meta"); | ||
var meta = {}; | ||
var element_properties = tilt_descriptor.types.filter(e => e.name == "Meta")[0].properties | ||
var property_names = []; | ||
for(let i in element_properties){ | ||
property_names.push(element_properties[i].name.split(":")[1]); | ||
} | ||
for(m in tilt_elements){ | ||
for(p in property_names){ | ||
if(tilt_elements[m].hasOwnProperty(property_names[p])){ | ||
meta[property_names[p]] = tilt_elements[m][property_names[p]] | ||
}else{ | ||
meta[property_names[p]] = null; | ||
} | ||
} | ||
|
||
} | ||
return meta | ||
} | ||
|
||
createTiltObject(){ | ||
debugger; | ||
var canvas = window.bpmnjsInjector.get("canvas"); | ||
var rootElement = canvas.getRootElement(); | ||
var tilt_object = {} | ||
var tilt_elements = getBusinessObject(this.getTiltElements(rootElement)); | ||
tilt_object["meta"] = this.getMeta(tilt_elements); | ||
navigator.clipboard.writeText(tilt_object) | ||
|
||
alert("Copied the extracted TILT Document to the clipboard.") | ||
debugger; | ||
} | ||
|
||
createPropertyFromFile(){ | ||
var moddle = TILT; | ||
debugger; | ||
var x = getPropertyFromModdle("tilt:Meta",moddle); | ||
} | ||
|
||
saveFile(){ | ||
var object = buildTiltDocument(window.bpmnjsInjector.get("canvas")) | ||
debugger; | ||
var json_string = JSON.stringify(object, undefined, 2); | ||
var link = document.createElement('a'); | ||
link.download = 'NewTiltDocument.tilt.json'; | ||
var blob = new Blob([json_string], {type: 'application/json'}); | ||
link.href = window.URL.createObjectURL(blob); | ||
link.click(); | ||
} | ||
|
||
async saveFile2(){ | ||
const opts = { | ||
suggestedName: "NewProcessTiltDocument.tilt.json", | ||
types: [{ | ||
description: 'TILT .json file', | ||
accept: {'application/json': ['.tilt.json']}, | ||
}], | ||
excludeAcceptAllOption: true, | ||
}; | ||
try { | ||
// Show the file save dialog. | ||
const handle = await window.showSaveFilePicker(opts); | ||
// Write to the file. | ||
const writable = await handle.createWritable(); | ||
debugger; | ||
await writable.write("Hello World"); | ||
await writable.close(); | ||
return; | ||
} catch (err) { | ||
if (err.name !== 'AbortError') { | ||
alert(err.name +": "+ err.message); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
|
||
render() { | ||
// we can use fills to hook React components into certain places of the UI | ||
return <Fragment> | ||
<Fill slot="status-bar__file" group="1_tilt_save"> | ||
<button | ||
ref={ this._buttonRef } | ||
className={ classNames('tilt-btn','btn') } | ||
onClick={ () => this.saveFile()}> | ||
onClick={ () => saveFile(window.bpmnjsInjector.get("canvas"))}> | ||
TILT | ||
</button> | ||
</Fill> | ||
</Fragment>; | ||
} | ||
} | ||
|
||
//ExtractButton.$inject = [ | ||
// 'eventBus', | ||
// 'canvas', | ||
// 'injector', | ||
// 'viewer' | ||
//]; | ||
} |
Oops, something went wrong.