17 $robotTemplate = Automation\Engine\Template::createByTpl($tpl);
19 if ($robotTemplate->isExternalModified())
24 $robots = $robotTemplate->toArray()[
'ROBOTS'];
28 'DOCUMENT_STATUS' => $tpl->getDocumentStatus(),
29 'NAME' => $tpl->getName(),
30 'DESCRIPTION' => $tpl->getDescription(),
31 'PARAMETERS' => $tpl->getParameters(),
32 'VARIABLES' => $tpl->getVariables(),
33 'CONSTANTS' => $tpl->getConstants(),
34 'SYSTEM_CODE' => $tpl->getSystemCode(),
35 'ORIGINATOR_ID' => $tpl->getOriginatorId(),
36 'ORIGIN_ID' => $tpl->getOriginId(),
39 'DOCUMENT_FIELDS' => $this->getUsedDocumentFields($tpl),
40 'REQUIRED_APPLICATIONS' => $this->getRequiredApplications($tpl),
53 $datum = Main\Web\Json::encode($datum);
56 return (
new Result\Pack())->setPackage($datum);
59 public function unpack($data)
64 if (is_string($datumTmp))
68 $datumTmp = Main\Web\Json::decode($data);
76 if (is_array($datumTmp) && is_array($datumTmp[
'ROBOTS']))
81 $robotTemplate->setRobots($datumTmp[
'ROBOTS']);
83 catch (Main\ArgumentException $e)
85 $result->addError(
new Main\Error(
Loc::getMessage(
"BIZPROC_WF_TEMPLATE_ROBOPACKAGE_WRONG_DATA")));
91 $tpl = WorkflowTemplateTable::createObject();
92 $tpl->set(
'MODULE_ID', $datumTmp[
'DOCUMENT_TYPE'][0]);
93 $tpl->set(
'ENTITY', $datumTmp[
'DOCUMENT_TYPE'][1]);
94 $tpl->set(
'DOCUMENT_TYPE', $datumTmp[
'DOCUMENT_TYPE'][2]);
95 $tpl->set(
'DOCUMENT_STATUS', $datumTmp[
'DOCUMENT_STATUS']);
96 $tpl->set(
'NAME', $datumTmp[
'NAME']);
97 $tpl->set(
'DESCRIPTION', $datumTmp[
'DESCRIPTION']);
98 $tpl->set(
'TEMPLATE', $robotTemplate->getActivities());
99 $tpl->set(
'PARAMETERS', $datumTmp[
'PARAMETERS']);
100 $tpl->set(
'VARIABLES', $datumTmp[
'VARIABLES']);
101 $tpl->set(
'CONSTANTS', $datumTmp[
'CONSTANTS']);
102 $tpl->set(
'SYSTEM_CODE', $datumTmp[
'SYSTEM_CODE']);
103 $tpl->set(
'ORIGINATOR_ID', $datumTmp[
'ORIGINATOR_ID']);
104 $tpl->set(
'ORIGIN_ID', $datumTmp[
'ORIGIN_ID']);
106 return $result->setTpl($tpl)
107 ->setDocumentFields($datumTmp[
'DOCUMENT_FIELDS'])
108 ->setRequiredApplications($datumTmp[
'REQUIRED_APPLICATIONS']);
111 $result->addError(
new Main\
Error(
Loc::getMessage(
"BIZPROC_WF_TEMPLATE_ROBOPACKAGE_WRONG_DATA")));
116 private function getUsedDocumentFields(Tpl $tpl)
125 $documentService = CBPRuntime::GetRuntime(
true)->getDocumentService();
126 $documentFields = $documentService->GetDocumentFields($tpl->getDocumentComplexType(),
true);
130 foreach ($usedFieldKeys as $fieldKey)
133 mb_strtoupper(mb_substr($fieldKey, -10)) !==
'_PRINTABLE'
135 isset($documentFields[$fieldKey])
138 $result[$fieldKey] = $documentFields[$fieldKey];
145 private function getRequiredApplications(Tpl $tpl)
147 $types = $tpl->getUsedActivityTypes();
150 foreach ($types as $type)
152 if (mb_strpos($type,
'rest_') === 0)
static getMessage($code, $replace=null, $language=null)