Beispiel #1
0
def get_variable_instance_binary_data(pc: PortalConnector,
                                      variable_instance_id,
                                      session=None):
    url = '/engine-rest/variable-instance/' + str(
        variable_instance_id) + '/data'
    json_response = pc.execute_request(url, session=session, binary_data=True)
    return json_response
Beispiel #2
0
def unclaim(pc: PortalConnector, task_id, session=None):
    url = '/engine-rest/task/' + str(task_id) + '/unclaim'
    json_response = pc.execute_request(url,
                                       request_type='POST',
                                       data={},
                                       session=session)
    return json_response
def get_process_start_form(pc: PortalConnector,
                           session=None,
                           process_key=None):
    url = '/engine-rest/process-definition/key/' + str(
        process_key) + '/startForm'
    json_response = pc.execute_request(url, session=session)
    return json_response
def submit_new_process(pc: PortalConnector,
                       session=None,
                       process_key=None,
                       data=None):
    url = '/engine-rest/process-definition/key/' + str(process_key) + '/start'
    # make data transformation for Camunda
    process_variables = {}
    for item in data:
        if item.type == 'StringField':
            process_variables[item.name] = {
                "value": item.data,
                "type": "String"
            }
        if item.type == 'FileField':
            process_variables[item.name] = {
                "value":
                base64.b64encode(item.data.stream.read()).decode('ascii'),
                "type": "File",
                "valueInfo": {
                    "filename": item.data.filename,
                    "mimetype": item.data.mimetype,
                    "encoding": "UTF-8"
                }
            }

    # process_variables = {}
    # for modification in data['modifications']:
    #    process_variables[modification["variable_id"]] = {"value": modification['value'], "type": modification['type']}
    all_vars = {"variables": process_variables}
    json_response = pc.execute_request(url,
                                       request_type='POST',
                                       session=session,
                                       data=all_vars)
    return json_response
def get_user_allowed_process_by_key(pc: PortalConnector,
                                    session=None,
                                    process_key=None):
    url = '/engine-rest/process-definition?latestVersion=true&startableBy=' + str(
        session['username']) + '&key=' + str(process_key)
    json_response = pc.execute_request(url, session=session)
    return json_response
Beispiel #6
0
def claim(pc: PortalConnector, task_id, session=None):
    url = '/engine-rest/task/' + str(task_id) + '/claim'
    data = {"userId": str(session['username'])}
    json_response = pc.execute_request(url,
                                       request_type='POST',
                                       data=data,
                                       session=session)
    return json_response
Beispiel #7
0
def get_all_user_tasks(pc: PortalConnector, session=None):
    url = '/engine-rest/task?assignee=' + str(session['username'])
    json_response = pc.execute_request(url, session=session)
    for record in json_response['response']:
        if record['created']:
            record['created'] = datetime.datetime.strptime(
                record['created'][:-9], '%Y-%m-%dT%H:%M:%S')
        if record['due']:
            record['due'] = datetime.datetime.strptime(record['due'][:-9],
                                                       '%Y-%m-%dT%H:%M:%S')
    return json_response
def get_process_history_by_id(pc: PortalConnector,
                              session=None,
                              execution_id=None):
    url = '/engine-rest/history/activity-instance?executionId=' + str(execution_id) \
          + '&activityType=intermediateNoneThrowEvent'
    json_response = pc.execute_request(url, session=session)
    for record in json_response['response']:
        if record['endTime']:
            record['endTime'] = datetime.datetime.strptime(
                record['endTime'][:-9], '%Y-%m-%dT%H:%M:%S')
    return json_response
Beispiel #9
0
def get_variable_instance_by_proc_inst_id_and_name(pc: PortalConnector,
                                                   proc_inst_id,
                                                   var_name=None,
                                                   session=None):
    if var_name:
        url = '/engine-rest/variable-instance?processInstanceIdIn=' \
              + str(proc_inst_id) + '&variableName=' + str(var_name)
    else:  # When var_name is not specified return all variable instances
        url = '/engine-rest/variable-instance?processInstanceIdIn=' + str(
            proc_inst_id)
    json_response = pc.execute_request(url, session=session)
    return json_response
def get_processes_started_by_user(pc: PortalConnector, session=None):
    url = '/engine-rest/history/process-instance?startedBy=' + str(
        session['username'])
    json_response = pc.execute_request(url, session=session)
    for record in json_response['response']:
        if record['startTime']:
            record['startTime'] = datetime.datetime.strptime(
                record['startTime'][:-9], '%Y-%m-%dT%H:%M:%S')
        if record['endTime']:
            record['endTime'] = datetime.datetime.strptime(
                record['endTime'][:-9], '%Y-%m-%dT%H:%M:%S')
    return json_response
Beispiel #11
0
def complete_task_by_id(pc: PortalConnector, task_id, data=None, session=None):
    url = '/engine-rest/task/' + str(task_id) + '/complete'
    # make data transformation for Camunda
    process_variables = {}
    for item in data:
        if item != "csrf_token":
            process_variables[item] = {"value": data[item], "type": "String"}
    all_vars = {"variables": process_variables}
    json_response = pc.execute_request(url,
                                       request_type='POST',
                                       session=session,
                                       data=all_vars)
    return json_response
Beispiel #12
0
def update_task_variables_by_id(pc: PortalConnector,
                                task_id,
                                data=None,
                                session=None):
    url = '/engine-rest/task/' + str(task_id) + '/variables'
    # make data transformation for Camunda
    modifications = {}
    for item in data:
        if item != "csrf_token":
            modifications[item] = {"value": data[item], "type": "String"}
    all_mods = {"modifications": modifications}
    json_response = pc.execute_request(url,
                                       request_type='POST',
                                       data=all_mods,
                                       session=session)
    return json_response
Beispiel #13
0
def count_all_user_tasks(pc: PortalConnector, session=None):
    url = '/engine-rest/task/count?assignee=' + str(session['username'])
    json_response = pc.execute_request(url, session=session)
    return json_response
Beispiel #14
0
import logging
import app.forms.common_form_factory as cff
import app.reports.user_tasks_count_report as user_tasks_count_report

app = Flask(__name__)
app.jinja_env.add_extension('jinja2.ext.loopcontrols')
# Set the secret key to some random bytes. Keep this really secret!
app.secret_key = b'your_secret_key_here'
logging.basicConfig(format='%(asctime)s %(message)s',
                    datefmt='%Y-%m-%d %I:%M:%S %p',
                    filename='execution.log',
                    encoding='utf-8',
                    level=logging.DEBUG)
tr = Translations()
vl = Validations()
connector = PortalConnector()


@app.route("/", methods=["POST", "GET"])
def authenticate_user():
    try:
        if 'language' not in session:
            session['language'] = 'en'  # default
        translations = tr.parse_template('app/templates/login.html',
                                         session['language'])
        validations = vl.parse_template('app/templates/login.html')
        if 'username' in session:
            return if_user_authenticated(connector)
        elif request.form:
            result = connector.authenticate_user(request.form)
            validations = vl.parse_template('app/templates/login.html')
Beispiel #15
0
def get_group_tasks(pc: PortalConnector, session=None):
    url = '/engine-rest/task?withCandidateGroups=true'
    json_response = pc.execute_request(url, session=session)
    return json_response
def get_process_definition_by_id(pc: PortalConnector,
                                 session=None,
                                 process_def_if=None):
    url = '/engine-rest/process-definition/' + str(process_def_if)
    json_response = pc.execute_request(url, session=session)
    return json_response
Beispiel #17
0
def get_task_vars_by_id(pc: PortalConnector, task_id, session=None):
    url = '/engine-rest/task/' + str(task_id) + '/variables'
    json_response = pc.execute_request(url, session=session)
    return json_response
Beispiel #18
0
def get_user_profile(pc: PortalConnector, session=None):
    url = '/engine-rest/user/' + str(session['username']) + '/profile'
    json_response = pc.execute_request(url, session=session)
    return json_response
def get_member_groups(pc: PortalConnector, session=None):
    url = '/engine-rest/group?member=' + str(session['username'])
    json_response = pc.execute_request(url, session=session)
    return json_response