Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchCourrier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchCourrier
Commits
a8de7ec8
Commit
a8de7ec8
authored
3 years ago
by
Quentin Ribac
Browse files
Options
Downloads
Patches
Plain Diff
FEAT #14837 TIME 0:15 cleaning code and added TODOs
parent
2e6afc9b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/external/multigest/controllers/MultigestController.php
+16
-19
16 additions, 19 deletions
...pp/external/multigest/controllers/MultigestController.php
with
16 additions
and
19 deletions
src/app/external/multigest/controllers/MultigestController.php
+
16
−
19
View file @
a8de7ec8
...
@@ -66,6 +66,7 @@ class MultigestController
...
@@ -66,6 +66,7 @@ class MultigestController
if
(
!
Validator
::
stringType
()
->
notEmpty
()
->
validate
(
$body
[
'uri'
]))
{
if
(
!
Validator
::
stringType
()
->
notEmpty
()
->
validate
(
$body
[
'uri'
]))
{
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Body uri is empty or not a string'
]);
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Body uri is empty or not a string'
]);
}
elseif
(
!
Validator
::
stringType
()
->
notEmpty
()
->
validate
(
$body
[
'login'
]))
{
}
elseif
(
!
Validator
::
stringType
()
->
notEmpty
()
->
validate
(
$body
[
'login'
]))
{
return
$response
->
withStatus
(
400
)
->
withJson
([
'errors'
=>
'Body login is empty or not a string'
]);
}
}
$value
=
json_encode
([
$value
=
json_encode
([
...
@@ -194,13 +195,9 @@ class MultigestController
...
@@ -194,13 +195,9 @@ class MultigestController
'label'
=>
$externalId
[
'multigest'
][
'label'
],
'label'
=>
$externalId
[
'multigest'
][
'label'
],
'login'
=>
$externalId
[
'multigest'
][
'login'
],
'login'
=>
$externalId
[
'multigest'
][
'login'
],
'sasId'
=>
$externalId
[
'multigest'
][
'sasId'
],
'sasId'
=>
$externalId
[
'multigest'
][
'sasId'
],
'entities'
=>
[]
'entities'
=>
array_column
(
$entities
,
'id'
)
];
];
foreach
(
$entities
as
$entity
)
{
$account
[
'entities'
][]
=
$entity
[
'id'
];
}
return
$response
->
withJson
(
$account
);
return
$response
->
withJson
(
$account
);
}
}
...
@@ -243,7 +240,7 @@ class MultigestController
...
@@ -243,7 +240,7 @@ class MultigestController
'label'
=>
$body
[
'label'
],
'label'
=>
$body
[
'label'
],
'login'
=>
$body
[
'login'
],
'login'
=>
$body
[
'login'
],
'password'
=>
empty
(
$body
[
'password'
])
?
$externalId
[
'multigest'
][
'password'
]
:
PasswordModel
::
encrypt
([
'password'
=>
$body
[
'password'
]]),
'password'
=>
empty
(
$body
[
'password'
])
?
$externalId
[
'multigest'
][
'password'
]
:
PasswordModel
::
encrypt
([
'password'
=>
$body
[
'password'
]]),
'sasId'
=>
$body
[
'sasId'
]
'sasId'
=>
$body
[
'sasId'
]
];
];
$account
=
json_encode
(
$account
);
$account
=
json_encode
(
$account
);
...
@@ -421,20 +418,17 @@ class MultigestController
...
@@ -421,20 +418,17 @@ class MultigestController
if
(
empty
(
$multigestField
)
||
empty
(
$maarchField
))
{
if
(
empty
(
$multigestField
)
||
empty
(
$maarchField
))
{
continue
;
continue
;
}
}
$nextField
=
''
;
$nextValue
=
''
;
$nextField
=
$multigestField
;
if
(
$maarchField
==
'CURRENT_DATE'
)
{
if
(
$maarchField
==
'CURRENT_DATE'
)
{
$nextField
=
$multigestField
;
$nextValue
=
date
(
'Y-m-d'
);
$nextValue
=
date
(
'Y-m-d'
);
}
elseif
(
isset
(
$document
[
$maarchField
]))
{
}
elseif
(
isset
(
$document
[
$maarchField
]))
{
$nextField
=
$multigestField
;
if
(
strpos
(
$maarchField
,
'_date'
)
!==
false
)
{
if
(
strpos
(
$maarchField
,
'_date'
)
!==
false
)
{
$document
[
$maarchField
]
=
substr
(
$document
[
$maarchField
],
0
,
10
);
$date
=
new
\DateTime
(
$document
[
$maarchField
]);
$document
[
$maarchField
]
=
$date
->
format
(
'Y-m-d'
);
}
}
$nextValue
=
$document
[
$maarchField
];
$nextValue
=
$document
[
$maarchField
];
}
else
{
}
else
{
$nextField
=
$multigestField
;
$nextValue
=
MultigestController
::
getResourceField
(
$document
,
$maarchField
,
$rawContacts
);
$nextValue
=
MultigestController
::
getResourceField
(
$document
,
$maarchField
,
$rawContacts
);
}
}
...
@@ -464,7 +458,7 @@ class MultigestController
...
@@ -464,7 +458,7 @@ class MultigestController
return
[
'errors'
=>
'No valid metadata from Multigest mapping'
];
return
[
'errors'
=>
'No valid metadata from Multigest mapping'
];
}
}
$soapClient
=
new
\SoapClient
(
$multigestUri
,
[
'trace'
=>
true
]
);
$soapClient
=
new
\SoapClient
(
$multigestUri
);
$soapClient
->
GedSetModeUid
(
1
);
$soapClient
->
GedSetModeUid
(
1
);
$soapClient
->
GedChampReset
();
$soapClient
->
GedChampReset
();
...
@@ -472,8 +466,8 @@ class MultigestController
...
@@ -472,8 +466,8 @@ class MultigestController
$result
=
(
int
)
$soapClient
->
GedDossierExist
(
$entityConfiguration
[
'sasId'
],
$entityConfiguration
[
'login'
]);
$result
=
(
int
)
$soapClient
->
GedDossierExist
(
$entityConfiguration
[
'sasId'
],
$entityConfiguration
[
'login'
]);
if
(
$result
>
0
)
{
if
(
$result
>
0
)
{
return
[
'errors'
=>
'This resource is already in Multigest'
];
return
[
'errors'
=>
'This resource is already in Multigest'
];
}
elseif
(
$result
!==
-
7
)
{
}
elseif
(
$result
!==
-
7
)
{
// -7 -> "Dossier inexistant"
return
[
'errors'
=>
'Multigest error '
.
$result
.
' occured while checking for folder preexistence'
];
return
[
'errors'
=>
'Multigest error '
.
$result
.
' occur
r
ed while checking for folder preexistence'
];
}
}
$soapClient
->
GedChampReset
();
$soapClient
->
GedChampReset
();
...
@@ -487,7 +481,7 @@ class MultigestController
...
@@ -487,7 +481,7 @@ class MultigestController
$soapClient
->
GedAddChampRecherche
(
$keyMetadataField
,
$keyMetadataValue
);
$soapClient
->
GedAddChampRecherche
(
$keyMetadataField
,
$keyMetadataValue
);
$result
=
$soapClient
->
GedDossierExist
(
$entityConfiguration
[
'sasId'
],
$entityConfiguration
[
'login'
]);
$result
=
$soapClient
->
GedDossierExist
(
$entityConfiguration
[
'sasId'
],
$entityConfiguration
[
'login'
]);
if
(
$result
<=
0
)
{
if
(
$result
<=
0
)
{
return
[
'errors'
=>
'Multigest error '
.
$result
.
' occured while accessing folder'
];
return
[
'errors'
=>
'Multigest error '
.
$result
.
' occur
r
ed while accessing folder'
];
}
}
$result
=
(
int
)
$soapClient
->
GedImporterDocumentStream
(
$result
=
(
int
)
$soapClient
->
GedImporterDocumentStream
(
$entityConfiguration
[
'sasId'
],
$entityConfiguration
[
'sasId'
],
...
@@ -507,7 +501,7 @@ class MultigestController
...
@@ -507,7 +501,7 @@ class MultigestController
-
1
-
1
);
);
if
(
$result
<=
0
)
{
if
(
$result
<=
0
)
{
return
[
'errors'
=>
'Multigest error '
.
$result
.
' occured while importing main document'
];
return
[
'errors'
=>
'Multigest error '
.
$result
.
' occur
r
ed while importing main document'
];
}
}
$externalId
=
json_decode
(
$document
[
'external_id'
],
true
);
$externalId
=
json_decode
(
$document
[
'external_id'
],
true
);
...
@@ -523,6 +517,7 @@ class MultigestController
...
@@ -523,6 +517,7 @@ class MultigestController
]);
]);
foreach
(
$attachments
as
$attachment
)
{
foreach
(
$attachments
as
$attachment
)
{
// TODO check for last version
$adrInfo
=
[
$adrInfo
=
[
'docserver_id'
=>
$attachment
[
'docserver_id'
],
'docserver_id'
=>
$attachment
[
'docserver_id'
],
'path'
=>
$attachment
[
'path'
],
'path'
=>
$attachment
[
'path'
],
...
@@ -578,7 +573,7 @@ class MultigestController
...
@@ -578,7 +573,7 @@ class MultigestController
$soapClient
->
GedAddChampRecherche
(
$keyAttachmentMetadataField
,
$keyAttachmentMetadataValue
);
$soapClient
->
GedAddChampRecherche
(
$keyAttachmentMetadataField
,
$keyAttachmentMetadataValue
);
$result
=
$soapClient
->
GedDossierExist
(
$entityConfiguration
[
'sasId'
],
$entityConfiguration
[
'login'
]);
$result
=
$soapClient
->
GedDossierExist
(
$entityConfiguration
[
'sasId'
],
$entityConfiguration
[
'login'
]);
if
(
$result
<=
0
)
{
if
(
$result
<=
0
)
{
return
[
'errors'
=>
'Multigest error '
.
$result
.
' occured while accessing folder'
];
return
[
'errors'
=>
'Multigest error '
.
$result
.
' occur
r
ed while accessing folder'
];
}
}
$result
=
(
int
)
$soapClient
->
GedImporterDocumentStream
(
$result
=
(
int
)
$soapClient
->
GedImporterDocumentStream
(
$entityConfiguration
[
'sasId'
],
$entityConfiguration
[
'sasId'
],
...
@@ -598,7 +593,7 @@ class MultigestController
...
@@ -598,7 +593,7 @@ class MultigestController
-
1
-
1
);
);
if
(
$result
<=
0
)
{
if
(
$result
<=
0
)
{
return
[
'errors'
=>
'Multigest error '
.
$result
.
' occured while importing attachment'
];
return
[
'errors'
=>
'Multigest error '
.
$result
.
' occur
r
ed while importing attachment'
];
}
}
$multigestUIDs
[
'attachments'
][]
=
$result
;
$multigestUIDs
[
'attachments'
][]
=
$result
;
...
@@ -613,6 +608,7 @@ class MultigestController
...
@@ -613,6 +608,7 @@ class MultigestController
}
}
public
static
function
getResourceField
(
array
$document
,
string
$field
,
array
$rawContacts
)
{
public
static
function
getResourceField
(
array
$document
,
string
$field
,
array
$rawContacts
)
{
// TODO test in case type_id is not a real type
if
(
$field
==
'doctypeLabel'
&&
!
empty
(
$document
[
'type_id'
]))
{
if
(
$field
==
'doctypeLabel'
&&
!
empty
(
$document
[
'type_id'
]))
{
return
DoctypeModel
::
getById
([
'select'
=>
[
'description'
],
'id'
=>
$document
[
'type_id'
]])[
'description'
];
return
DoctypeModel
::
getById
([
'select'
=>
[
'description'
],
'id'
=>
$document
[
'type_id'
]])[
'description'
];
}
}
...
@@ -674,5 +670,6 @@ class MultigestController
...
@@ -674,5 +670,6 @@ class MultigestController
return
''
;
return
''
;
}
}
}
}
return
''
;
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment