Commit 3334dc85 authored by Alexandre Morin's avatar Alexandre Morin

Merge branch 'release/2.4' into 'master'

Release/2.4 master

See merge request maarch/workflow!24
parents 9373933e ebcf23c9
data/conf/vhost.win.conf
data/conf/vhost.conf
data/conf/configuration.ini
data/conf/confvars.ini
<?php
/**
* Copyright (C) 2019 Maarch
*
* This file is part of bundle workflow.
*
* Bundle workflow is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Bundle workflow is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bundle anadoc. If not, see <http://www.gnu.org/licenses/>.
*/
namespace ext\workflow\bundle\workflow\Controller;
/**
* Controller for archive unit workflow
*
* @package workflow
* @author Alexandre Morin <alexandre.morin@maarch.org>
*/
class Actions
{
private $baseActionsController;
private $EngineController;
private $actions;
public function __construct()
{
$this->baseActionsController = \laabs::newController('workflow/BaseActions');
$this->EngineController = \laabs::newController('workflow/Engine');
$this->actions = $this->EngineController->getActions();
}
public function updateMetadata(
$archivesIds,
$actionId,
$archiveId = null,
$archiveName = null,
$archiverArchiveId = null,
$description = null,
$originatingDate = null,
$originatorArchiveId = null
) {
$action = $this->EngineController->getActionConfig($actionId);
$this->baseActionsController->updateMetadata(
$archivesIds,
$archiveId,
$archiveName,
$archiverArchiveId,
$description,
$originatingDate,
$originatorArchiveId
);
$this->baseActionsController->setStatus($archivesIds, $action['params']['status']);
}
public function addContent($archiveId, $actionId, $archive)
{
$action = $this->EngineController->getActionConfig($actionId);
$this->baseActionsController->addContent($archiveId, $archive);
$this->baseActionsController->setStatus($archiveId, $action['params']['status']);
}
public function setUserOrgAccess($archiveId, $actionId, $userOrgRegNumbers)
{
$action = $this->EngineController->getActionConfig($actionId);
$this->baseActionsController->setUserOrgAccess($archiveId, $userOrgRegNumbers);
$this->baseActionsController->setStatus($archiveId, $action['params']['status']);
}
}
\ No newline at end of file
<?php
/**
* Copyright (C) 2019 Maarch
*
* This file is part of bundle workflow.
*
* Bundle workflow is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Bundle workflow is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bundle workflow. If not, see <http://www.gnu.org/licenses/>.
*/
namespace ext\workflow\bundle\workflow\Controller;
/**
* Base controller for archive unit workflow
*
* @package workflow
* @author Cyril Vazquez <cyril.vazquez@maarch.org>
*/
class BaseActions
{
/**
* The SDO Factory engine
* @var dependency\sdo\SDOFactory
*/
protected $sdoFactory;
/**
* Constructs a new action executor service
* @param dependency\sdo\Factory $sdoFactory
*/
public function __construct(\dependency\sdo\Factory $sdoFactory)
{
$this->sdoFactory = $sdoFactory;
$this->archiveController = \laabs::newController('recordsManagement/archive');
$this->orgController = \laabs::newController('organization/organization');
$this->archivalProfileController = \laabs::newController('recordsManagement/archivalProfile');
}
/**
* Returns the archive descriptive metadata
* @param string $archiveId The archive identifier
*
* @return object
*/
public function getMetadata($archiveId)
{
$archive = $this->archiveController->getMetadata($archiveId, $checkAccess = false);
return $archive;
}
/**
* Returns the archive descriptive metadata
* @param array $archiveIds The archive identifier
*
* @return object
*/
public function getArchiveUnit($archiveIds)
{
$archives = [];
foreach ($archiveIds as $archiveId) {
$archives[] = $this->archiveController->retrieve($archiveId, $checkAccess = false);
}
return $archives;
}
/**
* Sets the processing status for one or several archive units
* @param array $archiveIds
* @param string $status
*
* @return array The result of the batch process
*/
public function setStatus($archiveIds, string $status)
{
if (!is_array($archiveIds)) {
$archiveIds = array($archiveIds);
}
foreach ($archiveIds as $archiveId) {
$archive = $this->sdoFactory->read('recordsManagement/archive', $archiveId);
$archive->lastModificationDate = \laabs::newTimestamp();
$this->sdoFactory->update($archive);
}
$results = $this->archiveController->setProcessingStatus($archiveIds, $status);
return $results;
}
/**
* Store a new resource
*
* @param string $archiveId The archive identifier
* @param string $contents The resource contents
* @param string $filename The optional filename
*
* @return The new resource identifier
*/
public function addResource($archiveId, $contents, $filename = false)
{
$result = $this->archiveController->addResource($archiveId, $contents, $filename, $checkAccess = false);
return $result;
}
/**
* Add a new archive unit to an existing archive
* @param string $archiveId The parent archive identifier
* @param object $archive The archive object
*
* @return string the identifier
*/
public function addContent($archiveId, $archive)
{
$parentArchive = $this->getMetadata($archiveId);
// Force originator
$archive->parentArchiveId = $archiveId;
$archive->originatorOrgRegNumber = $parentArchive->originatorOrgRegNumber;
$archive->originatorOwnerOrgId = $parentArchive->originatorOwnerOrgId;
$archive->originatorOwnerOrgRegNumber = $parentArchive->originatorOwnerOrgRegNumber;
return $this->archiveController->receive($archive);
}
/**
* Update metadata of archive
* @param array $archivesId
* @param string $archiveId
* @param string $originatorArchiveId
* @param string $archiveName
* @param date $originatingDate
* @param string $description
*
* @return boolean The result of the operation
*/
public function updateMetadata(
$archivesIds,
$archiveId = null,
$archiveName = null,
$archiverArchiveId = null,
$description = null,
$originatingDate = null,
$originatorArchiveId = null
) {
return $this->archiveController->modifyMetadata(
$archiveId,
$originatorArchiveId,
$archiverArchiveId,
$archiveName,
$originatingDate,
$description,
$checkAccess = false
);
}
/**
* Add user accesses to archive userOrgRegNumbers
* @param string $archiveId The archive identifier
*
* @return array An assocative array of status codes => array of possible user org reg numbers
*/
public function getUserOrgAccess($archiveId)
{
$userOrgAccesses = [];
$archive = $this->archiveController->read($archiveId);
$archivalProfileReference = $archive->archivalProfileReference;
$archivalProfileAccesses = $this->orgController->getArchivalProfileAccess(null, $archivalProfileReference);
$archivalProfile = $this->archivalProfileController->getByReference($archivalProfileReference);
if (empty($archivalProfile->processingStatuses) || !is_object($archivalProfile->processingStatuses)) {
return [];
}
$processingStatuses = $archivalProfile->processingStatuses->getValue();
// Check that all accesses to statuses are still available on profile
foreach ($processingStatuses as $statusCode => $processingStatus) {
if ($processingStatus->type == 'final') {
continue;
}
if (!isset($processingStatus->filterUserAccess) || $processingStatus->filterUserAccess === false) {
continue;
}
$userOrgAccesses[$statusCode] = [];
foreach ($archivalProfileAccesses as $archivalProfileAccess) {
// Get the Laabs json objet
if (empty($archivalProfileAccess->userAccess) || !is_object($archivalProfileAccess->userAccess)) {
continue;
}
$userAccess = $archivalProfileAccess->userAccess->getValue();
if (!property_exists($userAccess, 'processingStatuses')
|| !is_object($userAccess->processingStatuses)
|| !isset($userAccess->processingStatuses->{$statusCode})) {
continue;
}
$userOrgAccesses[$statusCode][] = $archivalProfileAccess->orgId;
}
}
return [$archive, $userOrgAccesses];
}
/**
* Add user accesses to an archive by updating userOrgRegNumbers
* @param string $archiveId The archive identifier
* @param string[] $userOrgRegNumbers The user org registration numbers
*
* @return bool
*/
public function setUserOrgAccess($archiveId, array $userOrgRegNumbers)
{
if (isset($userOrgRegNumbers) && is_object($userOrgRegNumbers[0])) {
$userOrgRegNumbers = json_decode(json_encode($userOrgRegNumbers[0]), true);
}
return $this->archiveController->updateUserOrgRegNumbers($archiveId, $userOrgRegNumbers);
}
}
This diff is collapsed.
<?php
/*
* Copyright (C) 2015 Maarch
*
* This file is part of bundle Workflow.
*
* Bundle Workflow is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Bundle Workflow is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bundle Workflow. If not, see <http://www.gnu.org/licenses/>.
*/
namespace bundle\workflow\Model;
/**
* Workflow action result
*
* @package Workflow
*
*/
class ActionResult
{
// Actual action result
/**
* The return code (0 means OK ?)
*
* @var int
* @notempty
*/
public $returnCode = 0;
/**
* The action return
*
* @var mixed
*/
public $serviceReturn;
// Action info
/**
* The archival profile reference
*
* @var string
*/
public $archivalProfileReference;
/**
* The status code
*
* @var string
*/
public $statusCode;
/**
* The action identifier
*
* @var string
*/
public $actionId;
/**
* The action referer (form or previous action id)
*
* @var string
*/
public $refererId;
/**
* The archive identifiers
*
* @var string[]
*/
public $archiveIds;
/**
* The action configuration
* @var array
*/
public $actionConfig;
}
<?php
/*
* Copyright (C) 2018 Maarch
*
* This file is part of bundle anadoc.
*
* Bundle anadoc is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Bundle anadoc is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bundle anadoc. If not, see <http://www.gnu.org/licenses/>.
*/
namespace ext\workflow\bundle\workflow;
/**
* Interface for workflow
*
* @package workflow
*/
interface WorkflowInterface
{
/**
* Get list of actions
*
* @action workflow/Engine/getActions
*/
public function readActions();
/**
* Get available workflows
* @action workflow/Engine/getWorkflow
*/
public function readWorkflow();
/**
* @param $archivalProfileReference
* @param $statusCode
*
* @action workflow/Engine/getStatus
*/
public function readStatus($archivalProfileReference, $statusCode);
/**
* Get archive informations by its archiveId
*
* @action workflow/Engine/getArchiveInformation
*/
public function read_archiveId_informations_isComingFromWorkflowHistory_();
/**
* Get archive units for a given profile and status
*
* @action workflow/Engine/getArchiveUnits
*/
public function read_archivalProfileReference_($statusCode = null);
/**
* Get archive units for a given profile and status
*
* @param $archivalProfileReference
* @param null $text
* @param null $description
* @param null $originatingStartDate
* @param null $originatingEndDate
*
* @action workflow/Engine/history
*/
public function read_archivalProfileReference_history(
$text = null,
$description = null,
$originatingStartDate = null,
$originatingEndDate = null,
$originatingDate = null
);
/**
* Execute action on archive units
* @param string $statusCode
* @param string $actionId
* @param array $archiveIds An array of archiveunit identifiers for the action
* @param object $params
* @param string $refererId The referer action identifier to check access on resulting actions (submit, choice)
*
* @action workflow/Engine/processAction
*/
public function update_archivalProfileReference_(
$statusCode,
$actionId,
array $archiveIds = [],
$params = null,
$refererId = null
);
}
#!/bin/bash
cd $SCRIPT_PATH
# Set environment/server variables
export LAABS_APP="maarchRM"
export LAABS_INSTANCE_NAME="workflow"
export LAABS_BUNDLES="workflow;audit;auth;batchProcessing;contact;digitalResource;filePlan;lifeCycle;organization;recordsManagement"
export LAABS_EXTENSIONS="workflow"
export LAABS_DEPENDENCIES="repository;xml;html;localisation;datasource;sdo;json;fileSystem;PDF"
export LAABS_CONFIGURATION="../src/ext/workflow/data/conf/configuration.ini"
export LAABS_BUFFER_MODE=1
export LAABS_PHP_INI="$SCRIPT_PATH/../conf/php_batch.ini"
export LAABS_CONTENT_TYPES="url:application/x-www-form-urlencoded;html:text/html,application/xhtml+xml;xml:application/xml;json:application/json,application/javascript;soap:application/soap+xml;csv:text/csv"
# export LAABS_CONTENT_LANGUAGES="fr:fr,fr-fr,fr-ca"
export LAABS_TMP_DIR="$SCRIPT_PATH/../tmp"
# export LAABS_LOG="$SCRIPT_PATH/../log.txt"
export LAABS_XML_NS="medona:org:afnor:medona:1.0"
export LAABS_CRYPT_KEY="mySecretKey"
export LAABS_CRYPT_CIPHER=MCRYPT_BLOWFISH
# Change working directory to web root
cd ../../../../../web
AUTH=RJpzB36bmR+iuz/aHN9Zl9PDn8tZEs4mzsz9ORUXZpbMim/ilUMpE9FzYG3TW0Eii0Oy1PaFyJ35aBqcMU3gvAq4v0ZY0Z/r0cPVzbAaymd1UEnsAe3MjqGLt7BxvxiHJQ==
AUTH=RJpzB36bmR+iuz/aHN9Zl9PDn8tZEs4mzsz9OXNeNIrej2+v3UMzAsF3PSzDUlZ73kPvgqbQmZvza0eZO062uQu57Rdah9z3mdbTh6NBiiR8FQTnW6eVgQ==
#!/bin/bash
SCRIPT_PATH=`dirname $(readlink -f "$0")`
LAABS_PATH="$SCRIPT_PATH/../../../../../";
cd $SCRIPT_PATH
source 0-config.sh
# Run test job
# -d xdebug.profiler_enable=1 -d xdebug.collect_params=0
php cli.php CREATE medona/Archivetransfer messageFile="$LAABS_PATH/data/maarchRM/samples/medona/ArchiveTransfer_invoices_300/ArchiveTransfer_invoices_300.xml" attachments="$LAABS_PATH/data/maarchRM/samples/medona/ArchiveTransfer_invoices_300" -tokenfile:"$SCRIPT_PATH/0-token.txt"
php cli.php UPDATE medona/ArchiveTransfer/Validate/Batch -tokenfile:"$SCRIPT_PATH/0-token.txt"
php cli.php UPDATE medona/ArchiveTransfer/Process/Batch -tokenfile:"$SCRIPT_PATH/0-token.txt"
#!/bin/bash
SCRIPT_PATH=`dirname $(readlink -f "$0")`;
cd $SCRIPT_PATH
source 0-config.sh
# Run test job
php cli.php UPDATE medona/ArchiveTransfer/Validate/Batch -tokenfile:"$SCRIPT_PATH/0-token.txt"
#!/bin/bash
SCRIPT_PATH=`dirname $(readlink -f "$0")`
cd $SCRIPT_PATH
source 0-config.sh
# Run test job
php cli.php UPDATE medona/message/archive -tokenfile:"$SCRIPT_PATH/0-token.txt"
php cli.php CREATE lifeCycle/journal/Chainjournal -tokenfile:"$SCRIPT_PATH/0-token.txt"
php cli.php CREATE audit/event/Chainjournal -tokenfile:"$SCRIPT_PATH/0-token.txt"
#!/bin/bash
SCRIPT_PATH=`dirname $(readlink -f "$0")`
cd $SCRIPT_PATH
source 0-config.sh
# Run test job
php cli.php READ medona/documentConversion/process/all -tokenfile:"$SCRIPT_PATH/0-token.txt"
\ No newline at end of file