add indicator access global filters and reset indicator event
This commit is contained in:
parent
0e983f04e5
commit
b30f26588d
|
@ -172,8 +172,9 @@ public class AuditableAction {
|
||||||
public static final EventId Maintenance_SendReferenceTypeAccountingEntriesEvents = new EventId(230011, "Maintenance_SendReferenceTypeAccountingEntriesEvents");
|
public static final EventId Maintenance_SendReferenceTypeAccountingEntriesEvents = new EventId(230011, "Maintenance_SendReferenceTypeAccountingEntriesEvents");
|
||||||
public static final EventId Maintenance_SendUserAccountingEntriesEvents = new EventId(230012, "Maintenance_SendUserAccountingEntriesEvents");
|
public static final EventId Maintenance_SendUserAccountingEntriesEvents = new EventId(230012, "Maintenance_SendUserAccountingEntriesEvents");
|
||||||
public static final EventId Maintenance_SendIndicatorCreateEntryEvents = new EventId(230013, "Maintenance_SendIndicatorCreateEntryEvents");
|
public static final EventId Maintenance_SendIndicatorCreateEntryEvents = new EventId(230013, "Maintenance_SendIndicatorCreateEntryEvents");
|
||||||
public static final EventId Maintenance_SendIndicatorAccessEntryEvents = new EventId(230014, "Maintenance_SendIndicatorAccessEntryEvents");
|
public static final EventId Maintenance_SendIndicatorResetEntryEvents = new EventId(230014, "Maintenance_SendIndicatorResetEntryEvents");
|
||||||
public static final EventId Maintenance_SendIndicatorPointEntryEvents = new EventId(230015, "Maintenance_SendIndicatorPointEntryEvents");
|
public static final EventId Maintenance_SendIndicatorAccessEntryEvents = new EventId(230015, "Maintenance_SendIndicatorAccessEntryEvents");
|
||||||
|
public static final EventId Maintenance_SendIndicatorPointEntryEvents = new EventId(230016, "Maintenance_SendIndicatorPointEntryEvents");
|
||||||
|
|
||||||
|
|
||||||
public static final EventId Principal_Lookup = new EventId(240000, "Principal_Lookup");
|
public static final EventId Principal_Lookup = new EventId(240000, "Principal_Lookup");
|
||||||
|
|
|
@ -40,6 +40,8 @@ public class OutboxIntegrationEvent extends IntegrationEvent {
|
||||||
|
|
||||||
public static final String INDICATOR_ENTRY = "INDICATOR_ENTRY";
|
public static final String INDICATOR_ENTRY = "INDICATOR_ENTRY";
|
||||||
|
|
||||||
|
public static final String INDICATOR_RESET_ENTRY = "INDICATOR_RESET_ENTRY";
|
||||||
|
|
||||||
private TrackedEvent event;
|
private TrackedEvent event;
|
||||||
|
|
||||||
public TrackedEvent getEvent() {
|
public TrackedEvent getEvent() {
|
||||||
|
|
|
@ -40,6 +40,8 @@ public class OutboxProperties {
|
||||||
|
|
||||||
private final String indicatorTopic;
|
private final String indicatorTopic;
|
||||||
|
|
||||||
|
private final String indicatorResetTopic;
|
||||||
|
|
||||||
private final String indicatorAccessTopic;
|
private final String indicatorAccessTopic;
|
||||||
|
|
||||||
private final String generateFileTopic;
|
private final String generateFileTopic;
|
||||||
|
@ -58,7 +60,7 @@ public class OutboxProperties {
|
||||||
String notifyTopic,
|
String notifyTopic,
|
||||||
String forgetMeCompletedTopic,
|
String forgetMeCompletedTopic,
|
||||||
String whatYouKnowAboutMeCompletedTopic,
|
String whatYouKnowAboutMeCompletedTopic,
|
||||||
String accountingEntryCreatedTopic, String indicatorPointTopic, String indicatorTopic, String indicatorAccessTopic, String generateFileTopic
|
String accountingEntryCreatedTopic, String indicatorPointTopic, String indicatorTopic, String indicatorResetTopic, String indicatorAccessTopic, String generateFileTopic
|
||||||
) {
|
) {
|
||||||
this.exchange = exchange;
|
this.exchange = exchange;
|
||||||
this.handleAckRetries = handleAckRetries;
|
this.handleAckRetries = handleAckRetries;
|
||||||
|
@ -81,6 +83,7 @@ public class OutboxProperties {
|
||||||
this.accountingEntryCreatedTopic = accountingEntryCreatedTopic;
|
this.accountingEntryCreatedTopic = accountingEntryCreatedTopic;
|
||||||
this.indicatorPointTopic = indicatorPointTopic;
|
this.indicatorPointTopic = indicatorPointTopic;
|
||||||
this.indicatorTopic = indicatorTopic;
|
this.indicatorTopic = indicatorTopic;
|
||||||
|
this.indicatorResetTopic = indicatorResetTopic;
|
||||||
this.indicatorAccessTopic = indicatorAccessTopic;
|
this.indicatorAccessTopic = indicatorAccessTopic;
|
||||||
this.generateFileTopic = generateFileTopic;
|
this.generateFileTopic = generateFileTopic;
|
||||||
}
|
}
|
||||||
|
@ -173,6 +176,10 @@ public class OutboxProperties {
|
||||||
return indicatorTopic;
|
return indicatorTopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getIndicatorResetTopic() {
|
||||||
|
return indicatorResetTopic;
|
||||||
|
}
|
||||||
|
|
||||||
public String getIndicatorAccessTopic() {
|
public String getIndicatorAccessTopic() {
|
||||||
return indicatorAccessTopic;
|
return indicatorAccessTopic;
|
||||||
}
|
}
|
||||||
|
|
|
@ -454,6 +454,10 @@ public class OutboxRepositoryImpl implements OutboxRepository {
|
||||||
routingKey = this.outboxProperties.getIndicatorTopic();
|
routingKey = this.outboxProperties.getIndicatorTopic();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case OutboxIntegrationEvent.INDICATOR_RESET_ENTRY: {
|
||||||
|
routingKey = this.outboxProperties.getIndicatorResetTopic();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case OutboxIntegrationEvent.INDICATOR_ACCESS_ENTRY: {
|
case OutboxIntegrationEvent.INDICATOR_ACCESS_ENTRY: {
|
||||||
routingKey = this.outboxProperties.getIndicatorAccessTopic();
|
routingKey = this.outboxProperties.getIndicatorAccessTopic();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
package org.opencdmp.integrationevent.outbox.indicatoraccess;
|
||||||
|
|
||||||
|
|
||||||
|
import gr.cite.tools.validation.specification.Specification;
|
||||||
|
import org.opencdmp.commons.validation.BaseValidator;
|
||||||
|
import org.opencdmp.convention.ConventionService;
|
||||||
|
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FilterColumnConfig {
|
||||||
|
|
||||||
|
private String column;
|
||||||
|
public static final String _column = "column";
|
||||||
|
|
||||||
|
private List<String> values;
|
||||||
|
|
||||||
|
public String getColumn() {
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColumn(String column) {
|
||||||
|
this.column = column;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getValues() {
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValues(List<String> values) {
|
||||||
|
this.values = values;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component(FilterColumnConfigValidator.ValidatorName)
|
||||||
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public static class FilterColumnConfigValidator extends BaseValidator<FilterColumnConfig> {
|
||||||
|
|
||||||
|
public static final String ValidatorName = "Indicatoraccess.FilterColumnConfigValidator";
|
||||||
|
|
||||||
|
private final MessageSource messageSource;
|
||||||
|
|
||||||
|
protected FilterColumnConfigValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
|
||||||
|
super(conventionService, errors);
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<FilterColumnConfig> modelClass() {
|
||||||
|
return FilterColumnConfig.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Specification> specifications(FilterColumnConfig item) {
|
||||||
|
return Arrays.asList(
|
||||||
|
this.spec()
|
||||||
|
.must(() -> !this.isEmpty(item.getColumn()))
|
||||||
|
.failOn(FilterColumnConfig._column).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{FilterColumnConfig._column}, LocaleContextHolder.getLocale()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
package org.opencdmp.integrationevent.outbox.indicatoraccess;
|
||||||
|
|
||||||
|
|
||||||
|
import gr.cite.tools.validation.ValidatorFactory;
|
||||||
|
import gr.cite.tools.validation.specification.Specification;
|
||||||
|
import org.opencdmp.commons.validation.BaseValidator;
|
||||||
|
import org.opencdmp.convention.ConventionService;
|
||||||
|
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
|
public class IndicatorAccessConfig {
|
||||||
|
|
||||||
|
private List<FilterColumnConfig> globalFilterColumns;
|
||||||
|
public static final String _globalFilterColumns = "globalFilterColumns";
|
||||||
|
|
||||||
|
|
||||||
|
private Map<UUID, List<FilterColumnConfig>> groupFilterColumns;
|
||||||
|
public static final String _groupFilterColumns = "groupFilterColumns";
|
||||||
|
|
||||||
|
public List<FilterColumnConfig> getGlobalFilterColumns() {
|
||||||
|
return globalFilterColumns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGlobalFilterColumns(List<FilterColumnConfig> globalFilterColumns) {
|
||||||
|
this.globalFilterColumns = globalFilterColumns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<UUID, List<FilterColumnConfig>> getGroupFilterColumns() {
|
||||||
|
return groupFilterColumns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupFilterColumns(Map<UUID, List<FilterColumnConfig>> groupFilterColumns) {
|
||||||
|
this.groupFilterColumns = groupFilterColumns;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component(IndicatorAccessConfigValidator.ValidatorName)
|
||||||
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public static class IndicatorAccessConfigValidator extends BaseValidator<IndicatorAccessConfig> {
|
||||||
|
|
||||||
|
public static final String ValidatorName = "IndicatorAccessConfigValidator";
|
||||||
|
|
||||||
|
private final MessageSource messageSource;
|
||||||
|
|
||||||
|
private final ValidatorFactory validatorFactory;
|
||||||
|
|
||||||
|
protected IndicatorAccessConfigValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
|
||||||
|
super(conventionService, errors);
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
this.validatorFactory = validatorFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<IndicatorAccessConfig> modelClass() {
|
||||||
|
return IndicatorAccessConfig.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Specification> specifications(IndicatorAccessConfig item) {
|
||||||
|
return Arrays.asList(
|
||||||
|
this.navSpec()
|
||||||
|
.iff(() -> !this.isListNullOrEmpty(item.getGlobalFilterColumns()))
|
||||||
|
.on(IndicatorAccessConfig._globalFilterColumns)
|
||||||
|
.over(item.getGlobalFilterColumns())
|
||||||
|
.using((itm) -> this.validatorFactory.validator(FilterColumnConfig.FilterColumnConfigValidator.class))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,15 +1,29 @@
|
||||||
package org.opencdmp.integrationevent.outbox.indicatoraccess;
|
package org.opencdmp.integrationevent.outbox.indicatoraccess;
|
||||||
|
|
||||||
|
import gr.cite.tools.validation.ValidatorFactory;
|
||||||
|
import gr.cite.tools.validation.specification.Specification;
|
||||||
|
import org.opencdmp.commons.validation.BaseValidator;
|
||||||
|
import org.opencdmp.convention.ConventionService;
|
||||||
|
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
||||||
import org.opencdmp.integrationevent.TrackedEvent;
|
import org.opencdmp.integrationevent.TrackedEvent;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class IndicatorAccessEvent extends TrackedEvent {
|
public class IndicatorAccessEvent extends TrackedEvent {
|
||||||
|
|
||||||
private UUID userId;
|
private UUID userId;
|
||||||
public static final String _indicatorId= "indicatorId";
|
public static final String _userId= "userId";
|
||||||
|
|
||||||
private UUID indicatorId;
|
private UUID indicatorId;
|
||||||
|
public static final String _indicatorId= "indicatorId";
|
||||||
|
|
||||||
|
private IndicatorAccessConfig config;
|
||||||
|
public static final String _config = "config";
|
||||||
|
|
||||||
public UUID getUserId() {
|
public UUID getUserId() {
|
||||||
return userId;
|
return userId;
|
||||||
|
@ -26,4 +40,48 @@ public class IndicatorAccessEvent extends TrackedEvent {
|
||||||
public void setIndicatorId(UUID indicatorId) {
|
public void setIndicatorId(UUID indicatorId) {
|
||||||
this.indicatorId = indicatorId;
|
this.indicatorId = indicatorId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IndicatorAccessConfig getConfig() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfig(IndicatorAccessConfig config) {
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component(IndicatorAccessEventValidator.ValidatorName)
|
||||||
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public static class IndicatorAccessEventValidator extends BaseValidator<IndicatorAccessEvent> {
|
||||||
|
|
||||||
|
public static final String ValidatorName = "IndicatorAccessEventValidator";
|
||||||
|
|
||||||
|
private final MessageSource messageSource;
|
||||||
|
|
||||||
|
private final ValidatorFactory validatorFactory;
|
||||||
|
|
||||||
|
protected IndicatorAccessEventValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
|
||||||
|
super(conventionService, errors);
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
this.validatorFactory = validatorFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<IndicatorAccessEvent> modelClass() {
|
||||||
|
return IndicatorAccessEvent.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Specification> specifications(IndicatorAccessEvent item) {
|
||||||
|
return Arrays.asList(
|
||||||
|
this.spec()
|
||||||
|
.must(() -> this.isValidGuid(item.getIndicatorId()))
|
||||||
|
.failOn(IndicatorAccessEvent._indicatorId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{IndicatorAccessEvent._indicatorId}, LocaleContextHolder.getLocale())),
|
||||||
|
this.refSpec()
|
||||||
|
.iff(() -> !this.isNull(item.getConfig()))
|
||||||
|
.on(IndicatorAccessEvent._config)
|
||||||
|
.over(item.getConfig())
|
||||||
|
.using(() -> this.validatorFactory.validator(IndicatorAccessConfig.IndicatorAccessConfigValidator.class))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
package org.opencdmp.integrationevent.outbox.indicatorreset;
|
||||||
|
|
||||||
|
import gr.cite.tools.validation.ValidatorFactory;
|
||||||
|
import gr.cite.tools.validation.specification.Specification;
|
||||||
|
import org.opencdmp.commons.validation.BaseValidator;
|
||||||
|
import org.opencdmp.convention.ConventionService;
|
||||||
|
import org.opencdmp.errorcode.ErrorThesaurusProperties;
|
||||||
|
import org.opencdmp.integrationevent.TrackedEvent;
|
||||||
|
import org.opencdmp.integrationevent.outbox.indicator.IndicatorMetadata;
|
||||||
|
import org.opencdmp.integrationevent.outbox.indicator.IndicatorSchema;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class IndicatorResetEvent extends TrackedEvent {
|
||||||
|
|
||||||
|
private UUID id;
|
||||||
|
|
||||||
|
private IndicatorMetadata metadata;
|
||||||
|
|
||||||
|
private IndicatorSchema schema;
|
||||||
|
public static final String _schema = "schema";
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IndicatorMetadata getMetadata() {
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMetadata(IndicatorMetadata metadata) {
|
||||||
|
this.metadata = metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IndicatorSchema getSchema() {
|
||||||
|
return schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSchema(IndicatorSchema schema) {
|
||||||
|
this.schema = schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component(IndicatorResetEventValidator.ValidatorName)
|
||||||
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public static class IndicatorResetEventValidator extends BaseValidator<IndicatorResetEvent> {
|
||||||
|
|
||||||
|
public static final String ValidatorName = "IndicatorResetEventValidator";
|
||||||
|
|
||||||
|
private final MessageSource messageSource;
|
||||||
|
|
||||||
|
private final ValidatorFactory validatorFactory;
|
||||||
|
|
||||||
|
protected IndicatorResetEventValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
|
||||||
|
super(conventionService, errors);
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
this.validatorFactory = validatorFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<IndicatorResetEvent> modelClass() {
|
||||||
|
return IndicatorResetEvent.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Specification> specifications(IndicatorResetEvent item) {
|
||||||
|
return Arrays.asList(
|
||||||
|
this.refSpec()
|
||||||
|
.iff(() -> !this.isNull(item.getSchema()))
|
||||||
|
.on(IndicatorResetEvent._schema)
|
||||||
|
.over(item.getSchema())
|
||||||
|
.using(() -> this.validatorFactory.validator(IndicatorSchema.IndicatorSchemaValidator.class))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package org.opencdmp.integrationevent.outbox.indicatorreset;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public interface IndicatorResetEventHandler {
|
||||||
|
|
||||||
|
void handle(IndicatorResetEvent event);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package org.opencdmp.integrationevent.outbox.indicatorreset;
|
||||||
|
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.opencdmp.integrationevent.outbox.OutboxIntegrationEvent;
|
||||||
|
import org.opencdmp.integrationevent.outbox.OutboxService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class IndicatorResetEventHandlerImpl implements IndicatorResetEventHandler {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(IndicatorResetEventHandlerImpl.class));
|
||||||
|
|
||||||
|
private final OutboxService outboxService;
|
||||||
|
|
||||||
|
private final ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public IndicatorResetEventHandlerImpl(OutboxService outboxService, ApplicationContext applicationContext) {
|
||||||
|
this.outboxService = outboxService;
|
||||||
|
this.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(IndicatorResetEvent event) {
|
||||||
|
OutboxIntegrationEvent message = new OutboxIntegrationEvent();
|
||||||
|
message.setMessageId(UUID.randomUUID());
|
||||||
|
message.setType(OutboxIntegrationEvent.INDICATOR_RESET_ENTRY);
|
||||||
|
message.setEvent(event);
|
||||||
|
message.setTenantId(null);
|
||||||
|
|
||||||
|
this.outboxService.publish(message);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,13 +2,14 @@ package org.opencdmp.service.maintenance;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ConfigurationProperties(prefix = "kpi.user-indicator")
|
@ConfigurationProperties(prefix = "kpi.user-indicator")
|
||||||
public class KpiProperties {
|
public class KpiProperties {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
private UUID user;
|
private List<UUID> userIds;
|
||||||
|
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
|
@ -26,12 +27,12 @@ public class KpiProperties {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getUser() {
|
public List<UUID> getUserIds() {
|
||||||
return user;
|
return userIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUser(UUID user) {
|
public void setUserIds(List<UUID> userIds) {
|
||||||
this.user = user;
|
this.userIds = userIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
|
|
|
@ -31,6 +31,8 @@ public interface MaintenanceService {
|
||||||
|
|
||||||
void sendIndicatorCreateEntryEvents() throws InvalidApplicationException;
|
void sendIndicatorCreateEntryEvents() throws InvalidApplicationException;
|
||||||
|
|
||||||
|
void sendIndicatorResetEntryEvents() throws InvalidApplicationException;
|
||||||
|
|
||||||
void sendIndicatorAccessEntryEvents() throws InvalidApplicationException;
|
void sendIndicatorAccessEntryEvents() throws InvalidApplicationException;
|
||||||
|
|
||||||
void sendIndicatorPointEntryEvents() throws InvalidApplicationException;
|
void sendIndicatorPointEntryEvents() throws InvalidApplicationException;
|
||||||
|
|
|
@ -16,10 +16,14 @@ import org.opencdmp.integrationevent.outbox.accountingentrycreated.AccountingEnt
|
||||||
import org.opencdmp.integrationevent.outbox.annotationentityremoval.AnnotationEntityRemovalIntegrationEventHandler;
|
import org.opencdmp.integrationevent.outbox.annotationentityremoval.AnnotationEntityRemovalIntegrationEventHandler;
|
||||||
import org.opencdmp.integrationevent.outbox.annotationentitytouch.AnnotationEntityTouchedIntegrationEventHandler;
|
import org.opencdmp.integrationevent.outbox.annotationentitytouch.AnnotationEntityTouchedIntegrationEventHandler;
|
||||||
import org.opencdmp.integrationevent.outbox.indicator.*;
|
import org.opencdmp.integrationevent.outbox.indicator.*;
|
||||||
|
import org.opencdmp.integrationevent.outbox.indicatoraccess.FilterColumnConfig;
|
||||||
|
import org.opencdmp.integrationevent.outbox.indicatoraccess.IndicatorAccessConfig;
|
||||||
import org.opencdmp.integrationevent.outbox.indicatoraccess.IndicatorAccessEvent;
|
import org.opencdmp.integrationevent.outbox.indicatoraccess.IndicatorAccessEvent;
|
||||||
import org.opencdmp.integrationevent.outbox.indicatoraccess.IndicatorAccessEventHandler;
|
import org.opencdmp.integrationevent.outbox.indicatoraccess.IndicatorAccessEventHandler;
|
||||||
import org.opencdmp.integrationevent.outbox.indicatorpoint.IndicatorPointEvent;
|
import org.opencdmp.integrationevent.outbox.indicatorpoint.IndicatorPointEvent;
|
||||||
import org.opencdmp.integrationevent.outbox.indicatorpoint.IndicatorPointEventHandler;
|
import org.opencdmp.integrationevent.outbox.indicatorpoint.IndicatorPointEventHandler;
|
||||||
|
import org.opencdmp.integrationevent.outbox.indicatorreset.IndicatorResetEvent;
|
||||||
|
import org.opencdmp.integrationevent.outbox.indicatorreset.IndicatorResetEventHandler;
|
||||||
import org.opencdmp.integrationevent.outbox.tenantremoval.TenantRemovalIntegrationEventHandler;
|
import org.opencdmp.integrationevent.outbox.tenantremoval.TenantRemovalIntegrationEventHandler;
|
||||||
import org.opencdmp.integrationevent.outbox.tenanttouched.TenantTouchedIntegrationEvent;
|
import org.opencdmp.integrationevent.outbox.tenanttouched.TenantTouchedIntegrationEvent;
|
||||||
import org.opencdmp.integrationevent.outbox.tenanttouched.TenantTouchedIntegrationEventHandler;
|
import org.opencdmp.integrationevent.outbox.tenanttouched.TenantTouchedIntegrationEventHandler;
|
||||||
|
@ -69,13 +73,14 @@ public class MaintenanceServiceImpl implements MaintenanceService {
|
||||||
private final AccountingService accountingService;
|
private final AccountingService accountingService;
|
||||||
private final KpiProperties kpiProperties;
|
private final KpiProperties kpiProperties;
|
||||||
private final IndicatorElasticEventHandler indicatorElasticEventHandler;
|
private final IndicatorElasticEventHandler indicatorElasticEventHandler;
|
||||||
|
private final IndicatorResetEventHandler indicatorResetEventHandler;
|
||||||
private final IndicatorAccessEventHandler indicatorAccessEventHandler;
|
private final IndicatorAccessEventHandler indicatorAccessEventHandler;
|
||||||
private final IndicatorPointEventHandler indicatorPointEventHandler;
|
private final IndicatorPointEventHandler indicatorPointEventHandler;
|
||||||
private final ValidatorFactory validatorFactory;
|
private final ValidatorFactory validatorFactory;
|
||||||
|
|
||||||
public MaintenanceServiceImpl(
|
public MaintenanceServiceImpl(
|
||||||
TenantEntityManager entityManager, AuthorizationService authorizationService,
|
TenantEntityManager entityManager, AuthorizationService authorizationService,
|
||||||
QueryFactory queryFactory, UserTouchedIntegrationEventHandler userTouchedIntegrationEventHandler, UserRemovalIntegrationEventHandler userRemovalIntegrationEventHandler, TenantTouchedIntegrationEventHandler tenantTouchedIntegrationEventHandler, TenantRemovalIntegrationEventHandler tenantRemovalIntegrationEventHandler, AnnotationEntityRemovalIntegrationEventHandler annotationEntityRemovalIntegrationEventHandler, AnnotationEntityTouchedIntegrationEventHandler annotationEntityTouchedIntegrationEventHandler, AccountingEntryCreatedIntegrationEventHandler accountingEntryCreatedIntegrationEventHandler, TenantScope tenantScope, TenantEntityManager tenantEntityManager, AccountingProperties accountingProperties, AccountingService accountingService, KpiProperties kpiProperties, IndicatorElasticEventHandler indicatorElasticEventHandler, IndicatorAccessEventHandler indicatorAccessEventHandler, IndicatorPointEventHandler indicatorPointEventHandler, ValidatorFactory validatorFactory) {
|
QueryFactory queryFactory, UserTouchedIntegrationEventHandler userTouchedIntegrationEventHandler, UserRemovalIntegrationEventHandler userRemovalIntegrationEventHandler, TenantTouchedIntegrationEventHandler tenantTouchedIntegrationEventHandler, TenantRemovalIntegrationEventHandler tenantRemovalIntegrationEventHandler, AnnotationEntityRemovalIntegrationEventHandler annotationEntityRemovalIntegrationEventHandler, AnnotationEntityTouchedIntegrationEventHandler annotationEntityTouchedIntegrationEventHandler, AccountingEntryCreatedIntegrationEventHandler accountingEntryCreatedIntegrationEventHandler, TenantScope tenantScope, TenantEntityManager tenantEntityManager, AccountingProperties accountingProperties, AccountingService accountingService, KpiProperties kpiProperties, IndicatorElasticEventHandler indicatorElasticEventHandler, IndicatorResetEventHandler indicatorResetEventHandler, IndicatorAccessEventHandler indicatorAccessEventHandler, IndicatorPointEventHandler indicatorPointEventHandler, ValidatorFactory validatorFactory) {
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
this.queryFactory = queryFactory;
|
this.queryFactory = queryFactory;
|
||||||
|
@ -92,6 +97,7 @@ public class MaintenanceServiceImpl implements MaintenanceService {
|
||||||
this.accountingService = accountingService;
|
this.accountingService = accountingService;
|
||||||
this.kpiProperties = kpiProperties;
|
this.kpiProperties = kpiProperties;
|
||||||
this.indicatorElasticEventHandler = indicatorElasticEventHandler;
|
this.indicatorElasticEventHandler = indicatorElasticEventHandler;
|
||||||
|
this.indicatorResetEventHandler = indicatorResetEventHandler;
|
||||||
this.indicatorAccessEventHandler = indicatorAccessEventHandler;
|
this.indicatorAccessEventHandler = indicatorAccessEventHandler;
|
||||||
this.indicatorPointEventHandler = indicatorPointEventHandler;
|
this.indicatorPointEventHandler = indicatorPointEventHandler;
|
||||||
this.validatorFactory = validatorFactory;
|
this.validatorFactory = validatorFactory;
|
||||||
|
@ -415,6 +421,23 @@ public class MaintenanceServiceImpl implements MaintenanceService {
|
||||||
public void sendIndicatorCreateEntryEvents() throws InvalidApplicationException {
|
public void sendIndicatorCreateEntryEvents() throws InvalidApplicationException {
|
||||||
IndicatorElasticEvent event = new IndicatorElasticEvent();
|
IndicatorElasticEvent event = new IndicatorElasticEvent();
|
||||||
event.setId(this.kpiProperties.getId());
|
event.setId(this.kpiProperties.getId());
|
||||||
|
event.setMetadata(this.defineMetadata());
|
||||||
|
event.setSchema(this.defineSchema());
|
||||||
|
this.validatorFactory.validator(IndicatorElasticEvent.IndicatorElasticEventValidator.class).validateForce(event);
|
||||||
|
this.indicatorElasticEventHandler.handle(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendIndicatorResetEntryEvents() throws InvalidApplicationException {
|
||||||
|
IndicatorResetEvent event = new IndicatorResetEvent();
|
||||||
|
event.setId(this.kpiProperties.getId());
|
||||||
|
event.setMetadata(this.defineMetadata());
|
||||||
|
event.setSchema(this.defineSchema());
|
||||||
|
this.validatorFactory.validator(IndicatorResetEvent.IndicatorResetEventValidator.class).validateForce(event);
|
||||||
|
this.indicatorResetEventHandler.handle(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IndicatorMetadata defineMetadata() {
|
||||||
IndicatorMetadata metadata = new IndicatorMetadata();
|
IndicatorMetadata metadata = new IndicatorMetadata();
|
||||||
metadata.setCode(this.kpiProperties.getCode());
|
metadata.setCode(this.kpiProperties.getCode());
|
||||||
metadata.setLabel(this.kpiProperties.getLabel());
|
metadata.setLabel(this.kpiProperties.getLabel());
|
||||||
|
@ -422,72 +445,67 @@ public class MaintenanceServiceImpl implements MaintenanceService {
|
||||||
metadata.setUrl(this.kpiProperties.getUrl());
|
metadata.setUrl(this.kpiProperties.getUrl());
|
||||||
metadata.setDate(Instant.now());
|
metadata.setDate(Instant.now());
|
||||||
|
|
||||||
event.setMetadata(metadata);
|
return metadata;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
private IndicatorSchema defineSchema() {
|
||||||
this.tenantEntityManager.disableTenantFilters();
|
IndicatorSchema schema = new IndicatorSchema();
|
||||||
List<TenantUserEntity> tenantUserEntities = this.queryFactory.query(TenantUserQuery.class).disableTracking().userIds(this.kpiProperties.getUser()).collectAs(new BaseFieldSet().ensure(TenantUser._tenant));
|
schema.setId(this.kpiProperties.getId());
|
||||||
List<IndicatorField> fields = new ArrayList<>();
|
|
||||||
|
|
||||||
IndicatorField field = new IndicatorField();
|
List<IndicatorField> fields = new ArrayList<>();
|
||||||
field.setCode("tenant_code");
|
|
||||||
field.setName("Tenant Code");
|
|
||||||
field.setBasetype(IndicatorFieldBaseType.Keyword);
|
|
||||||
fields.add(field);
|
|
||||||
|
|
||||||
IndicatorField field1 = new IndicatorField();
|
IndicatorField field = new IndicatorField();
|
||||||
field1.setCode("user_id");
|
field.setCode("tenant_code");
|
||||||
field1.setName("User Id");
|
field.setName("Tenant Code");
|
||||||
field1.setBasetype(IndicatorFieldBaseType.Keyword);
|
field.setBasetype(IndicatorFieldBaseType.Keyword);
|
||||||
fields.add(field1);
|
fields.add(field);
|
||||||
|
|
||||||
IndicatorField field2 = new IndicatorField();
|
IndicatorField field1 = new IndicatorField();
|
||||||
field2.setCode("created_at");
|
field1.setCode("user_id");
|
||||||
field2.setName("Created at");
|
field1.setName("User Id");
|
||||||
field2.setBasetype(IndicatorFieldBaseType.Date);
|
field1.setBasetype(IndicatorFieldBaseType.Keyword);
|
||||||
fields.add(field2);
|
fields.add(field1);
|
||||||
|
|
||||||
UserEntity user = this.queryFactory.query(UserQuery.class).disableTracking().ids(this.kpiProperties.getUser()).firstAs(new BaseFieldSet().ensure(User._name));
|
IndicatorField field2 = new IndicatorField();
|
||||||
if (user == null) {
|
field2.setCode("created_at");
|
||||||
throw new MyApplicationException("user not found");
|
field2.setName("Created at");
|
||||||
}
|
field2.setBasetype(IndicatorFieldBaseType.Date);
|
||||||
IndicatorField field3 = new IndicatorField();
|
fields.add(field2);
|
||||||
field3.setCode("user_name");
|
|
||||||
field3.setName("User Name");
|
|
||||||
field3.setBasetype(IndicatorFieldBaseType.String);
|
|
||||||
fields.add(field3);
|
|
||||||
|
|
||||||
IndicatorField field4 = new IndicatorField();
|
IndicatorField field3 = new IndicatorField();
|
||||||
field4.setCode("value");
|
field3.setCode("user_name");
|
||||||
field4.setName("Value");
|
field3.setName("User Name");
|
||||||
field4.setBasetype(IndicatorFieldBaseType.Integer);
|
field3.setBasetype(IndicatorFieldBaseType.String);
|
||||||
fields.add(field4);
|
fields.add(field3);
|
||||||
|
|
||||||
IndicatorSchema schema = new IndicatorSchema();
|
IndicatorField field4 = new IndicatorField();
|
||||||
schema.setId(this.kpiProperties.getId());
|
field4.setCode("value");
|
||||||
schema.setFields(fields);
|
field4.setName("Value");
|
||||||
|
field4.setBasetype(IndicatorFieldBaseType.Integer);
|
||||||
|
fields.add(field4);
|
||||||
|
|
||||||
event.setSchema(schema);
|
schema.setFields(fields);
|
||||||
|
|
||||||
this.validatorFactory.validator(IndicatorElasticEvent.IndicatorElasticEventValidator.class).validateForce(event);
|
return schema;
|
||||||
this.indicatorElasticEventHandler.handle(event);
|
|
||||||
} finally {
|
|
||||||
this.tenantEntityManager.reloadTenantFilters();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendIndicatorAccessEntryEvents() throws InvalidApplicationException {
|
public void sendIndicatorAccessEntryEvents() throws InvalidApplicationException {
|
||||||
IndicatorAccessEvent event = new IndicatorAccessEvent();
|
|
||||||
event.setIndicatorId(this.kpiProperties.getId());
|
|
||||||
event.setUserId(this.kpiProperties.getUser());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
for (UUID userId: this.kpiProperties.getUserIds()) {
|
||||||
|
this.indicatorAccessEventHandler.handle(this.createIndicatorAccessEvent(userId, this.tenantScope.getDefaultTenantCode()), null);
|
||||||
|
}
|
||||||
this.tenantEntityManager.disableTenantFilters();
|
this.tenantEntityManager.disableTenantFilters();
|
||||||
List<TenantUserEntity> tenantUserEntities = this.queryFactory.query(TenantUserQuery.class).disableTracking().userIds(this.kpiProperties.getUser()).collectAs(new BaseFieldSet().ensure(TenantUser._tenant));
|
List<TenantUserEntity> tenantUserEntities = this.queryFactory.query(TenantUserQuery.class).disableTracking().userIds(this.kpiProperties.getUserIds()).collect();
|
||||||
if (tenantUserEntities != null) {
|
if (tenantUserEntities == null || tenantUserEntities.isEmpty()) throw new MyApplicationException("tenant users not found");
|
||||||
|
List<TenantEntity> tenantEntities = this.queryFactory.query(TenantQuery.class).disableTracking().ids(tenantUserEntities.stream().map(TenantUserEntity::getTenantId).distinct().toList()).collectAs(new BaseFieldSet().ensure(Tenant._id).ensure(Tenant._code));
|
||||||
|
if (tenantEntities != null && !tenantEntities.isEmpty()) {
|
||||||
for (TenantUserEntity user: tenantUserEntities) {
|
for (TenantUserEntity user: tenantUserEntities) {
|
||||||
this.indicatorAccessEventHandler.handle(event, user.getTenantId());
|
TenantEntity tenant = tenantEntities.stream().filter(x -> x.getId().equals(user.getTenantId())).findFirst().orElse(null);
|
||||||
|
if (tenant != null){
|
||||||
|
this.indicatorAccessEventHandler.handle(this.createIndicatorAccessEvent(user.getUserId(), tenant.getCode()), tenant.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -495,32 +513,49 @@ public class MaintenanceServiceImpl implements MaintenanceService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IndicatorAccessEvent createIndicatorAccessEvent(UUID userId, String tenantCode) {
|
||||||
|
IndicatorAccessEvent event = new IndicatorAccessEvent();
|
||||||
|
event.setIndicatorId(this.kpiProperties.getId());
|
||||||
|
event.setUserId(userId);
|
||||||
|
|
||||||
|
List<FilterColumnConfig> globalFilterColumns = new ArrayList<>();
|
||||||
|
FilterColumnConfig filterColumn = new FilterColumnConfig();
|
||||||
|
filterColumn.setColumn("tenant_code");
|
||||||
|
filterColumn.setValues(List.of(tenantCode));
|
||||||
|
globalFilterColumns.add(filterColumn);
|
||||||
|
|
||||||
|
IndicatorAccessConfig config = new IndicatorAccessConfig();
|
||||||
|
config.setGlobalFilterColumns(globalFilterColumns);
|
||||||
|
|
||||||
|
event.setConfig(config);
|
||||||
|
|
||||||
|
this.validatorFactory.validator(IndicatorAccessEvent.IndicatorAccessEventValidator.class).validateForce(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendIndicatorPointEntryEvents() throws InvalidApplicationException {
|
public void sendIndicatorPointEntryEvents() throws InvalidApplicationException {
|
||||||
IndicatorPointEvent event = new IndicatorPointEvent();
|
|
||||||
event.setIndicatorId(this.kpiProperties.getId());
|
|
||||||
|
|
||||||
event.add("user_id", this.kpiProperties.getUser());
|
|
||||||
event.add("created_at", Instant.now());
|
|
||||||
event.add("value", 1);
|
|
||||||
|
|
||||||
UserEntity user = this.queryFactory.query(UserQuery.class).disableTracking().ids(this.kpiProperties.getUser()).firstAs(new BaseFieldSet().ensure(User._name));
|
|
||||||
if (user == null) {
|
|
||||||
throw new MyApplicationException("user not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
event.add("user_name", user.getName());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.tenantEntityManager.disableTenantFilters();
|
this.tenantEntityManager.disableTenantFilters();
|
||||||
List<TenantUserEntity> tenantUserEntities = this.queryFactory.query(TenantUserQuery.class).disableTracking().userIds(this.kpiProperties.getUser()).collectAs(new BaseFieldSet().ensure(TenantUser._tenant));
|
List<UserEntity> users = this.queryFactory.query(UserQuery.class).disableTracking().isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(User._id).ensure(User._name).ensure(User._createdAt));
|
||||||
if (tenantUserEntities != null) {
|
if (users == null || users.isEmpty()) {
|
||||||
|
throw new MyApplicationException("users not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (UserEntity user: users) {
|
||||||
|
this.indicatorPointEventHandler.handle(this.createIndicatorPointEvent(user, user.getCreatedAt(), this.tenantScope.getDefaultTenantCode()));
|
||||||
|
}
|
||||||
|
List<TenantUserEntity> tenantUserEntities = this.queryFactory.query(TenantUserQuery.class).disableTracking().collect();
|
||||||
|
if (tenantUserEntities != null && !tenantUserEntities.isEmpty()) {
|
||||||
List<TenantEntity> tenantEntities = this.queryFactory.query(TenantQuery.class).disableTracking().ids(tenantUserEntities.stream().map(TenantUserEntity::getTenantId).distinct().toList()).collect();
|
List<TenantEntity> tenantEntities = this.queryFactory.query(TenantQuery.class).disableTracking().ids(tenantUserEntities.stream().map(TenantUserEntity::getTenantId).distinct().toList()).collect();
|
||||||
if (tenantEntities != null) {
|
if (tenantEntities != null) {
|
||||||
for (TenantEntity tenant: tenantEntities) {
|
for (TenantUserEntity tenantUser: tenantUserEntities) {
|
||||||
event.add("tenant_code", tenant.getCode());
|
TenantEntity tenantEntity = tenantEntities.stream().filter(x -> x.getId().equals(tenantUser.getTenantId())).findFirst().orElse(null);
|
||||||
this.validatorFactory.validator(IndicatorPointEvent.IndicatorPointEventValidator.class).validateForce(event);
|
UserEntity userToAdd = users.stream().filter(x -> tenantUser.getUserId().equals(x.getId())).findFirst().orElse(null);
|
||||||
this.indicatorPointEventHandler.handle(event);
|
if (userToAdd != null && tenantEntity != null) {
|
||||||
|
this.indicatorPointEventHandler.handle(this.createIndicatorPointEvent(userToAdd, tenantUser.getCreatedAt(), tenantEntity.getCode()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,4 +564,18 @@ public class MaintenanceServiceImpl implements MaintenanceService {
|
||||||
this.tenantEntityManager.reloadTenantFilters();
|
this.tenantEntityManager.reloadTenantFilters();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IndicatorPointEvent createIndicatorPointEvent(UserEntity user, Instant createAt, String tenantCode) {
|
||||||
|
IndicatorPointEvent event = new IndicatorPointEvent();
|
||||||
|
event.setIndicatorId(this.kpiProperties.getId());
|
||||||
|
|
||||||
|
event.add("user_id", user.getId());
|
||||||
|
event.add("created_at", createAt);
|
||||||
|
event.add("user_name", user.getName());
|
||||||
|
event.add("value", 1);
|
||||||
|
event.add("tenant_code", tenantCode);
|
||||||
|
|
||||||
|
this.validatorFactory.validator(IndicatorPointEvent.IndicatorPointEventValidator.class).validateForce(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,6 +192,16 @@ public class MaintenanceController {
|
||||||
this.auditService.track(AuditableAction.Maintenance_SendIndicatorCreateEntryEvents);
|
this.auditService.track(AuditableAction.Maintenance_SendIndicatorCreateEntryEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = "/events/indicator-reset-entry")
|
||||||
|
public void sendIndicatorResetEvents() throws InvalidApplicationException {
|
||||||
|
logger.debug("send indicator reset entry queue events");
|
||||||
|
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
|
||||||
|
|
||||||
|
this.maintenanceService.sendIndicatorResetEntryEvents();
|
||||||
|
|
||||||
|
this.auditService.track(AuditableAction.Maintenance_SendIndicatorResetEntryEvents);
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = "/events/indicator-access-entry")
|
@RequestMapping(method = RequestMethod.POST, value = "/events/indicator-access-entry")
|
||||||
public void sendIndicatorAccessEvents() throws InvalidApplicationException {
|
public void sendIndicatorAccessEvents() throws InvalidApplicationException {
|
||||||
logger.debug("send indicator create entry queue events");
|
logger.debug("send indicator create entry queue events");
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
kpi:
|
kpi:
|
||||||
user-indicator:
|
user-indicator:
|
||||||
id: 97c2d685-d7d2-4bd1-a287-ba329ad45d74
|
id: 97c2d685-d7d2-4bd1-a287-ba329ad45d74
|
||||||
user: 8552f758-f196-4a51-a3fd-154c088d85c4
|
userIds:
|
||||||
|
- 8552f758-f196-4a51-a3fd-154c088d85c4
|
||||||
|
- e60876ed-87f8-4a8e-8081-e5620ec839cf
|
||||||
label: test
|
label: test
|
||||||
description: test
|
description: test
|
||||||
url: url test
|
url: url test
|
||||||
|
|
|
@ -44,6 +44,7 @@ queue:
|
||||||
what-you-know-about-me-completed-topic: whatyouknowaboutme.completed
|
what-you-know-about-me-completed-topic: whatyouknowaboutme.completed
|
||||||
accounting-entry-created-topic: accountingentry.create
|
accounting-entry-created-topic: accountingentry.create
|
||||||
indicator-topic: indicator.entry
|
indicator-topic: indicator.entry
|
||||||
|
indicator-reset-topic: indicator_reset.entry
|
||||||
indicator-point-topic: indicator_point.entry
|
indicator-point-topic: indicator_point.entry
|
||||||
indicator-access-topic: indicator_access.entry
|
indicator-access-topic: indicator_access.entry
|
||||||
generate-file-topic: generate.file
|
generate-file-topic: generate.file
|
||||||
|
|
|
@ -121,6 +121,13 @@ export class MaintenanceService extends BaseService {
|
||||||
catchError((error: any) => throwError(error)));
|
catchError((error: any) => throwError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendIndicatorResetEvents(): Observable<any> {
|
||||||
|
const url = `${this.apiBase}/events/indicator-reset-entry`;
|
||||||
|
return this.http
|
||||||
|
.post<any>(url, null).pipe(
|
||||||
|
catchError((error: any) => throwError(error)));
|
||||||
|
}
|
||||||
|
|
||||||
sendIndicatorAccessEvents(): Observable<any> {
|
sendIndicatorAccessEvents(): Observable<any> {
|
||||||
const url = `${this.apiBase}/events/indicator-access-entry`;
|
const url = `${this.apiBase}/events/indicator-access-entry`;
|
||||||
return this.http
|
return this.http
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<h3>{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.INDICATOR-TITLE')}}</h3>
|
<h3>{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.INDICATOR-TITLE')}}</h3>
|
||||||
<button mat-button (click)="sendIndicatorCreateEvents($event)" class="mb-1 mr-1 rounded-btn primary">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-INDICATOR-CREATE-ENTRY')}}</button>
|
<button mat-button (click)="sendIndicatorCreateEvents($event)" class="mb-1 mr-1 rounded-btn primary">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-INDICATOR-CREATE-ENTRY')}}</button>
|
||||||
|
<button mat-button (click)="sendIndicatorResetEvents($event)" class="mb-1 mr-1 rounded-btn primary">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-INDICATOR-RESET-ENTRY')}}</button>
|
||||||
<button mat-button (click)="sendIndicatorAccessEvents($event)" class="mb-1 mr-1 rounded-btn primary">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-INDICATOR-ACCESS-ENTRY')}}</button>
|
<button mat-button (click)="sendIndicatorAccessEvents($event)" class="mb-1 mr-1 rounded-btn primary">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-INDICATOR-ACCESS-ENTRY')}}</button>
|
||||||
<button mat-button (click)="sendIndicatorPointEvents($event)" class="mb-1 mr-1 rounded-btn primary">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-INDICATOR-POINT-ENTRY')}}</button>
|
<button mat-button (click)="sendIndicatorPointEvents($event)" class="mb-1 mr-1 rounded-btn primary">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-INDICATOR-POINT-ENTRY')}}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -496,6 +496,37 @@ export class MaintenanceTasksComponent extends BaseComponent implements OnInit {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendIndicatorResetEvents(ev: Event) {
|
||||||
|
this.dialog.open(ConfirmationDialogComponent, {
|
||||||
|
data: {
|
||||||
|
message: this.language.instant('MAINTENANCE-TASKS.CONFIRMATION.MESSAGE'),
|
||||||
|
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
|
||||||
|
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL')
|
||||||
|
},
|
||||||
|
maxWidth: '30em'
|
||||||
|
})
|
||||||
|
.afterClosed()
|
||||||
|
.subscribe(confirm => {
|
||||||
|
if (confirm) {
|
||||||
|
this.doSendIndicatorResetEvents(ev);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private doSendIndicatorResetEvents(ev: Event) {
|
||||||
|
(ev.target as HTMLButtonElement).disabled = true;
|
||||||
|
this.maintenanceService.sendIndicatorResetEvents().pipe(takeUntil(this._destroyed)).subscribe(
|
||||||
|
_ => {
|
||||||
|
(ev.target as HTMLButtonElement).disabled = false;
|
||||||
|
this.onCallbackSuccess();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
(ev.target as HTMLButtonElement).disabled = false;
|
||||||
|
this.onCallbackError(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
sendIndicatorAccessEvents(ev: Event) {
|
sendIndicatorAccessEvents(ev: Event) {
|
||||||
this.dialog.open(ConfirmationDialogComponent, {
|
this.dialog.open(ConfirmationDialogComponent, {
|
||||||
data: {
|
data: {
|
||||||
|
|
|
@ -424,6 +424,7 @@
|
||||||
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
||||||
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
||||||
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
||||||
|
"SEND-INDICATOR-RESET-ENTRY": "Send indicator reset entry events",
|
||||||
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
||||||
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,6 +424,7 @@
|
||||||
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
||||||
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
||||||
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
||||||
|
"SEND-INDICATOR-RESET-ENTRY": "Send indicator reset entry events",
|
||||||
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
||||||
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
||||||
}
|
}
|
||||||
|
|
|
@ -422,6 +422,7 @@
|
||||||
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
||||||
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
||||||
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
||||||
|
"SEND-INDICATOR-RESET-ENTRY": "Send indicator reset entry events",
|
||||||
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
||||||
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,6 +424,7 @@
|
||||||
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
||||||
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
||||||
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
||||||
|
"SEND-INDICATOR-RESET-ENTRY": "Send indicator reset entry events",
|
||||||
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
||||||
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,6 +424,7 @@
|
||||||
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
||||||
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
||||||
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
||||||
|
"SEND-INDICATOR-RESET-ENTRY": "Send indicator reset entry events",
|
||||||
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
||||||
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,6 +424,7 @@
|
||||||
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
||||||
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
||||||
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
||||||
|
"SEND-INDICATOR-RESET-ENTRY": "Send indicator reset entry events",
|
||||||
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
||||||
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,6 +424,7 @@
|
||||||
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
||||||
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
||||||
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
||||||
|
"SEND-INDICATOR-RESET-ENTRY": "Send indicator reset entry events",
|
||||||
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
||||||
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,6 +424,7 @@
|
||||||
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
||||||
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
||||||
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
||||||
|
"SEND-INDICATOR-RESET-ENTRY": "Send indicator reset entry events",
|
||||||
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
||||||
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,6 +424,7 @@
|
||||||
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
||||||
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
||||||
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
||||||
|
"SEND-INDICATOR-RESET-ENTRY": "Send indicator reset entry events",
|
||||||
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
||||||
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,6 +424,7 @@
|
||||||
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
||||||
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
||||||
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
||||||
|
"SEND-INDICATOR-RESET-ENTRY": "Send indicator reset entry events",
|
||||||
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
||||||
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,6 +424,7 @@
|
||||||
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
|
||||||
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events",
|
||||||
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
"SEND-INDICATOR-CREATE-ENTRY": "Send indicator create entry events",
|
||||||
|
"SEND-INDICATOR-RESET-ENTRY": "Send indicator reset entry events",
|
||||||
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
"SEND-INDICATOR-ACCESS-ENTRY": "Send indicator access entry events",
|
||||||
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
"SEND-INDICATOR-POINT-ENTRY": "Send indicator point entry events"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue