Commit 29773b1f authored by RTI Almaviva2's avatar RTI Almaviva2

aggiornamento progetto Gestore Pratiche

parent 51c0d26f
ALTER TABLE `procedure_instance_event_queue_item` ADD COLUMN `execution_type` VARCHAR(50) DEFAULT 'unset';
\ No newline at end of file
create or replace table procedure_procedure_report
(
procedure_procedure_report_id bigint auto_increment
primary key,
procedure_id bigint not null,
procedure_report_id bigint not null,
constraint procedure_proc_report_procedure_id_proc_report_id_uindex
unique (procedure_id, procedure_report_id),
constraint procedure_proc_report_proc_report_procedure_report_id_fk
foreign key (procedure_report_id) references procedure_report (procedure_report_id)
on delete cascade,
constraint procedure_procedure_report_procedure_procedure_id_fk
foreign key (procedure_id) references `procedure` (procedure_id)
on delete cascade
);
alter table document_converter drop constraint constraint_name;
alter table document_converter add constraint document_converter_tenant_id_converter_key_uindex unique (tenant_id, converter_key);
alter table procedure_report add column report_key varchar(50) not null;
alter table procedure_report add constraint procedure_report_tenant_id_report_key_uindex unique(tenant_id, report_key);
alter table procedure_report_compiled_content_snapshot add column report_key varchar(50) not null;
alter table procedure_report_compiled_content_snapshot add constraint proc_rep_compiled_content_snap_ten_id_proc_pub_id_rep_key_uindex unique(tenant_id, procedure_publication_id, report_key);
create or replace table procedure_instance_importer_log
(
procedure_instance_importer_log_id bigint auto_increment
primary key,
procedure_instance_importer_id bigint not null,
name varchar(255) not null,
user varchar(255) not null,
content longblob not null,
created_at timestamp default current_timestamp() not null,
constraint proc_inst_imp_log_proc_inst_imp_proc_inst_imp_id_fk
foreign key (procedure_instance_importer_id) references procedure_instance_importer (procedure_instance_importer_id)
on delete cascade
);
create or replace index procedure_instance_importer_log_name_index
on procedure_instance_importer_log (name);
alter table procedure_instance_protocol add column configuration varchar(4096);
\ No newline at end of file
## Adding new user store
Access identity server.
Click on left menu Main. Select item User stores\Add.
Add new user store:
- Class: org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager
- Domain name: it.almaviva.gestionepratiche.identity
- Connection URL: mysql//host:port/simelusermanager
- Connection name and password are MySQL server credentials
- Driver name: com.mysql.jdbc.Driver (IMPORTANT: copy driver mysql-connector-java-5.1.49.jar in IS repository/components/lib folder)
- Disable write group
See img1.png for reference.
## Adding a resident identity provider
More information at https://docs.wso2.com/display/IS560/Adding+and+Configuring+an+Identity+Provider
Access identity server.
Click on left menu Main. Select item Identity providers\Resident.
Base section
- Home realm identifier: localhost
- Idle session timeout: 15
- Remember me period: 20160
Inbound Authentication Configuration section. Expand "OAuth2/OpenID Connect Configuration".
Just change Inbound Authentication Configuration > OAuth/OpenID Connect Configuration setting Identity provider
Entity ID to http://identityserver:9763/oauth2/oidcdiscovery
Check if OIDC discovery document is reachable at https://localhost:9443/oauth2/oidcdiscovery/.well-known/openid-configuration
## Adding a service provider
More information at https://docs.wso2.com/display/IS570/Adding+and+Configuring+a+Service+Provider
Access identity server.
Click on left menu Main. Select item Service providers\Add.
Base section
- Service provider name: it.almaviva.gestionepratiche.sp (click on Register button)
- Select SP Certificate Type: Upload SP certificate
- Application certificate: <use cert.pem file under this folder>
- Inbound authentication configuration > OAuth/OpenID Connect Configuration: add new application
- Left everything untouched
- Flag Allow authentication without the client secret must be enabled
- Callback URL: http://localhost:8080/gestionepratiche/login/oauth2/code/idsvr
## Adding new user
Access identity server.
Click on left menu Main. Select item Users and roles.
Add new user.
- Domain: it.almaviva.gestionepratiche.identity
- Username: test12345
- Password: test12345
Left roles untouched.
## Adding new user organization claim to OIDC
Under Claims for dialect http://wso2.org/oidc/claim, add a new external claim called "organization":
- Claim URI: organization
- Mapped local claim: http://wso2.org/claims/organization
Add the claim to the OIDC profile scope under OIDC Scopes menu item.
-----BEGIN CERTIFICATE-----
MIIDazCCAlOgAwIBAgIUBoBxcH/e2xthohKjSA6srss/CKcwDQYJKoZIhvcNAQEL
BQAwRTELMAkGA1UEBhMCSVQxDjAMBgNVBAgMBUl0YWx5MQ8wDQYDVQQHDAZWZW5p
Y2UxFTATBgNVBAoMDEFsbWF2aXZhIFNwQTAeFw0yMTAxMTUyMjM4MzNaFw0zMTAx
MTMyMjM4MzNaMEUxCzAJBgNVBAYTAklUMQ4wDAYDVQQIDAVJdGFseTEPMA0GA1UE
BwwGVmVuaWNlMRUwEwYDVQQKDAxBbG1hdml2YSBTcEEwggEiMA0GCSqGSIb3DQEB
AQUAA4IBDwAwggEKAoIBAQDiDceQx/OktF/ZfNrT/yexETi5ixOJzx5ye3rTUwvM
OfKa80aLqPTtJlKhD4S9zi2y7uPReaixZZ9EDPeSDqiv0gOJ0dUxd48bCtc+AzjC
0cld8EHcOSk9uA8GoGosDJbVxybq0uWMO46GPf4wgxLMnZWNSuqQO/cH2Mre+993
cR5uDEKY6WvekhNrpBSL7jT8zZgo+wD6hrYqz6E+uaJ9rQ9e1EKAgWkkxY7ihYsy
wHP4/V/bqOgR42rdZiiwCDVxSLWQazapTVxPzvIDROUUNWhU+5lkCGCCT3/mMkZt
36cZgOV/tA4sMAFXqKFv9bxhFvFqAE8Y2TL0wJGkeA5nAgMBAAGjUzBRMB0GA1Ud
DgQWBBQ9Et0enXYp7B0OI/KIQLWkecdXtjAfBgNVHSMEGDAWgBQ9Et0enXYp7B0O
I/KIQLWkecdXtjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBs
Mw8CGTTwMZF90JXso21R17G28IZ1SLnDMWjwD7CzbdS1iC0Fh7Yvr1/aH8SeuEu4
ZqUlUnLomIqrv6fE8Y/G3pxp0Rf7IMaNdu1LmRCGluqBkCsnsiiCCoC4yVbpQ80K
+Mena3i0xJHBmd1Mx8g7kUUc+VmpErPV1/YrRC6DvFLM6CnEH3iRer0Vgh6s5ByF
GOWhdXrj4Ua/laW1+ayHk5mN1dK4qGAKrwCNtNOBptL02M1hootZEwq+OT/21oZx
/g4DLBj305qbV5EDPo3NXQE8qljyU8obcEvTcS/gKvB6HlufBEoWZlIHw+74S4aF
vUiOvJtPsufdQLO9S6cr
-----END CERTIFICATE-----
-----BEGIN PRIVATE KEY-----
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDiDceQx/OktF/Z
fNrT/yexETi5ixOJzx5ye3rTUwvMOfKa80aLqPTtJlKhD4S9zi2y7uPReaixZZ9E
DPeSDqiv0gOJ0dUxd48bCtc+AzjC0cld8EHcOSk9uA8GoGosDJbVxybq0uWMO46G
Pf4wgxLMnZWNSuqQO/cH2Mre+993cR5uDEKY6WvekhNrpBSL7jT8zZgo+wD6hrYq
z6E+uaJ9rQ9e1EKAgWkkxY7ihYsywHP4/V/bqOgR42rdZiiwCDVxSLWQazapTVxP
zvIDROUUNWhU+5lkCGCCT3/mMkZt36cZgOV/tA4sMAFXqKFv9bxhFvFqAE8Y2TL0
wJGkeA5nAgMBAAECggEBALPCB2dfSaU49luJiK46YcLRkg0hxji5JlodTS/NAz20
+vIy8G9QvOv0pJKFN6aD1R1MEIfcOcRPrlW8Bgb0dznRRJUM8n6yt27msQEUKMfr
cTitPII2RlBZFEHNwIAkxrFa+9ySNo3MMmsX0xGauZFS4sEHyP1HYgqwX6rwGeTs
5YlAO/FQNUXFYl7Lk31UP05PBQpqLC7mRaWAL+8rqXP9aqrcD4xlypkZcIefuDee
jIFUwdrZjuCGfB2w5pO79l9sZkf/aeF0u/ova+Yj4heSlhTXBvOvYzk8ghSTzo+r
e5KO1U+HlMvuIp6yosMAJ7gDB0sen/eGrDStSQmB8gkCgYEA84lVx+iRgiA0qcks
/HuGz4eTZXgn1wBStpKTKpdzEh9KgEl3f676iQ9WFe++WQ2TuvDhZIAcoeu1Awox
vI3v4ZR8rde0++ozJNgayhiEk195s/tnWV6bjhJm1uOF5J/Zh0tP3akH/NY+4S0K
3q20rOSYAtw40RDxeGuNvM+/OS0CgYEA7Z9lz1feaVfnGKuvifHDRrHlf/oz1BeE
WEVkfG7vPcqK8aQHctco1L3xnlM35wkqmZ+ik1puS86/O+77tuif2F9ZmgKc2AB3
WaClI41cfzck7QFa73ZZrLaTxo1UulNPy+KOOcyE5Wh+47FqfB44lBc3kNK6PR2A
RNjvpL3L+mMCgYEAmnAFDfjWDYcO3nzNIm/TVdfMCRThbt6tlUnuOZxBRMTDIgd0
2GvGRRSMquyV8TNC89G9nVYA0k3/RCY61C/OZ2caicO46efi9wJ0OqTBrhNlwlUz
fOEaFEZnIO64Afu8nqeLxi1i+1uCFJnTwtK1OM7d9zJgdXQhLRRHlezIfyECgYEA
vnoFrH1tJdh2wQnuvo7zz9mOdFXl8d+gEPofILf0Qv32/thTuDTM4CwaYKWorCRm
55pVQfU9cLscBDj/wZEbgOB9/LyXaXaGNWxWs/b+7GMR0IJDmKywGYiJUKG+B1X9
IxxKkf5lkVeAT5jKGRBInj02J3skGxVo2sdi4hXaSq0CgYAQE7SRBcm9xpP12Go2
dbqk18XNoFwHqLWgY9Mq9LpVCiyD5MB7IaYkuotagWXAGQShW/IZuIUjtiaCg4O8
9/fb1LK8HPPNUlq3JJuwmOYLOUfpdRtc+PzHKJJjpjm0PzosAiXFu/mLEcJjoHg+
BRE/AUwLtgKsM52qsIrYUFcx3g==
-----END PRIVATE KEY-----
@startuml (id=set-procedure-instance-status)
autonumber
autoactivate on
title Scenario generazione numero di protocollo
!$a = 1
!include generate-protocol-number-header.iuml!header
== Generazione numero di protocollo ==
workflowEngine->backend: POST /bpm/protocolnumber/generate
note left
{
externalProcedureInstanceId: <externalProcedureInstanceId>,
generateProtocolNumberModel: {
servicePluginProtocolDelegateUniqueIdentifier: <servicePluginProtocolDelegateUniqueIdentifier>,
generateSubProtocols: <generateSubProtocols>
}
}
end note
note right
il backend chiama il servizio di protocollazione per generare il numero di protocollo
end note
backend->database: salvataggio del numero di protocollo della istanza di procedura
backend --> workflowEngine: HTTP 200
note left
{
status: <HTTP.status>,
item: null
}
end note
@enduml
\ No newline at end of file
@startuml (id=header)
autonumber
autoactivate on
actor "Worklfow Engine" as workflowEngine
participant "Backend Gestione Pratiche" as backend
database "Database Gestione Pratiche" as database
@enduml
@startuml (id=set-procedure-instance-status)
autonumber
autoactivate on
title Scenario generazione report di procedura
!$a = 1
!include generate-report-header.iuml!header
== Generazione report di procedura ==
workflowEngine->backend: POST /bpm/procedure/report/generate
note left
{
externalProcedureInstanceId: <externalProcedureInstanceId>,
resolveNameConflicts: <resolveNameConflicts>
}
end note
note right
il backend genera il report tramite il componente jasper-report
end note
backend->documentale: salvataggio del report nel documentale
documentale-->backend: il documentale ritorna il file
backend --> workflowEngine: HTTP 200
note left
{
status: <HTTP.status>,
item: null
}
end note
@enduml
\ No newline at end of file
@startuml (id=header)
autonumber
autoactivate on
actor "Worklfow Engine" as workflowEngine
participant "Backend Gestione Pratiche" as backend
database "Documentale" as documentale
@enduml
@startuml (id=header)
autonumber
autoactivate on
actor "front end user" as frontend
participant "Backend Gestione Pratiche" as backend
database "Database Mongo Gestione Pratiche" as database
@enduml
\ No newline at end of file
@startuml (id=set-procedure-instance-status)
autonumber
autoactivate on
title Scenario ricerca avanzata tramite query builder
!$a = 1
!include search-query-builder-header.iuml!header
== Ricerca avanzata tramite query builder ==
frontend->backend: GET /search/procedure/querybuilder
note left
{
queryData: <queryData>,
sortList: <sortList>,
sortByList: <sortByList>,
page: <page>,
size: <size>
}
end note
note right
Il backend tramite un parser crea la query mongo, comprensibile per mongodb
end note
backend->database: esecuzione della query in mongodb
database-->backend: <Page<indexed_procedure_instance>>
backend --> frontend: HTTP 200
note left
{
status: <HTTP.status>,
item: {
items: <procedure_instance>
totalItems: <total_items>
}
}
end note
@enduml
\ No newline at end of file
@startuml (id=header)
autonumber
autoactivate on
actor "external System" as ext
participant "Backend Gestione Pratiche" as backend
database "Database Gestione Pratiche" as database
@enduml
@startuml (id=set-procedure-instance-status)
autonumber
autoactivate on
title Scenario set stato istanza di procedura API Gestione Pratiche
!$a = 1
!include set-procedure-instance-status-header.iuml!header
== Set stato istanza di procedura ==
ext->backend: POST /status
note left
{
procedureInstanceId: <procedure_instance_id>,
status: <status>
}
end note
backend->database: recupero istanza di procedura
note right
SELECT procedure_instance
FROM procedure_instance
WHERE procedure_instance_id = <procedureInstanceId>
end note
database-->backend: <procedure_instance>
backend --> ext: HTTP 200
note left
{
status: <HTTP.status>,
item: null
}
end note
@enduml
\ No newline at end of file
@startuml (id=signal-all-instances-sync)
autonumber
autoactivate on
!include signal-header.iuml!header
== Invio segnale su tutte le istanze ==
ext->backend: POST /signal
note left
{
name: <signal_name>,
procedureInstanceIds: [<procedure_instance_id>]
procedureId: <procedure_id>,
variables: [<process_variable>]
}
end note
backend->database: carica istanze workflow
note right
SELECT external_procedure_instance_id
FROM procedure_instance
WHERE procedure_publication_id IN
(
SELECT procedure_publication_id
FROM procedure_publication
WHERE procedure_id=<procedureId>
)
end note
database-->backend: list<external_procedure_instance_id>
loop for each executionId in list
backend->workflowEngine: /signal
note right
{
name: <signal_name>,
executionId: <executionId>,
variables: [<process_variable>]
}
end note
workflowEngine-->backend: HTTP 200
end loop
backend-->ext: HTTP 200
note left
{
status: <HTTP.status>,
item: [{
procedureInstanceId: <procedure_instance_id>
message: <error_message>
}]
}
end note
@enduml
\ No newline at end of file
@startuml (id=signal-broadcast)
autonumber
autoactivate on
!include signal-header.iuml!header
== Invio segnale broadcast ==
ext->backend: POST /signal
note left
{
name: <signal_name>,
variables: [<process_variable>]
}
end note
backend->workflowEngine: /signal
note right
{
name: <signal_name>,
variables: [<process_variable>]
}
end note
workflowEngine -->backend: HTTP 200
backend --> ext: HTTP 200
note left
{
status: <HTTP.status>,
item: [{
procedureInstanceId: null
message: <error_message>
}]
}
end note
@enduml
\ No newline at end of file
@startuml (id=header)
autonumber
autoactivate on
actor "external System" as ext
participant "Backend Gestione Pratiche" as backend
participant "Workflow Engine" as workflowEngine
database "Database Gestione Pratiche" as database
@enduml
@startuml (id=signal-one-instance)
autonumber
autoactivate on
!include signal-header.iuml!header
== Invio segnale su singola istanza ==
ext->backend: POST /signal
note left
{
name: <signal_name>,
procedureInstanceId: <procedure_instance_id>,
variables: [<process_variable>]
}
end note
backend->database: carica l'istanza del workflow
note right
SELECT external_procedure_instance_id
FROM procedure_instance
WHERE procedure_instance_id = <procedureInstanceId>
end note
database-->backend: <external_procedure_instance_id>
backend->workflowEngine: /signal
note right
{
name: <signal_name>,
executionId: <external_procedure_instance_id>,
variables: [<process_variable>]
}
end note
workflowEngine-->backend: HTTP 200
backend --> ext: HTTP 200
note left
{
status: <HTTP.status>,
item: null
}
end note
@enduml
\ No newline at end of file
@startuml signal-all
title Scenari invio segnale API Gestione Pratiche
!$a = 1
!include signal-header.iuml!header
!include signal-all-instances.puml
!include signal-one-instance.puml
!include signal-broadcast.puml
@enduml
......@@ -13,6 +13,6 @@ export const environment = {
backendUrl: 'https://api-gateway.comune.salerno.it/gestionepratiche/v1/api/proceduretask/file/',
authenticationMethod: 'apiGatewayAuthentication'
},
version: '2.1.2',
version: '2.1.6',
language: 'it',
};
......@@ -13,6 +13,6 @@ export const environment = {
backendUrl: 'https://test-api-gateway.comune.salerno.it/gestionepratiche/v1/api/proceduretask/file/',
authenticationMethod: 'apiGatewayAuthentication'
},
version: '2.1.2',
version: '2.1.6',
language: 'it',
};
......@@ -9,31 +9,50 @@ import it.almaviva.gestionepratiche.data.entities.FormModuleMetadataField;
import org.springframework.data.repository.query.Param;
/**
*
* @author Paolo Bertuzzo
* The interface Form module metadata field repository.
*
* @author Paolo Bertuzzo
*/
public interface FormModuleMetadataFieldRepository extends CrudRepository<FormModuleMetadataField, Long> {
/**
*
* @param formModuleId
* @return
* Find all by form module id iterable.
*
* @param formModuleId the form module id
* @return iterable iterable
*/
Iterable<FormModuleMetadataField> findAllByFormModuleId(final long formModuleId);
/**
*
* @param formModuleIds
* @return
* Find by form module id iterable.
*
* @param formModuleId the form module id
* @return the iterable
*/
Iterable<it.almaviva.gestionepratiche.data.interfaces.FormModuleMetadataField> findByFormModuleId(final long formModuleId);
/**
* Find all by form module ids iterable.
*
* @param formModuleIds the form module ids
* @return iterable iterable
*/
@Query("select fmmf from FormModuleMetadataField fmmf where fmmf.formModule.id in (:formModuleIds)")
Iterable<FormModuleMetadataField> findAllByFormModuleIds(@Param("formModuleIds") final List<Long> formModuleIds);
/**
* Find by form module ids iterable.
*
* @param formModuleIds the form module ids
* @return the iterable
*/
@Query("select fmmf from FormModuleMetadataField fmmf where fmmf.formModule.id in (:formModuleIds)")
Iterable<FormModuleMetadataField> findAllByFormModuleIds(@Param("formModuleIds")
final List<Long> formModuleIds);
@Query("select fmmf from FormModuleMetadataField fmmf where fmmf.formModule.id in (:formModuleIds)")
Iterable<it.almaviva.gestionepratiche.data.interfaces.FormModuleMetadataField> findByFormModuleIds(@Param("formModuleIds") final List<Long> formModuleIds);
/**
*
* @param formModuleId
* Delete by form module id.
*
* @param formModuleId the form module id
*/
void deleteByFormModuleId(final long formModuleId);
......
......@@ -8,30 +8,51 @@ import org.springframework.data.repository.query.Param;
import java.util.List;
/**
* The interface Form module process field repository.
*
* @author Carlo Sindico
*
*/
public interface FormModuleProcessFieldRepository extends CrudRepository<FormModuleProcessField, Long> {
/**
* Find all by form module id iterable.
*
* @param formModuleId
* @return
* @param formModuleId the form module id
* @return iterable
*/
Iterable<FormModuleProcessField> findAllByFormModuleId(final long formModuleId);
/**
* Find all by form module ids iterable.
*
* @param formModuleIds
* @return
* @param formModuleIds the form module ids
* @return iterable
*/
@Query("select fmmf from FormModuleProcessField fmmf where fmmf.formModule.id in (:formModuleIds)")
Iterable<FormModuleProcessField> findAllByFormModuleIds(@Param("formModuleIds")
final List<Long> formModuleIds);
/**
* Find all by form module ids iterable.
*
* @param formModuleIds the form module ids
* @return iterable
*/
@Query("select fmmf from FormModuleProcessField fmmf where fmmf.formModule.id in (:formModuleIds)")
List<it.almaviva.gestionepratiche.data.interfaces.FormModuleProcessField> findByFormModuleIds(
@Param("formModuleIds") final List<Long> formModuleIds);
/**
* Find form module id iterable.
*
* @param formModuleId the form module id
* @return the iterable
*/
List<it.almaviva.gestionepratiche.data.interfaces.FormModuleProcessField> findByFormModuleId(final long formModuleId);
/**
* Delete by form module id.
*
* @param formModuleId
* @param formModuleId the form module id
*/
void deleteByFormModuleId(final long formModuleId);
}
......@@ -10,26 +10,41 @@ import org.springframework.data.repository.query.Param;
import java.sql.Timestamp;
/**
*
* @author Paolo Bertuzzo
* The interface Procedure instance event queue item repository.
*
* @author Paolo Bertuzzo
*/
public interface ProcedureInstanceEventQueueItemRepository extends CrudRepository<ProcedureInstanceEventQueueItem, Long> {
/**
*
*/
@Modifying(clearAutomatically = true)
@Query("delete from ProcedureInstanceEventQueueItem p where p.createdAt < :minExpirationTimestamp")
void cleanUpOldEventQueueItems(@Param("minExpirationTimestamp") Timestamp minExpirationTimestamp);
/**
*
* @param tenantId
* @param externalProcedureInstanceId
* @return
*/
Iterable<ProcedureInstanceEventQueueItem> getByTenantIdAndExternalProcedureInstanceIdOrderByCreatedAtAsc(final long tenantId,
final String externalProcedureInstanceId);
/**
* Clean up old event queue items.
*
* @param minExpirationTimestamp the min expiration timestamp
*/
@Modifying(clearAutomatically = true)
@Query("delete from ProcedureInstanceEventQueueItem p where p.createdAt < :minExpirationTimestamp")
void cleanUpOldEventQueueItems(@Param("minExpirationTimestamp") Timestamp minExpirationTimestamp);
/**
* Gets by tenant id and external procedure instance id order by created at asc.
*
* @param tenantId the tenant id
* @param externalProcedureInstanceId the external procedure instance id
* @return by tenant id and external procedure instance id order by created at asc
*/
Iterable<ProcedureInstanceEventQueueItem> getByTenantIdAndExternalProcedureInstanceIdOrderByCreatedAtAsc(final long tenantId,
final String externalProcedureInstanceId);
/**
* Gets by tenant id and external procedure instance id and execution type order by created at asc.
*
* @param tenantId the tenant id
* @param externalProcedureInstanceId the external procedure instance id
* @param executionType the execution type
* @return by tenant id and external procedure instance id and execution type order by created at asc
*/
Iterable<ProcedureInstanceEventQueueItem> getByTenantIdAndExternalProcedureInstanceIdAndExecutionTypeOrderByCreatedAtAsc(final long tenantId,
final String externalProcedureInstanceId,
final String executionType);
}
package it.almaviva.gestionepratiche.data;
import it.almaviva.gestionepratiche.data.entities.ProcedureInstanceImporterLog;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.CrudRepository;
/**
* The interface Procedure instance importer log repository.
*
* @author Carlo Sindico
*/
public interface ProcedureInstanceImporterLogRepository extends CrudRepository<ProcedureInstanceImporterLog, Long> {
/**
* Gets by procedure instance importer id and name contains.
*
* @param procedureInstanceImporterId the procedure instance importer id
* @param name the name
* @param pageable the pageable
* @return the by procedure instance importer id and name contains
*/
Page<it.almaviva.gestionepratiche.data.interfaces.ProcedureInstanceImporterLog> getByProcedureInstanceImporterIdAndNameContains(final long procedureInstanceImporterId, final String name, final Pageable pageable);
/**
* Gets by procedure instance importer id.
*
* @param procedureInstanceImporterId the procedure instance importer id
* @param pageable the pageable
* @return the by procedure instance importer id
*/
Page<it.almaviva.gestionepratiche.data.interfaces.ProcedureInstanceImporterLog> getByProcedureInstanceImporterId(final long procedureInstanceImporterId,
final Pageable pageable);
}
......@@ -21,6 +21,14 @@ public interface ProcedureProcedureDomainRepository extends CrudRepository<Proce
*/
List<ProcedureProcedureDomain> findAllByProcedureId(final long procedureId);
/**
* Find all by procedure id list.
*
* @param procedureId the procedure id
* @return list
*/
List<it.almaviva.gestionepratiche.data.interfaces.ProcedureProcedureDomain> findByProcedureId(final long procedureId);
/**
* Find by procedure id in list.
*
......
package it.almaviva.gestionepratiche.data;
import it.almaviva.gestionepratiche.data.entities.ProcedureProcedureReport;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
/**
* The interface Procedure procedure report repository.
*
* @author Carlo Sindico
*/
public interface ProcedureProcedureReportRepository extends CrudRepository<ProcedureProcedureReport, Long> {
/**
* Find by procedure id list.
*
* @param procedureId the procedure id
* @return the list
*/
List<ProcedureProcedureReport> findAllByProcedureId(final long procedureId);
/**
* Delete all by procedure id.
*
* @param procedureId the procedure id
*/
void deleteAllByProcedureId(final long procedureId);
}
......@@ -20,6 +20,14 @@ public interface ProcedureProcedureStatusRepository extends CrudRepository<Proce
*/
List<ProcedureProcedureStatus> findAllByProcedureId(final long procedureId);
/**
* Find by procedure id list.
*
* @param procedureId the procedure id
* @return the list
*/
List<it.almaviva.gestionepratiche.data.interfaces.ProcedureProcedureStatus> findByProcedureId(final long procedureId);
/**
* Delete all by procedure id.
*
......
......@@ -3,31 +3,55 @@ package it.almaviva.gestionepratiche.data;
import it.almaviva.gestionepratiche.data.entities.ProcedureReportCompiledContentSnapshot;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
import java.util.Optional;
/**
*
* The interface Procedure report compiled content snapshot repository.
*
* @author Carlo Sindico
*
*/
public interface ProcedureReportCompiledContentSnapshotRepository extends CrudRepository<ProcedureReportCompiledContentSnapshot, Long> {
/**
* Find by tenant id and procedure report id and procedure publication id optional.
*
* @param tenantId
* @param procedureReportId
* @param procedurePublicationId
* @return
* @param tenantId the tenant id
* @param procedureReportId the procedure report id
* @param procedurePublicationId the procedure publication id
* @return optional optional
*/
Optional<ProcedureReportCompiledContentSnapshot> findByTenantIdAndProcedureReportIdAndProcedurePublicationId(final long tenantId,
final long procedureReportId,
final long procedurePublicationId);
/**
* Find by tenant id and report key and procedure publication id optional.
*
* @param tenantId the tenant id
* @param reportKey the report key
* @param procedurePublicationId the procedure publication id
* @return the optional
*/
Optional<ProcedureReportCompiledContentSnapshot> findByTenantIdAndReportKeyAndProcedurePublicationId(final long tenantId,
final String reportKey,
final long procedurePublicationId);
/**
* Find by tenant id and procedure publication id list.
*
* @param tenantId the tenant id
* @param procedurePublicationId the procedure publication id
* @return the list
*/
List<ProcedureReportCompiledContentSnapshot> findByTenantIdAndProcedurePublicationId(final long tenantId, final long procedurePublicationId);
/**
* Delete by tenant id and procedure publication id.
*
* @param tenantId
* @param procedurePublicationId
* @param tenantId the tenant id
* @param procedurePublicationId the procedure publication id
*/
void deleteByTenantIdAndProcedurePublicationId(final long tenantId, final long procedurePublicationId);
}
package it.almaviva.gestionepratiche.data;
import it.almaviva.gestionepratiche.data.entities.DocumentConverter;
import it.almaviva.gestionepratiche.data.entities.ProcedureReport;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
......@@ -25,6 +26,15 @@ public interface ProcedureReportRepository extends CrudRepository<ProcedureRepor
*/
Optional<ProcedureReport> findByTenantIdAndId(final long tenantId, final long id);
/**
*
* @param tenantId
* @param key
* @return
*/
Optional<it.almaviva.gestionepratiche.data.interfaces.ProcedureReport> findByTenantIdAndReportKey(final long tenantId, final String key);
/**
*
* @param tenantId
......
......@@ -19,6 +19,13 @@ public interface ProcedureVariablePermissionRepository extends CrudRepository<Pr
*/
Iterable<ProcedureVariablePermission> findAllByProcedureId(final long procedureId);
/**
*
* @param procedureId
* @return
*/
Iterable<it.almaviva.gestionepratiche.data.interfaces.ProcedureVariablePermission> findByProcedureId(final long procedureId);
/**
* @param tenantId
* @param procedureId
......
......@@ -12,7 +12,9 @@ import java.sql.Timestamp;
*
*/
@Entity
@Table(name = "document_converter")
@Table(name = "document_converter", uniqueConstraints = {
@UniqueConstraint(columnNames = { "tenant_id", "converter_key" }) }, indexes = {
@Index(columnList = "tenant_id, converter_key") })
public class DocumentConverter implements Serializable {
/**
......@@ -41,7 +43,7 @@ public class DocumentConverter implements Serializable {
/**
*/
@Column(name="converter_key", nullable = false, unique = true)
@Column(name="converter_key", nullable = false)
private String converterKey;
/**
......
......@@ -18,9 +18,9 @@ import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
/**
* The type Procedure instance event queue item.
*
* @author Paolo Bertuzzo
*
*/
@Entity
@Table(name = "procedure_instance_event_queue_item")
......@@ -65,6 +65,12 @@ public class ProcedureInstanceEventQueueItem implements Serializable {
@Column(name = "action_value", nullable = false)
private String actionValue;
/**
*
*/
@Column(name = "execution_type", nullable = true)
private String executionType;
/**
*/
@Column(name = "created_at", nullable = false)
......@@ -72,6 +78,8 @@ public class ProcedureInstanceEventQueueItem implements Serializable {
private Timestamp createdAt;
/**
* Gets id.
*
* @return the id
*/
public Long getId() {
......@@ -79,6 +87,8 @@ public class ProcedureInstanceEventQueueItem implements Serializable {
}
/**
* Sets id.
*
* @param id the id to set
*/
public void setId(Long id) {
......@@ -86,6 +96,8 @@ public class ProcedureInstanceEventQueueItem implements Serializable {
}
/**
* Gets tenant.
*
* @return the tenant
*/
public Tenant getTenant() {
......@@ -93,6 +105,8 @@ public class ProcedureInstanceEventQueueItem implements Serializable {
}
/**
* Sets tenant.
*
* @param tenant the tenant to set
*/
public void setTenant(Tenant tenant) {
......@@ -100,6 +114,8 @@ public class ProcedureInstanceEventQueueItem implements Serializable {
}
/**
* Gets external procedure instance id.
*
* @return the externalProcedureInstanceId
*/
public String getExternalProcedureInstanceId() {
......@@ -107,6 +123,8 @@ public class ProcedureInstanceEventQueueItem implements Serializable {
}
/**
* Sets external procedure instance id.
*
* @param externalProcedureInstanceId the externalProcedureInstanceId to set
*/
public void setExternalProcedureInstanceId(String externalProcedureInstanceId) {
......@@ -114,6 +132,8 @@ public class ProcedureInstanceEventQueueItem implements Serializable {
}
/**
* Gets action type.
*
* @return the actionType
*/
public String getActionType() {
......@@ -121,6 +141,8 @@ public class ProcedureInstanceEventQueueItem implements Serializable {
}
/**
* Sets action type.
*
* @param actionType the actionType to set
*/
public void setActionType(String actionType) {
......@@ -128,6 +150,8 @@ public class ProcedureInstanceEventQueueItem implements Serializable {
}
/**
* Gets action value.
*
* @return the actionValue
*/
public String getActionValue() {
......@@ -135,6 +159,8 @@ public class ProcedureInstanceEventQueueItem implements Serializable {
}
/**
* Sets action value.
*
* @param actionValue the actionValue to set
*/
public void setActionValue(String actionValue) {
......@@ -142,6 +168,8 @@ public class ProcedureInstanceEventQueueItem implements Serializable {
}
/**
* Gets created at.
*
* @return the createdAt
*/
public Timestamp getCreatedAt() {
......@@ -149,10 +177,30 @@ public class ProcedureInstanceEventQueueItem implements Serializable {
}
/**
* Sets created at.
*
* @param createdAt the createdAt to set
*/
public void setCreatedAt(Timestamp createdAt) {
this.createdAt = createdAt;
}
/**
* Gets execution type.
*
* @return the execution type
*/
public String getExecutionType() {
return executionType;
}
/**
* Sets execution type.
*
* @param executionType the execution type
*/
public void setExecutionType(String executionType) {
this.executionType = executionType;
}
}
......@@ -39,6 +39,22 @@ public class ProcedureInstanceImporter implements Serializable {
@Column(name = "procedure_instance_importer_id")
private Long id;
/**
*
*/
@OneToOne(fetch = FetchType.EAGER)
@Fetch(FetchMode.JOIN)
@JoinColumn(name = "procedure_id", referencedColumnName = "procedure_id")
private Procedure procedure;
/**
*
*/
@OneToOne(fetch = FetchType.EAGER)
@Fetch(FetchMode.JOIN)
@JoinColumn(name = "tenant_id", referencedColumnName = "tenant_id")
private Tenant tenant;
/**
*
*/
......@@ -78,21 +94,6 @@ public class ProcedureInstanceImporter implements Serializable {
@CreationTimestamp
private Timestamp updatedAt;
/**
*
*/
@OneToOne(fetch = FetchType.EAGER)
@Fetch(FetchMode.JOIN)
@JoinColumn(name = "procedure_id", referencedColumnName = "procedure_id")
private Procedure procedure;
/**
*
*/
@OneToOne(fetch = FetchType.EAGER)
@Fetch(FetchMode.JOIN)
@JoinColumn(name = "tenant_id", referencedColumnName = "tenant_id")
private Tenant tenant;
/**
* Gets id.
......
package it.almaviva.gestionepratiche.data.entities;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* The type Procedure instance importer log.
*
* @author Carlo Sindico
*/
@Entity
@Table(name = "procedure_instance_importer_log")
public class ProcedureInstanceImporterLog implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
*
*/
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "procedure_instance_importer_log_id")
private Long id;
/**
*
*/
@OneToOne(fetch = FetchType.EAGER)
@Fetch(FetchMode.JOIN)
@JoinColumn(name = "procedure_instance_importer_id", referencedColumnName = "procedure_instance_importer_id")
private ProcedureInstanceImporter procedureInstanceImporter;
/**
*
*/
@Column(name = "name", nullable = false)
private String name;
/**
*
*/
@Column(name = "user", nullable = false)
private String user;
/**
*
*/
@Column(name = "content", nullable = false)
private byte[] content;
/**
*
*/
@Column(name = "created_at", nullable = false)
@CreationTimestamp
private Timestamp createdAt;
/**
* Gets id.
*
* @return the id
*/
public Long getId() {
return id;
}
/**
* Sets id.
*
* @param id the id
*/
public void setId(Long id) {
this.id = id;
}
/**
* Gets procedure instance importer.
*
* @return the procedure instance importer
*/
public ProcedureInstanceImporter getProcedureInstanceImporter() {
return procedureInstanceImporter;
}
/**
* Sets procedure instance importer.
*
* @param procedureInstanceImporter the procedure instance importer
*/
public void setProcedureInstanceImporter(ProcedureInstanceImporter procedureInstanceImporter) {
this.procedureInstanceImporter = procedureInstanceImporter;
}
/**
* Gets name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Sets name.
*
* @param name the name
*/
public void setName(String name) {
this.name = name;
}
/**
* Get content byte [ ].
*
* @return the byte [ ]
*/
public byte[] getContent() {
return content;
}
/**
* Sets content.
*
* @param content the content
*/
public void setContent(byte[] content) {
this.content = content;
}
/**
* Gets created at.
*
* @return the created at
*/
public Timestamp getCreatedAt() {
return createdAt;
}
/**
* Sets created at.
*
* @param createdAt the created at
*/
public void setCreatedAt(Timestamp createdAt) {
this.createdAt = createdAt;
}
/**
* Gets user.
*
* @return the user
*/
public String getUser() {
return user;
}
/**
* Sets user.
*
* @param user the user
*/
public void setUser(String user) {
this.user = user;
}
}
......@@ -8,6 +8,7 @@ import java.io.Serializable;
/**
* The type Procedure instance protocol.
*
* @author Carlo Sindico
*/
@Entity
......@@ -42,6 +43,12 @@ public class ProcedureInstanceProtocol implements Serializable {
@Column(name = "protocol_number", nullable = false)
private String protocolNumber;
/**
*
*/
@Column(name = "configuration", nullable = true)
private String configuration;
/**
* Gets id.
*
......@@ -96,5 +103,23 @@ public class ProcedureInstanceProtocol implements Serializable {
this.protocolNumber = protocolNumber;
}
/**
* Gets configuration.
*
* @return the configuration
*/
public String getConfiguration() {
return configuration;
}
/**
* Sets configuration.
*
* @param configuration the configuration
*/
public void setConfiguration(String configuration) {
this.configuration = configuration;
}
}
package it.almaviva.gestionepratiche.data.entities;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import javax.persistence.*;
/**
* The type Procedure procedure report.
* @author Carlo Sindico
*/
@Entity
@Table(name = "procedure_procedure_report", uniqueConstraints = {
@UniqueConstraint(columnNames = {"procedure_id", "procedure_report_id"})},
indexes = {
@Index(columnList = "procedure_id, procedure_report_id")
})
public class ProcedureProcedureReport {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
*
*/
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "procedure_procedure_report_id")
private Long id;
/**
*
*/
@OneToOne(fetch = FetchType.EAGER)
@Fetch(FetchMode.JOIN)
@JoinColumn(name = "procedure_id", referencedColumnName = "procedure_id")
private Procedure procedure;
/**
*
*/
@OneToOne(fetch = FetchType.EAGER)
@Fetch(FetchMode.JOIN)
@JoinColumn(name = "procedure_report_id", referencedColumnName = "procedure_report_id")
private ProcedureReport procedureReport;
/**
* Gets id.
*
* @return the id
*/
public Long getId() {
return id;
}
/**
* Sets id.
*
* @param id the id
*/
public void setId(Long id) {
this.id = id;
}
/**
* Gets procedure.
*
* @return the procedure
*/
public Procedure getProcedure() {
return procedure;
}
/**
* Sets procedure.
*
* @param procedure the procedure
*/
public void setProcedure(Procedure procedure) {
this.procedure = procedure;
}
/**
* Gets procedure report.
*
* @return the procedure report
*/
public ProcedureReport getProcedureReport() {
return procedureReport;
}
/**
* Sets procedure report.
*
* @param procedureReport the procedure report
*/
public void setProcedureReport(ProcedureReport procedureReport) {
this.procedureReport = procedureReport;
}
}
......@@ -14,7 +14,9 @@ import java.sql.Timestamp;
* @author Carlo Sindico
*/
@Entity
@Table(name = "procedure_report")
@Table(name = "procedure_report", uniqueConstraints = {
@UniqueConstraint(columnNames = { "tenant_id", "report_key" }) }, indexes = {
@Index(columnList = "tenant_id, report_key") })
public class ProcedureReport implements Serializable {
/**
......@@ -44,6 +46,9 @@ public class ProcedureReport implements Serializable {
@Column(name = "name", nullable = false)
private String name;
@Column(name = "report_key", nullable = false)
private String reportKey;
/**
*
*/
......@@ -193,4 +198,23 @@ public class ProcedureReport implements Serializable {
public Timestamp getCreatedAt() {
return createdAt;
}
/**
* Gets report key.
*
* @return the report key
*/
public String getReportKey() {
return reportKey;
}
/**
* Sets report key.
*
* @param reportKey the report key
*/
public void setReportKey(String reportKey) {
this.reportKey = reportKey;
}
}
......@@ -50,6 +50,12 @@ public class ProcedureReportCompiledContentSnapshot implements Serializable {
@Column(name = "procedure_report_id", nullable = false)
private Long procedureReportId;
/**
*
*/
@Column(name = "report_key", nullable = false)
private String reportKey;
/**
*
*/
......@@ -194,4 +200,23 @@ public class ProcedureReportCompiledContentSnapshot implements Serializable {
public void setUseDatasource(Boolean useDatasource) {
this.useDatasource = useDatasource;
}
/**
* Gets report key.
*
* @return the report key
*/
public String getReportKey() {
return reportKey;
}
/**
* Sets report key.
*
* @param reportKey the report key
*/
public void setReportKey(String reportKey) {
this.reportKey = reportKey;
}
}
package it.almaviva.gestionepratiche.data.interfaces;
/**
* The interface Form module.
* @author Carlo Sindico
*/
public interface FormModule {
Long getId();
}
package it.almaviva.gestionepratiche.data.interfaces;
public interface FormModuleMetadataField {
Long getId();
FormModule getFormModule();
String getFieldName();
}
package it.almaviva.gestionepratiche.data.interfaces;
/**
* The interface Form module process field.
* @author Carlo Sindico
*/
public interface FormModuleProcessField {
Long getId();
FormModule getFormModule();
String getFieldName();
}
package it.almaviva.gestionepratiche.data.interfaces;
/**
* The interface Procedure domain.
* @author Carlo Sindico
*/
public interface ProcedureDomain {
Long getId();
String getName();
String getValue();
Long parentId();
}
package it.almaviva.gestionepratiche.data.interfaces;
import java.util.Date;
public interface ProcedureInstanceImporterLog {
long getId();
String getName();
String getUser();
Date getCreatedAt();
}
package it.almaviva.gestionepratiche.data.interfaces;
/**
* The interface Procedure procedure domain.
* @author Carlo Sindico
*/
public interface ProcedureProcedureDomain {
Long getId();
ProcedureDomain getProcedureDomain();
}
package it.almaviva.gestionepratiche.data.interfaces;
/**
* The interface Procedure procedure status.
* @author Carlo Sindico
*/
public interface ProcedureProcedureStatus {
Long getId();
ProcedureProcedureStatusType getProcedureProcedureStatusType();
}
package it.almaviva.gestionepratiche.data.interfaces;
/**
* The interface Procedure procedure status type.
* @author Carlo Sindico
*/
public interface ProcedureProcedureStatusType {
Long getId();
String getKey();
String getLabel();
}
......@@ -23,6 +23,13 @@ public interface ProcedureReport {
*/
String getName();
/**
* Gets report key.
*
* @return the report key
*/
String getReportKey();
/**
* Gets use datasource.
*
......
package it.almaviva.gestionepratiche.data.interfaces;
/**
* The interface Procedure variable permission.
* @author Carlo Sindico
*/
public interface ProcedureVariablePermission {
Long getId();
String getVariableName();
int getPermission();
String getCustomType();
}
......@@ -264,6 +264,35 @@ public class AlfrescoCmDocumentManager extends AlfrescoCmManager
}
}
/*
*
*/
@Override
public InputStream downloadDocument(final long tenantId, final long procedureInstanceId, final String name) {
Optional<Document> documentWithName = getDocumentsByProcedureInstanceId(tenantId, procedureInstanceId)
.stream()
.filter(d -> {
return d.getName().equals(name);
})
.findFirst();
if (!documentWithName.isPresent())
throw new IllegalArgumentException(String.format("Document with name %s does not exists for procedure instance id %s", name, procedureInstanceId));
try {
Session session = createSession();
org.apache.chemistry.opencmis.client.api.Document document = (org.apache.chemistry.opencmis.client.api.Document)
session.getObject(documentWithName.get().getId());
ContentStream contentStream = document.getContentStream();
return contentStream.getStream();
} catch (CmisObjectNotFoundException e) {
throw new IllegalArgumentException(String.format("Document with name %s does not exists for procedure instance id %s", name, procedureInstanceId), e);
}
}
/*
*
*/
......
......@@ -88,6 +88,16 @@ public interface DocumentManager<TConfiguration extends ConnectedServiceConfigur
*/
InputStream downloadDocument(final long tenantId, final String path, final String name);
/**
* Download document input stream.
*
* @param tenantId the tenant id
* @param procedureInstanceId the procedure instance id
* @param name the name
* @return input stream
*/
InputStream downloadDocument(final long tenantId, final long procedureInstanceId, final String name);
/**
*
* @param tenantId
......
......@@ -348,6 +348,27 @@ public class EmbeddedDocumentManager
return new ByteArrayInputStream(content.get().getContent());
}
/*
*
*/
@Override
public InputStream downloadDocument(final long tenantId, final long procedureInstanceId, final String name) {
Optional<LatestDocumentObjectNode> document = latestNodeRepository
.findByProcedureInstanceIdAndName(String.valueOf(procedureInstanceId), name);
if (!document.isPresent())
throw new IllegalStateException(
String.format("Cannot find object document for tenant id %s and procedure instance id %s and name %s", tenantId, procedureInstanceId, name));
Optional<DocumentObjectNodeContent> content = nodeContentRepository.findByDocumentObjectNodeId(document.get().getId());
if (!content.isPresent())
throw new IllegalStateException(
String.format("Cannot find object document content for tenant id %s and procedure instance id %s and name %s", tenantId, procedureInstanceId, name));
return new ByteArrayInputStream(content.get().getContent());
}
/*
*
*/
......
......@@ -7,21 +7,33 @@ import org.springframework.data.repository.CrudRepository;
import it.almaviva.gestionepratiche.connectors.document.embedded.data.entitites.LatestDocumentObjectNode;
import java.util.List;
import java.util.Optional;
/**
*
* @author Paolo Bertuzzo
* The interface Latest document object node repository.
*
* @author Paolo Bertuzzo
*/
public interface LatestDocumentObjectNodeRepository extends CrudRepository<LatestDocumentObjectNode, Long> {
/**
*
* @param procedureInstanceId
* @param variableIdentifiers
* @return
* Find by procedure instance id and variable identifier in page.
*
* @param procedureInstanceId the procedure instance id
* @param variableIdentifiers the variable identifiers
* @param pageable the pageable
* @return page
*/
Page<LatestDocumentObjectNode> findByProcedureInstanceIdAndVariableIdentifierIn(final String procedureInstanceId,
final List<String> variableIdentifiers, final Pageable pageable);
final List<String> variableIdentifiers, final Pageable pageable);
/**
* Find by procedure instance id and name optional.
*
* @param procedureInstanceId the procedure instance id
* @param name the name
* @return optional
*/
Optional<LatestDocumentObjectNode> findByProcedureInstanceIdAndName(final String procedureInstanceId, final String name);
}
package it.almaviva.gestionepratiche.serviceplugins.models;
/**
*
* @author Paolo Bertuzzo
* The type Protocol response.
*
* @author Paolo Bertuzzo
*/
public class ProtocolResponse {
private String protocolNumber;
private String protocolDate;
private String protocolYear;
private String protocolMessage;
private String protocolError;
/**
* Gets protocol number.
*
* @return the protocolNumber
*/
public String getProtocolNumber() {
......@@ -21,6 +24,8 @@ public class ProtocolResponse {
}
/**
* Sets protocol number.
*
* @param protocolNumber the protocolNumber to set
*/
public void setProtocolNumber(String protocolNumber) {
......@@ -28,6 +33,8 @@ public class ProtocolResponse {
}
/**
* Gets protocol date.
*
* @return the protocolDate
*/
public String getProtocolDate() {
......@@ -35,6 +42,8 @@ public class ProtocolResponse {
}
/**
* Sets protocol date.
*
* @param protocolDate the protocolDate to set
*/
public void setProtocolDate(String protocolDate) {
......@@ -42,6 +51,8 @@ public class ProtocolResponse {
}
/**
* Gets protocol year.
*
* @return the protocolYear
*/
public String getProtocolYear() {
......@@ -49,10 +60,48 @@ public class ProtocolResponse {
}
/**
* Sets protocol year.
*
* @param protocolYear the protocolYear to set
*/
public void setProtocolYear(String protocolYear) {
this.protocolYear = protocolYear;
}
/**
* Gets protocol message.
*
* @return the protocol message
*/
public String getProtocolMessage() {
return protocolMessage;
}
/**
* Sets protocol message.
*
* @param protocolMessage the protocol message
*/
public void setProtocolMessage(String protocolMessage) {
this.protocolMessage = protocolMessage;
}
/**
* Gets protocol error.
*
* @return the protocol error
*/
public String getProtocolError() {
return protocolError;
}
/**
* Sets protocol error.
*
* @param protocolError the protocol error
*/
public void setProtocolError(String protocolError) {
this.protocolError = protocolError;
}
}
package it.almaviva.gestionepratiche.models;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The type Document protocol model.
......@@ -10,7 +12,7 @@ import java.util.List;
public class DocumentProtocolModel {
private String protocolNumber;
private HashMap<String, String> protocolConfiguration;
private List<String> documentIdList;
/**
......@@ -49,4 +51,23 @@ public class DocumentProtocolModel {
this.documentIdList = documentIdList;
}
/**
* Gets protocol configuration.
*
* @return the protocol configuration
*/
public Map<String, String> getProtocolConfiguration() {
return protocolConfiguration;
}
/**
* Sets protocol configuration.
*
* @param protocolConfiguration the protocol configuration
*/
public void setProtocolConfiguration(HashMap<String, String> protocolConfiguration) {
this.protocolConfiguration = protocolConfiguration;
}
}
package it.almaviva.gestionepratiche.models;
/**
* The type Dynamic report model.
*
* @author Carlo Sindico
*/
public class DynamicReportModel {
private String reportIdentifier;
private String fileName;
private String variableName;
private boolean useDataSource;
private boolean resolveNameConflicts;
/**
* Gets report identifier.
*
* @return the report identifier
*/
public String getReportIdentifier() {
return reportIdentifier;
}
/**
* Sets report identifier.
*
* @param reportIdentifier the report identifier
*/
public void setReportIdentifier(String reportIdentifier) {
this.reportIdentifier = reportIdentifier;
}
/**
* Gets file name.
*
* @return the file name
*/
public String getFileName() {
return fileName;
}
/**
* Sets file name.
*
* @param fileName the file name
*/
public void setFileName(String fileName) {
this.fileName = fileName;
}
/**
* Gets variable name.
*
* @return the variable name
*/
public String getVariableName() {
return variableName;
}
/**
* Sets variable name.
*
* @param variableName the variable name
*/
public void setVariableName(String variableName) {
this.variableName = variableName;
}
/**
* Gets resolve name conflicts.
*
* @return the resolve name conflicts
*/
public boolean getResolveNameConflicts() {
return resolveNameConflicts;
}
/**
* Sets resolve name conflicts.
*
* @param resolveNameConflicts the resolve name conflicts
*/
public void setResolveNameConflicts(boolean resolveNameConflicts) {
this.resolveNameConflicts = resolveNameConflicts;
}
/**
* Is use data source boolean.
*
* @return the boolean
*/
public boolean isUseDataSource() {
return useDataSource;
}
/**
* Sets use data source.
*
* @param useDataSource the use data source
*/
public void setUseDataSource(boolean useDataSource) {
this.useDataSource = useDataSource;
}
}
......@@ -15,6 +15,8 @@ public class ProcedureDetailModel extends ProcedureModel {
private List<ProcedureProcedureStatusModel> procedureProcedureStatusModels;
private List<ProcedureProcedureReportModel> procedureProcedureReportModels;
/**
* Gets procedure variables.
*
......@@ -69,4 +71,22 @@ public class ProcedureDetailModel extends ProcedureModel {
this.procedureProcedureStatusModels = procedureProcedureStatusModels;
}
/**
* Gets procedure procedure report models.
*
* @return the procedure procedure report models
*/
public List<ProcedureProcedureReportModel> getProcedureProcedureReportModels() {
return procedureProcedureReportModels;
}
/**
* Sets procedure procedure report models.
*
* @param procedureProcedureReportModels the procedure procedure report models
*/
public void setProcedureProcedureReportModels(List<ProcedureProcedureReportModel> procedureProcedureReportModels) {
this.procedureProcedureReportModels = procedureProcedureReportModels;
}
}
package it.almaviva.gestionepratiche.models;
/**
* The enum Procedure instance event queue item execution type.
*
* @author Carlo Sindico
*/
public enum ProcedureInstanceEventQueueItemExecutionType {
/**
* Unset procedure instance event queue item execution type.
*/
UNSET("unset"),
/**
* At end procedure instance event queue item execution type.
*/
AT_END("at_end");
private final String value;
/**
* @param value
*/
ProcedureInstanceEventQueueItemExecutionType(final String value) {
this.value = value;
}
/*
*
*/
@Override
public String toString() {
return value;
}
}
package it.almaviva.gestionepratiche.models;
import java.util.Date;
/**
* The type Procedure instance importer log model.
* @author Carlo Sindico
*/
public class ProcedureInstanceImporterLogModel {
private Long id;
private String name;
private String user;
private Date createdAt;
/**
* Gets name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Sets name.
*
* @param name the name
*/
public void setName(String name) {
this.name = name;
}
/**
* Gets created at.
*
* @return the created at
*/
public Date getCreatedAt() {
return createdAt;
}
/**
* Sets created at.
*
* @param createdAt the created at
*/
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
/**
* Gets id.
*
* @return the id
*/
public Long getId() {
return id;
}
/**
* Sets id.
*
* @param id the id
*/
public void setId(Long id) {
this.id = id;
}
/**
* Gets user.
*
* @return the user
*/
public String getUser() {
return user;
}
/**
* Sets user.
*
* @param user the user
*/
public void setUser(String user) {
this.user = user;
}
}
package it.almaviva.gestionepratiche.models;
import java.util.HashMap;
/**
* The type Procedure instance protocol model.
*
* @author Carlo Sindico
*/
public class ProcedureInstanceProtocolModel {
private Long id;
private long procedureInstanceId;
private String protocolNumber;
private HashMap<String, String> protocolConfiguration;
/**
* Gets id.
......@@ -64,4 +67,23 @@ public class ProcedureInstanceProtocolModel {
public void setProtocolNumber(String protocolNumber) {
this.protocolNumber = protocolNumber;
}
/**
* Gets protocol configuration.
*
* @return the protocol configuration
*/
public HashMap<String, String> getProtocolConfiguration() {
return protocolConfiguration;
}
/**
* Sets protocol configuration.
*
* @param protocolConfiguration the protocol configuration
*/
public void setProtocolConfiguration(HashMap<String, String> protocolConfiguration) {
this.protocolConfiguration = protocolConfiguration;
}
}
package it.almaviva.gestionepratiche.models;
/**
* The type Procedure procedure report model.
* @author Carlo Sindico
*/
public class ProcedureProcedureReportModel {
private long procedureId;
private long procedureReportId;
/**
* Gets procedure id.
*
* @return the procedure id
*/
public long getProcedureId() {
return procedureId;
}
/**
* Sets procedure id.
*
* @param procedureId the procedure id
*/
public void setProcedureId(long procedureId) {
this.procedureId = procedureId;
}
/**
* Gets procedure report id.
*
* @return the procedure report id
*/
public long getProcedureReportId() {
return procedureReportId;
}
/**
* Sets procedure report id.
*
* @param procedureReportId the procedure report id
*/
public void setProcedureReportId(long procedureReportId) {
this.procedureReportId = procedureReportId;
}
}
......@@ -13,6 +13,8 @@ public class ProcedureReportModel {
private String name;
private String key;
private boolean useDatasource;
private String content;
......@@ -128,4 +130,23 @@ public class ProcedureReportModel {
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
/**
* Gets key.
*
* @return the key
*/
public String getKey() {
return key;
}
/**
* Sets key.
*
* @param key the key
*/
public void setKey(String key) {
this.key = key;
}
}
package it.almaviva.gestionepratiche.models;
import java.util.HashMap;
import java.util.List;
/**
......@@ -8,7 +9,8 @@ import java.util.List;
public class RegisterDocumentModel {
private String protocolNumber;
private List<String> documentIds;
private HashMap<String, String> protocolConfiguration;
private List<String> documentNames;
/**
......@@ -30,20 +32,39 @@ public class RegisterDocumentModel {
}
/**
* Gets document ids.
* Gets document names.
*
* @return the document ids
* @return the document names
*/
public List<String> getDocumentIds() {
return documentIds;
public List<String> getDocumentNames() {
return documentNames;
}
/**
* Sets document ids.
* Sets document names.
*
* @param documentIds the document ids
* @param documentNames the document names
*/
public void setDocumentIds(List<String> documentIds) {
this.documentIds = documentIds;
public void setDocumentNames(List<String> documentNames) {
this.documentNames = documentNames;
}
/**
* Gets protocol configuration.
*
* @return the protocol configuration
*/
public HashMap<String, String> getProtocolConfiguration() {
return protocolConfiguration;
}
/**
* Sets protocol configuration.
*
* @param protocolConfiguration the protocol configuration
*/
public void setProtocolConfiguration(HashMap<String, String> protocolConfiguration) {
this.protocolConfiguration = protocolConfiguration;
}
}
package it.almaviva.gestionepratiche.models.mappers;
import com.github.rozidan.springboot.modelmapper.TypeMapConfigurer;
import it.almaviva.gestionepratiche.data.entities.ProcedureInstance;
import it.almaviva.gestionepratiche.data.entities.ProcedureInstanceProtocol;
import it.almaviva.gestionepratiche.models.ProcedureInstanceProtocolModel;
import org.modelmapper.TypeMap;
import org.springframework.stereotype.Component;
/**
* The type Procedure instance protocol model mapper.
* @author Carlo Sindico
*/
@Component
public class ProcedureInstanceProtocolModelMapper
extends TypeMapConfigurer<ProcedureInstanceProtocol, ProcedureInstanceProtocolModel> {
/*
*
*/
@Override
public void configure(final TypeMap<ProcedureInstanceProtocol, ProcedureInstanceProtocolModel> typeMap) {
typeMap.addMapping(ProcedureInstanceProtocol::getId, ProcedureInstanceProtocolModel::setId);
typeMap.addMapping(ProcedureInstanceProtocol::getProtocolNumber, ProcedureInstanceProtocolModel::setProtocolNumber);
typeMap.addMapping(ProcedureInstanceProtocol::getConfiguration, ProcedureInstanceProtocolModel::setProtocolConfiguration);
typeMap.setPostConverter(context -> {
ProcedureInstance procedureInstance = context.getSource().getProcedureInstance();
context.getDestination().setProcedureInstanceId(procedureInstance.getId());
return context.getDestination();
});
}
}
\ No newline at end of file
package it.almaviva.gestionepratiche.models.mappers;
import com.github.rozidan.springboot.modelmapper.TypeMapConfigurer;
import it.almaviva.gestionepratiche.data.entities.ProcedureReport;
import it.almaviva.gestionepratiche.models.ProcedureReportModel;
import org.modelmapper.TypeMap;
import org.springframework.stereotype.Component;
/**
* The type Procedure report model mapper.
* @author Carlo Sindico
*/
@Component
public class ProcedureReportModelMapper
extends TypeMapConfigurer<ProcedureReport, ProcedureReportModel> {
/*
*
*/
@Override
public void configure(final TypeMap<ProcedureReport, ProcedureReportModel> typeMap) {
typeMap.addMapping(ProcedureReport::getId, ProcedureReportModel::setId);
typeMap.addMapping(ProcedureReport::getReportKey, ProcedureReportModel::setKey);
typeMap.addMapping(ProcedureReport::getUseDatasource, ProcedureReportModel::setUseDatasource);
typeMap.addMapping(ProcedureReport::getName, ProcedureReportModel::setName);
typeMap.addMapping(ProcedureReport::getCreatedAt, ProcedureReportModel::setCreatedAt);
typeMap.addMapping(ProcedureReport::getUpdatedAt, ProcedureReportModel::setUpdatedAt);
}
}
package it.almaviva.gestionepratiche.models.mappers;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.rozidan.springboot.modelmapper.TypeMapConfigurer;
import org.modelmapper.TypeMap;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* The type String to hash map mapper.
* @author Carlo Sindico
*/
@Component
public class StringToHashMapMapper
extends TypeMapConfigurer<String, HashMap<String,String>> {
/*
*
*/
@Override
public void configure(final TypeMap<String, HashMap<String,String>> typeMap) {
typeMap.setPostConverter(context -> {
try {
ObjectMapper mapper = new ObjectMapper();
Map<String, String> result = mapper.readValue(context.getSource(), new TypeReference<HashMap<String, String>>() {});
context.getDestination().putAll(result);
return context.getDestination();
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
});
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import it.almaviva.gestionepratiche.data.ProcedureInstanceEventQueueItemReposito
import it.almaviva.gestionepratiche.data.TenantRepository;
import it.almaviva.gestionepratiche.data.entities.ProcedureInstanceEventQueueItem;
import it.almaviva.gestionepratiche.data.entities.Tenant;
import it.almaviva.gestionepratiche.models.ProcedureInstanceEventQueueItemExecutionType;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Optional;
......@@ -17,7 +18,8 @@ public abstract class BpmServiceTask {
private ProcedureInstanceEventQueueItemRepository repository;
protected void createItem(final long tenantId, final String externalProcedureInstanceId,
final String actionType, final String actionValue) {
final String actionType, final String actionValue,
final ProcedureInstanceEventQueueItemExecutionType type) {
Optional<Tenant> tenant = tenantRepository.findById(tenantId);
if (!tenant.isPresent())
......@@ -29,6 +31,7 @@ public abstract class BpmServiceTask {
item.setActionType(actionType);
item.setExternalProcedureInstanceId(externalProcedureInstanceId);
item.setTenant(tenant.get());
item.setExecutionType(type.toString());
repository.save(item);
}
......
package it.almaviva.gestionepratiche.services;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mysql.cj.util.StringUtils;
import it.almaviva.gestionepratiche.connectors.ServiceFactory;
......@@ -14,10 +15,7 @@ import it.almaviva.gestionepratiche.data.*;
import it.almaviva.gestionepratiche.data.entities.*;
import it.almaviva.gestionepratiche.document.converters.DocumentConverterFactory;
import it.almaviva.gestionepratiche.document.converters.models.ConvertedDocument;
import it.almaviva.gestionepratiche.models.DocumentBase64Model;
import it.almaviva.gestionepratiche.models.DocumentSaveModel;
import it.almaviva.gestionepratiche.models.DocumentsConverterModel;
import it.almaviva.gestionepratiche.models.RegisterDocumentModel;
import it.almaviva.gestionepratiche.models.*;
import it.almaviva.gestionepratiche.services.instanceeventhandlers.ProcedureInstanceEvent;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
......@@ -91,7 +89,7 @@ public class BpmServiceTaskDelegateDocumentServiceImpl extends BpmServiceTask im
log.info("Renaming documents folder for tenant id {} and external procedure instance id {}", tenantId, externalProcedureInstanceId);
this.createItem(tenantId, externalProcedureInstanceId, ProcedureInstanceEvent.RENAME_DOCUMENTS_FOLDER.toString(),
newName);
newName, ProcedureInstanceEventQueueItemExecutionType.UNSET);
}
/*
......@@ -440,44 +438,102 @@ public class BpmServiceTaskDelegateDocumentServiceImpl extends BpmServiceTask im
throw new IllegalArgumentException(String.format("Protocol number already exists for procedure instance id %s",
procedureInstance.get().getId()));
// Save procedure instance protocol
ProcedureInstanceProtocol procedureInstanceProtocol = new ProcedureInstanceProtocol();
procedureInstanceProtocol.setProcedureInstance(procedureInstance.get());
procedureInstanceProtocol.setProtocolNumber(registerDocumentModel.getProtocolNumber());
procedureInstanceProtocolRepository.save(procedureInstanceProtocol);
DocumentManager documentManager = (DocumentManager) serviceFactory.createInstance(DocumentManager.class, tenantId);
// Retrieve procedure instance documents
List<Document> documents = documentManager.getDocumentsByProcedureInstanceId(tenantId, procedureInstance.get().getId());
List<String> documentIds = registerDocumentModel.getDocumentIds();
List<String> documentNames = registerDocumentModel.getDocumentNames();
// Filter documents by input
if (documentIds != null) {
documents = documents.stream().filter(d -> documentIds.contains(d.getId())).collect(Collectors.toList());
if (documentNames != null) {
documents = documents.stream().filter(d -> documentNames.contains(d.getName())).collect(Collectors.toList());
}
// Save documents associated with generated protocol number
documents.forEach(d -> {
DocumentProtocol documentProtocol = new DocumentProtocol();
ObjectMapper objectMapper = new ObjectMapper();
if (!documents.isEmpty()) {
if (procedureInstance.get().getProtocolNumber() == null) {
procedureInstance.get().setProtocolNumber(registerDocumentModel.getProtocolNumber());
// Rename the procedure instance folder using the generated protocol number
String procedureInstanceFolder = documentManager.renameFolder(tenantId, procedureInstance.get().getDocumentsBasePath(), registerDocumentModel.getProtocolNumber());
procedureInstance.get().setDocumentsBasePath(procedureInstanceFolder);
procedureInstanceRepository.save(procedureInstance.get());
// Save procedure instance protocol
ProcedureInstanceProtocol procedureInstanceProtocol = new ProcedureInstanceProtocol();
procedureInstanceProtocol.setProcedureInstance(procedureInstance.get());
procedureInstanceProtocol.setProtocolNumber(registerDocumentModel.getProtocolNumber());
// Save protocol configuration
if (registerDocumentModel.getProtocolConfiguration() != null) {
try {
procedureInstanceProtocol.setConfiguration(objectMapper.writeValueAsString(registerDocumentModel.getProtocolConfiguration()));
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
procedureInstanceProtocolRepository.save(procedureInstanceProtocol);
// Save documents associated with generated protocol number
documents.forEach(d -> {
DocumentProtocol documentProtocol = new DocumentProtocol();
documentProtocol.setProcedureInstanceProtocol(procedureInstanceProtocol);
documentProtocol.setDocumentId(d.getId());
documentProtocol.setProcedureInstanceProtocol(procedureInstanceProtocol);
documentProtocol.setDocumentId(d.getId());
documentProtocolRepository.save(documentProtocol);
});
documentProtocolRepository.save(documentProtocol);
});
} else {
Optional<ProcedureInstanceProtocol> procedureInstanceProtocolNumber = procedureInstanceProtocolRepository
.findByProcedureInstanceIdAndProtocolNumber(procedureInstance.get().getId(), registerDocumentModel.getProtocolNumber());
if (procedureInstanceProtocolNumber.isPresent())
throw new IllegalStateException(String.format("Protocol number %s for procedure instance id %s already exists",
procedureInstance.get().getId(), registerDocumentModel.getProtocolNumber()));
// Save procedure instance protocol
ProcedureInstanceProtocol procedureInstanceProtocol = new ProcedureInstanceProtocol();
procedureInstanceProtocol.setProcedureInstance(procedureInstance.get());
procedureInstanceProtocol.setProtocolNumber(registerDocumentModel.getProtocolNumber());
// Save protocol configuration
if (registerDocumentModel.getProtocolConfiguration() != null) {
try {
procedureInstanceProtocol.setConfiguration(objectMapper.writeValueAsString(registerDocumentModel.getProtocolConfiguration()));
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
procedureInstanceProtocolRepository.save(procedureInstanceProtocol);
// Save documents associated with generated protocol number
documents.forEach(d -> {
DocumentProtocol documentProtocol = new DocumentProtocol();
documentProtocol.setProcedureInstanceProtocol(procedureInstanceProtocol);
documentProtocol.setDocumentId(d.getId());
documentProtocolRepository.save(documentProtocol);
});
}
}
}
@Override
@Transactional(propagation = Propagation.REQUIRED)
public void registerDocumentsAsync(final long tenantId, final String externalProcedureInstanceId, final RegisterDocumentModel registerDocumentModel) {
log.info("Registering documents for tenant id {} and external procedure instance id {}", tenantId, externalProcedureInstanceId);
try {
this.createItem(tenantId, externalProcedureInstanceId, ProcedureInstanceEvent.REGISTER_DOCUMENTS.toString(),
new ObjectMapper().writeValueAsString(registerDocumentModel));
new ObjectMapper().writeValueAsString(registerDocumentModel), ProcedureInstanceEventQueueItemExecutionType.AT_END);
} catch (Exception e) {
throw new IllegalArgumentException(String.format("Error registering documents for tenant id" +
" %s and external procedure instance id %s", tenantId, externalProcedureInstanceId));
......
package it.almaviva.gestionepratiche.services;
import it.almaviva.gestionepratiche.models.DynamicReportModel;
/**
* The interface Bpm service task delegate report service.
*
* @author Carlo Sindico
*/
public interface BpmServiceTaskDelegateReportService {
/**
* Generate report.
*
* @param tenantId the tenant id
* @param externalProcedureInstanceId the external procedure instance id
* @param resolveNameConflicts the resolve name conflicts
*/
void generateReport(final long tenantId, final String externalProcedureInstanceId,
final Boolean resolveNameConflicts);
/**
* Generate dynamic report.
*
* @param tenantId the tenant id
* @param externalProcedureInstanceId the external procedure instance id
* @param dynamicReportModel the dynamic report model
*/
void generateDynamicReport(final long tenantId, final String externalProcedureInstanceId, final DynamicReportModel dynamicReportModel);
}
package it.almaviva.gestionepratiche.services;
import com.fasterxml.jackson.databind.ObjectMapper;
import it.almaviva.gestionepratiche.models.DynamicReportModel;
import it.almaviva.gestionepratiche.models.ProcedureInstanceEventQueueItemExecutionType;
import it.almaviva.gestionepratiche.services.instanceeventhandlers.ProcedureInstanceEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
* The type Bpm service task delegate report service.
* @author Carlo Sindico
*/
@Service
public class BpmServiceTaskDelegateReportServiceImpl extends BpmServiceTask implements BpmServiceTaskDelegateReportService {
private final Logger log = LoggerFactory.getLogger(this.getClass());
/*
*
*/
@Override
@Transactional(propagation = Propagation.REQUIRED)
public void generateReport(final long tenantId, final String externalProcedureInstanceId, final Boolean resolveNameConflicts) {
log.info("Generating report for tenant id {} and external procedure instance id {}", tenantId, externalProcedureInstanceId);
this.createItem(tenantId, externalProcedureInstanceId, ProcedureInstanceEvent.GENERATE_REPORT.toString(), String.valueOf(resolveNameConflicts),
ProcedureInstanceEventQueueItemExecutionType.AT_END);
}
/*
*
*/
@Override
@Transactional(propagation = Propagation.REQUIRED)
public void generateDynamicReport(final long tenantId, final String externalProcedureInstanceId, final DynamicReportModel dynamicReportModel) {
log.info("Generating dynamic report for tenant id {} and external procedure instance id {}", tenantId, externalProcedureInstanceId);
try {
this.createItem(tenantId, externalProcedureInstanceId, ProcedureInstanceEvent.GENERATE_DYNAMIC_REPORT.toString(),
new ObjectMapper().writeValueAsString(dynamicReportModel), ProcedureInstanceEventQueueItemExecutionType.AT_END);
} catch (Exception e) {
throw new IllegalArgumentException(String.format("Error generating dynamic report for tenant id" +
" %s and external procedure instance id %s", tenantId, externalProcedureInstanceId));
}
}
}
......@@ -72,16 +72,6 @@ public interface BpmServiceTaskDelegateService {
void generateProtocolNumber(final long tenantId, final String externalProcedureInstanceId,
final GenerateProtocolNumberModel generateProtocolNumberModel);
/**
* Generate report.
*
* @param tenantId the tenant id
* @param externalProcedureInstanceId the external procedure instance id
* @param resolveNameConflicts the resolve name conflicts
*/
void generateReport(final long tenantId, final String externalProcedureInstanceId,
final boolean resolveNameConflicts);
/**
* Export procedure instance export procedure instance model.
*
......
......@@ -107,7 +107,7 @@ public class BpmServiceTaskDelegateServiceImpl extends BpmServiceTask implements
log.info("Setting protocol number for tenant id {} and external procedure instance id {}", tenantId, externalProcedureInstanceId);
this.createItem(tenantId, externalProcedureInstanceId, ProcedureInstanceEvent.SET_PROTOCOL_NUMBER.toString(),
protocolNumber);
protocolNumber, ProcedureInstanceEventQueueItemExecutionType.AT_END);
}
/*
......@@ -119,7 +119,7 @@ public class BpmServiceTaskDelegateServiceImpl extends BpmServiceTask implements
final String status) {
log.info("Setting procedure instance status for tenant id {} and external procedure instance id {}", tenantId, externalProcedureInstanceId);
this.createItem(tenantId, externalProcedureInstanceId, ProcedureInstanceEvent.SET_PROCEDURE_STATUS.toString(), status);
this.createItem(tenantId, externalProcedureInstanceId, ProcedureInstanceEvent.SET_PROCEDURE_STATUS.toString(), status, ProcedureInstanceEventQueueItemExecutionType.AT_END);
}
/*
......@@ -132,7 +132,7 @@ public class BpmServiceTaskDelegateServiceImpl extends BpmServiceTask implements
try {
this.createItem(tenantId, externalProcedureInstanceId, ProcedureInstanceEvent.SET_PROCEDURE_VARIABLE.toString(),
new ObjectMapper().writeValueAsString(procedureVariableSetModel));
new ObjectMapper().writeValueAsString(procedureVariableSetModel), ProcedureInstanceEventQueueItemExecutionType.UNSET);
} catch (Exception e) {
throw new IllegalArgumentException(String.format("Error setting procedure instance variables for tenant id" +
" %s and external procedure instance id %s", tenantId, externalProcedureInstanceId));
......@@ -149,7 +149,7 @@ public class BpmServiceTaskDelegateServiceImpl extends BpmServiceTask implements
try {
this.createItem(tenantId, externalProcedureInstanceId, ProcedureInstanceEvent.SYNC_PROCEDURE_VARIABLE.toString(),
new ObjectMapper().writeValueAsString(procedureVariableSyncModel));
new ObjectMapper().writeValueAsString(procedureVariableSyncModel), ProcedureInstanceEventQueueItemExecutionType.UNSET);
} catch (Exception e) {
throw new IllegalArgumentException(String.format("Error synchronizing procedure instance variables for tenant id" +
" %s and external procedure instance id %s", tenantId, externalProcedureInstanceId));
......@@ -167,24 +167,13 @@ public class BpmServiceTaskDelegateServiceImpl extends BpmServiceTask implements
try {
this.createItem(tenantId, externalProcedureInstanceId, ProcedureInstanceEvent.GENERATE_PROTOCOL_NUMBER.toString(),
new ObjectMapper().writeValueAsString(generateProtocolNumberModel));
new ObjectMapper().writeValueAsString(generateProtocolNumberModel), ProcedureInstanceEventQueueItemExecutionType.AT_END);
} catch (Exception e) {
throw new IllegalArgumentException(String.format("Error generating protocol number for tenant id" +
" %s and external procedure instance id %s", tenantId, externalProcedureInstanceId));
}
}
/*
*
*/
@Override
@Transactional(propagation = Propagation.REQUIRED)
public void generateReport(final long tenantId, final String externalProcedureInstanceId, final boolean resolveNameConflicts) {
log.info("Generating report for tenant id {} and external procedure instance id {}", tenantId, externalProcedureInstanceId);
this.createItem(tenantId, externalProcedureInstanceId, ProcedureInstanceEvent.GENERATE_REPORT.toString(), String.valueOf(resolveNameConflicts));
}
/*
*
*/
......
package it.almaviva.gestionepratiche.services;
import it.almaviva.gestionepratiche.data.entities.ProcedureInstanceImporter;
import it.almaviva.gestionepratiche.models.Page;
import it.almaviva.gestionepratiche.models.ProcedureInstanceImporterLogModel;
import org.springframework.core.io.ByteArrayResource;;
/**
* The interface Procedure instance importer log service.
*
* @author Carlo Sindico
*/
public interface ProcedureInstanceImporterLogService {
/**
* Create procedure instance importer log model.
*
* @param tenantId the tenant id
* @param userId the user id
* @param procedureInstanceImporter the procedure instance importer
* @param procedureInstanceImporterLogModel the procedure instance importer log model
* @param content the content
* @return the procedure instance importer log model
*/
ProcedureInstanceImporterLogModel create(final long tenantId, final long userId, final ProcedureInstanceImporter procedureInstanceImporter,
final ProcedureInstanceImporterLogModel procedureInstanceImporterLogModel, final byte[] content);
/**
* Get page.
*
* @param tenantId the tenant id
* @param procedureInstanceImporterId the procedure instance importer id
* @param name the name
* @param page the page
* @param size the size
* @return the page
*/
Page<ProcedureInstanceImporterLogModel> get(final long tenantId, final long procedureInstanceImporterId, final String name,
final int page, final int size);
/**
* Download procedure instance importer log file byte array resource.
*
* @param tenantId the tenant id
* @param procedureInstanceImporterId the procedure instance importer id
* @return the byte array resource
*/
ByteArrayResource downloadProcedureInstanceImporterLogFile(final long tenantId, final long procedureInstanceImporterId);
}
package it.almaviva.gestionepratiche.services;
import com.mysql.cj.util.StringUtils;
import it.almaviva.gestionepratiche.data.ProcedureInstanceImporterLogRepository;
import it.almaviva.gestionepratiche.data.TenantRepository;
import it.almaviva.gestionepratiche.data.UserRepository;
import it.almaviva.gestionepratiche.data.entities.ProcedureInstanceImporter;
import it.almaviva.gestionepratiche.data.entities.ProcedureInstanceImporterLog;
import it.almaviva.gestionepratiche.data.entities.Tenant;
import it.almaviva.gestionepratiche.data.entities.User;
import it.almaviva.gestionepratiche.models.Page;
import it.almaviva.gestionepratiche.models.ProcedureInstanceImporterLogModel;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* The type Procedure instance importer log service.
* @author Carlo Sindico
*/
@Service
public class ProcedureInstanceImporterLogServiceImpl implements ProcedureInstanceImporterLogService {
@Autowired
private TenantRepository tenantRepository;
@Autowired
private UserRepository userRepository;
@Autowired
private ProcedureInstanceImporterLogRepository repository;
@Autowired
private ModelMapper mapper;
/*
*
*/
@Override
@Transactional(propagation = Propagation.REQUIRED)
public ProcedureInstanceImporterLogModel create(final long tenantId, final long userId, final ProcedureInstanceImporter procedureInstanceImporter,
final ProcedureInstanceImporterLogModel procedureInstanceImporterLogModel, final byte[] content) {
final Optional<Tenant> tenant = tenantRepository.findById(tenantId);
if (!tenant.isPresent())
throw new IllegalArgumentException("Invalid tenant id");
Optional<User> user = userRepository.findByTenantIdAndId(tenantId, userId);
if (!user.isPresent())
throw new IllegalArgumentException("invalid user id");
ProcedureInstanceImporterLog procedureInstanceImporterLog = new ProcedureInstanceImporterLog();
procedureInstanceImporterLog.setName(procedureInstanceImporterLogModel.getName());
procedureInstanceImporterLog.setProcedureInstanceImporter(procedureInstanceImporter);
procedureInstanceImporterLog.setUser(user.get().getUsername());
procedureInstanceImporterLog.setContent(content);
procedureInstanceImporterLog.setCreatedAt(new Timestamp(Calendar.getInstance().getTimeInMillis()));
return mapper.map(repository.save(procedureInstanceImporterLog), ProcedureInstanceImporterLogModel.class);
}
/*
*
*/
@Override
public Page<ProcedureInstanceImporterLogModel> get(final long tenantId, final long procedureInstanceImporterId,
final String name, final int page, final int size) {
final Optional<Tenant> tenant = tenantRepository.findById(tenantId);
if (!tenant.isPresent())
throw new IllegalArgumentException("Invalid tenant id");
final org.springframework.data.domain.Page<it.almaviva.gestionepratiche.data.interfaces.ProcedureInstanceImporterLog> results;
if (StringUtils.isNullOrEmpty(name))
results = repository.getByProcedureInstanceImporterId(procedureInstanceImporterId, PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "createdAt")));
else
results = repository.getByProcedureInstanceImporterIdAndNameContains(procedureInstanceImporterId, name, PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "createdAt")));
return new Page<ProcedureInstanceImporterLogModel>() {{
this.setTotalItems(results.getTotalElements());
this.setResults(results
.stream()
.map(piilm -> mapper.map(piilm, ProcedureInstanceImporterLogModel.class))
.collect(Collectors.toList())
);
}};
}
/*
*
*/
@Override
public ByteArrayResource downloadProcedureInstanceImporterLogFile(final long tenantId, final long id) {
final Optional<Tenant> tenant = tenantRepository.findById(tenantId);
if (!tenant.isPresent())
throw new IllegalArgumentException("invalid tenant id");
Optional<ProcedureInstanceImporterLog> procedureInstanceImporterLog = repository.findById(id);
if (!procedureInstanceImporterLog.isPresent())
throw new IllegalArgumentException("invalid entity id");
return new ByteArrayResource(procedureInstanceImporterLog.get().getContent());
}
}
......@@ -63,12 +63,12 @@ public interface ProcedureInstanceImporterService {
final File source);
/**
*
* @param tenantId
* @param procedureInstanceImporterId
* @param source
* @return
*/
ProcedureInstancesImportReport run(final long tenantId, final long procedureInstanceImporterId,
final File source);
* @param tenantId
* @param userId
* @param source
* @param procedureInstanceImporterId
* @return
*/
ProcedureInstancesImportReport run(final long tenantId, final long userId,
final File source, final long procedureInstanceImporterId);
}
package it.almaviva.gestionepratiche.services;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.FileAppender;
import it.almaviva.gestionepratiche.models.*;
import it.almaviva.gestionepratiche.services.importers.ImportErrorType;
import it.almaviva.gestionepratiche.services.importers.ImportGenerateLogError;
import it.almaviva.gestionepratiche.services.logger.LoggerFileAppenderFactory;
import it.almaviva.gestionepratiche.services.logger.ProcedureInstanceImporterLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......@@ -26,13 +35,10 @@ import it.almaviva.gestionepratiche.data.TenantRepository;
import it.almaviva.gestionepratiche.data.entities.Procedure;
import it.almaviva.gestionepratiche.data.entities.ProcedureInstanceImporter;
import it.almaviva.gestionepratiche.data.entities.Tenant;
import it.almaviva.gestionepratiche.models.CsvProcedureInstanceImporterModel;
import it.almaviva.gestionepratiche.models.Page;
import it.almaviva.gestionepratiche.models.ProcedureInstanceImporterModel;
import it.almaviva.gestionepratiche.models.ProcedureInstanceImporterType;
import it.almaviva.gestionepratiche.services.importers.ProcedureInstanceImporterFactory;
import it.almaviva.gestionepratiche.services.importers.ProcedureInstancesImportReport;
import it.almaviva.gestionepratiche.services.importers.mappers.RecordValueMapper;
import org.springframework.transaction.support.TransactionTemplate;
/**
* @author Paolo Bertuzzo
......@@ -40,6 +46,8 @@ import it.almaviva.gestionepratiche.services.importers.mappers.RecordValueMapper
@Service
public class ProcedureInstanceImporterServiceImpl implements ProcedureInstanceImporterService {
private final Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
private TenantRepository tenantRepository;
......@@ -49,9 +57,18 @@ public class ProcedureInstanceImporterServiceImpl implements ProcedureInstanceIm
@Autowired
private ProcedureInstanceImporterRepository procedureInstanceImporterRepository;
@Autowired
private LoggerFileAppenderFactory loggerFileAppenderFactory;
@Autowired
private ProcedureInstanceImporterFactory factory;
@Autowired
private ProcedureInstanceImporterLogService procedureInstanceImporterLogService;
@Autowired
private PlatformTransactionManager transactionManager;
/*
*
*/
......@@ -228,7 +245,7 @@ public class ProcedureInstanceImporterServiceImpl implements ProcedureInstanceIm
*/
@SuppressWarnings("rawtypes")
@Override
public ProcedureInstancesImportReport run(final long tenantId, final long procedureInstanceImporterId, final File source) {
public ProcedureInstancesImportReport run(final long tenantId, long userId, final File source, final long procedureInstanceImporterId) {
final Optional<Tenant> tenant = tenantRepository.findById(tenantId);
if (!tenant.isPresent())
......@@ -247,8 +264,40 @@ public class ProcedureInstanceImporterServiceImpl implements ProcedureInstanceIm
it.almaviva.gestionepratiche.services.importers.ProcedureInstanceImporter importer = factory.getInstance(instanceImporter.get().getType(),
instanceImporter.get().getProcedure().getId(), instanceImporter.get().getImportType(), configuration, mappers);
return importer.run(tenantId, source);
final String fileAppenderName = String.format("RUN-%s-%s.log", instanceImporter.get().getProcedure().getName(), UUID.randomUUID());
ch.qos.logback.classic.Logger logger = loggerFileAppenderFactory.createInstance(ProcedureInstanceImporterLogger.class.getName(), fileAppenderName);
// Run importer
ProcedureInstancesImportReport procedureInstancesImportReport = importer.run(tenantId, userId, source, logger);
TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
// Save Procedure instance importer log
transactionTemplate.executeWithoutResult((transaction) -> {
try {
FileAppender<ILoggingEvent> fileAppender = (FileAppender<ILoggingEvent>) logger.getAppender(fileAppenderName);
fileAppender.stop();
ProcedureInstanceImporterLogModel procedureInstanceImporterLogModel = new ProcedureInstanceImporterLogModel();
procedureInstanceImporterLogModel.setName(fileAppenderName);
procedureInstanceImporterLogService.create(tenantId, userId, instanceImporter.get(),
procedureInstanceImporterLogModel, Files.readAllBytes(new File(fileAppender.getFile()).toPath()));
} catch (IOException e) {
log.error("An error occurred while saving log file", e);
ImportGenerateLogError importGenerateLogError = new ImportGenerateLogError();
importGenerateLogError.setImportErrorType(ImportErrorType.GENERATE_LOG_ERROR);
importGenerateLogError.setMessage(e.getMessage());
procedureInstancesImportReport.setImportGenerateLogError(importGenerateLogError);
transaction.setRollbackOnly();
}
});
return procedureInstancesImportReport;
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
......
......@@ -12,6 +12,7 @@ import it.almaviva.gestionepratiche.connectors.document.models.Document;
import it.almaviva.gestionepratiche.connectors.workflow.models.AssigneeType;
import it.almaviva.gestionepratiche.connectors.workflow.models.ProcessVariable;
import it.almaviva.gestionepratiche.connectors.workflow.models.Requester;
import org.springframework.core.io.InputStreamResource;
/**
* The interface Procedure instance service.
......@@ -76,9 +77,10 @@ public interface ProcedureInstanceService {
*
* @param tenantId the tenant id
* @param procedureInstanceId the procedure instance id
* @param userId the user id
* @param variables the variables
*/
void update(final long tenantId, final long procedureInstanceId, final List<ProcessVariable> variables);
void update(final long tenantId, final long userId, final long procedureInstanceId, final List<ProcessVariable> variables);
/**
* Update status.
......@@ -201,6 +203,17 @@ public interface ProcedureInstanceService {
ByteArrayResource downloadProcedureInstanceDocument(final long tenantId, final String requesterIdentifier,
final String documentId, final boolean isCheckIdentifier) throws IOException;
/**
* Download procedure instance document input stream resource.
*
* @param tenantId the tenant id
* @param procedureInstanceId the procedure instance id
* @param documentName the document name
* @return input stream resource
* @throws IOException the io exception
*/
ByteArrayResource downloadProcedureInstanceDocument(final long tenantId, final long procedureInstanceId, final String documentName) throws IOException;
/**
* Gets document versions.
*
......
......@@ -7,7 +7,9 @@ import java.util.Optional;
import java.util.stream.Collectors;
import it.almaviva.gestionepratiche.data.ProcedureReportCompiledContentSnapshotRepository;
import it.almaviva.gestionepratiche.data.entities.DocumentConverter;
import it.almaviva.gestionepratiche.data.entities.ProcedureReportCompiledContentSnapshot;
import it.almaviva.gestionepratiche.services.exceptions.InvalidDocumentConverterException;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ByteArrayResource;
......@@ -57,7 +59,15 @@ public class ProcedureReportServiceImpl implements ProcedureReportService {
ProcedureReport procedureReport = mapper.map(procedureReportModel, ProcedureReport.class);
final Optional<it.almaviva.gestionepratiche.data.interfaces.ProcedureReport> report = repository
.findByTenantIdAndReportKey(tenantId, procedureReportModel.getKey());
if (report.isPresent())
throw new InvalidDocumentConverterException(String.format("Procedure report with key %s already defined",
procedureReportModel.getKey()));
procedureReport.setTenant(tenant.get());
procedureReport.setReportKey(procedureReportModel.getKey());
procedureReport.setCreatedAt(new Timestamp(Calendar.getInstance().getTimeInMillis()));
return mapper.map(repository.save(procedureReport), ProcedureReportModel.class);
......@@ -80,7 +90,15 @@ public class ProcedureReportServiceImpl implements ProcedureReportService {
throw new IllegalArgumentException(
String.format("Invalid procedure report id %s", procedureReportModel.getId()));
final Optional<it.almaviva.gestionepratiche.data.interfaces.ProcedureReport> report = repository
.findByTenantIdAndReportKey(tenantId, procedureReportModel.getKey());