add maintenance tasks for accounting entries

This commit is contained in:
amentis 2024-07-18 15:15:22 +03:00
parent 3d4d8a7bc1
commit 728f022a16
23 changed files with 760 additions and 55 deletions

View File

@ -158,6 +158,15 @@ public class AuditableAction {
public static final EventId Maintenance_SendTenantTouchEvents = new EventId(230002, "Maintenance_SendTenantTouchEvents"); public static final EventId Maintenance_SendTenantTouchEvents = new EventId(230002, "Maintenance_SendTenantTouchEvents");
public static final EventId Maintenance_SendPlanTouchEvents = new EventId(230003, "Maintenance_SendPlanTouchEvents"); public static final EventId Maintenance_SendPlanTouchEvents = new EventId(230003, "Maintenance_SendPlanTouchEvents");
public static final EventId Maintenance_SendDescriptionTouchEvents = new EventId(230004, "Maintenance_SendDescriptionTouchEvents"); public static final EventId Maintenance_SendDescriptionTouchEvents = new EventId(230004, "Maintenance_SendDescriptionTouchEvents");
public static final EventId Maintenance_SendPlanAccountingEntriesEvents = new EventId(230005, "Maintenance_SendPlanAccountingEntriesEvents");
public static final EventId Maintenance_SendBlueprintAccountingEntriesEvents = new EventId(230006, "Maintenance_SendBlueprintAccountingEntriesEvents");
public static final EventId Maintenance_SendDescriptionAccountingEntriesEvents = new EventId(230007, "Maintenance_SendDescriptionAccountingEntriesEvents");
public static final EventId Maintenance_SendDescriptionTemplateAccountingEntriesEvents = new EventId(230008, "Maintenance_SendDescriptionTemplateAccountingEntriesEvents");
public static final EventId Maintenance_SendDescriptionTemplateTypeAccountingEntriesEvents = new EventId(230009, "Maintenance_SendDescriptionTemplateTypeAccountingEntriesEvents");
public static final EventId Maintenance_SendPrefillingSourceAccountingEntriesEvents = new EventId(230010, "Maintenance_SendPrefillingSourceAccountingEntriesEvents");
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 Principal_Lookup = new EventId(240000, "Principal_Lookup"); public static final EventId Principal_Lookup = new EventId(240000, "Principal_Lookup");
public static final EventId Principal_MyTenants = new EventId(240001, "Principal_MyTenants"); public static final EventId Principal_MyTenants = new EventId(240001, "Principal_MyTenants");

View File

@ -3,8 +3,9 @@ package org.opencdmp.integrationevent.outbox.accountingentrycreated;
import org.opencdmp.commons.enums.accounting.AccountingValueType; import org.opencdmp.commons.enums.accounting.AccountingValueType;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import java.util.UUID;
public interface AccountingEntryCreatedIntegrationEventHandler { public interface AccountingEntryCreatedIntegrationEventHandler {
void handleAccountingEntry(String metric, AccountingValueType valueType) throws InvalidApplicationException; void handleAccountingEntry(String metric, AccountingValueType valueType, String subjectId, UUID tenantId) throws InvalidApplicationException;
} }

View File

@ -1,10 +1,8 @@
package org.opencdmp.integrationevent.outbox.accountingentrycreated; package org.opencdmp.integrationevent.outbox.accountingentrycreated;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.opencdmp.commons.enums.accounting.AccountingMeasureType; import org.opencdmp.commons.enums.accounting.AccountingMeasureType;
import org.opencdmp.commons.enums.accounting.AccountingValueType; import org.opencdmp.commons.enums.accounting.AccountingValueType;
import org.opencdmp.commons.scope.tenant.TenantScope;
import org.opencdmp.integrationevent.outbox.OutboxIntegrationEvent; import org.opencdmp.integrationevent.outbox.OutboxIntegrationEvent;
import org.opencdmp.integrationevent.outbox.OutboxService; import org.opencdmp.integrationevent.outbox.OutboxService;
import org.opencdmp.service.accounting.AccountingProperties; import org.opencdmp.service.accounting.AccountingProperties;
@ -25,16 +23,10 @@ public class AccountingEntryCreatedIntegrationEventHandlerImpl implements Accoun
private final OutboxService outboxService; private final OutboxService outboxService;
private final QueryFactory queryFactory;
private final TenantScope tenantScope;
private final AccountingProperties accountingProperties; private final AccountingProperties accountingProperties;
public AccountingEntryCreatedIntegrationEventHandlerImpl(OutboxService outboxService, QueryFactory queryFactory, TenantScope tenantScope, TenantScope tenantScope1, AccountingProperties accountingProperties) { public AccountingEntryCreatedIntegrationEventHandlerImpl(OutboxService outboxService, AccountingProperties accountingProperties) {
this.outboxService = outboxService; this.outboxService = outboxService;
this.queryFactory = queryFactory;
this.tenantScope = tenantScope1;
this.accountingProperties = accountingProperties; this.accountingProperties = accountingProperties;
} }
@ -47,7 +39,7 @@ public class AccountingEntryCreatedIntegrationEventHandlerImpl implements Accoun
} }
@Override @Override
public void handleAccountingEntry(String metric, AccountingValueType valueType) throws InvalidApplicationException { public void handleAccountingEntry(String metric, AccountingValueType valueType, String subjectId, UUID tenantId) throws InvalidApplicationException {
AccountingEntryCreatedIntegrationEvent event = new AccountingEntryCreatedIntegrationEvent(); AccountingEntryCreatedIntegrationEvent event = new AccountingEntryCreatedIntegrationEvent();
event.setTimeStamp(Instant.now()); event.setTimeStamp(Instant.now());
event.setServiceId(accountingProperties.getServiceId()); event.setServiceId(accountingProperties.getServiceId());
@ -55,9 +47,9 @@ public class AccountingEntryCreatedIntegrationEventHandlerImpl implements Accoun
event.setMeasure(AccountingMeasureType.Unit); event.setMeasure(AccountingMeasureType.Unit);
event.setType(valueType); event.setType(valueType);
event.setResource(metric); event.setResource(metric);
if (this.tenantScope.getTenantCode() != null && !this.tenantScope.getTenantCode().equals(this.tenantScope.getDefaultTenantCode())){ event.setUserId(subjectId);
event.setTenant(this.tenantScope.getTenant()); event.setValue(1.0);
} event.setTenant(tenantId);
this.handle(event); this.handle(event);
} }

View File

@ -8,6 +8,8 @@ public class AccountingProperties {
private String action; private String action;
private String subjectId;
public String getServiceId() { public String getServiceId() {
return serviceId; return serviceId;
} }
@ -23,4 +25,12 @@ public class AccountingProperties {
public void setAction(String action) { public void setAction(String action) {
this.action = action; this.action = action;
} }
public String getSubjectId() {
return subjectId;
}
public void setSubjectId(String subjectId) {
this.subjectId = subjectId;
}
} }

View File

@ -1,15 +1,16 @@
package org.opencdmp.service.accounting; package org.opencdmp.service.accounting;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.opencdmp.commons.enums.UsageLimitTargetMetric; import org.opencdmp.commons.enums.UsageLimitTargetMetric;
import org.opencdmp.commons.enums.accounting.AccountingValueType; import org.opencdmp.commons.enums.accounting.AccountingValueType;
import org.opencdmp.convention.ConventionService; import org.opencdmp.commons.scope.tenant.TenantScope;
import org.opencdmp.errorcode.ErrorThesaurusProperties; import org.opencdmp.commons.scope.user.UserScope;
import org.opencdmp.data.UserCredentialEntity;
import org.opencdmp.integrationevent.outbox.accountingentrycreated.AccountingEntryCreatedIntegrationEventHandler; import org.opencdmp.integrationevent.outbox.accountingentrycreated.AccountingEntryCreatedIntegrationEventHandler;
import org.opencdmp.query.UserCredentialQuery;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
@ -18,27 +19,18 @@ import javax.management.InvalidApplicationException;
public class AccountingServiceImpl implements AccountingService { public class AccountingServiceImpl implements AccountingService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(AccountingServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(AccountingServiceImpl.class));
private final AuthorizationService authorizationService; private final QueryFactory queryFactory;
private final ConventionService conventionService;
private final ErrorThesaurusProperties errors;
private final MessageSource messageSource;
private final AccountingEntryCreatedIntegrationEventHandler accountingEntryCreatedIntegrationEventHandler; private final AccountingEntryCreatedIntegrationEventHandler accountingEntryCreatedIntegrationEventHandler;
private final UserScope userScope;
private final TenantScope tenantScope;
@Autowired @Autowired
public AccountingServiceImpl( public AccountingServiceImpl(
AuthorizationService authorizationService, QueryFactory queryFactory, AccountingEntryCreatedIntegrationEventHandler accountingEntryCreatedIntegrationEventHandler, UserScope userScope, TenantScope tenantScope) {
ConventionService conventionService, this.queryFactory = queryFactory;
ErrorThesaurusProperties errors,
MessageSource messageSource,
AccountingEntryCreatedIntegrationEventHandler accountingEntryCreatedIntegrationEventHandler) {
this.authorizationService = authorizationService;
this.conventionService = conventionService;
this.errors = errors;
this.messageSource = messageSource;
this.accountingEntryCreatedIntegrationEventHandler = accountingEntryCreatedIntegrationEventHandler; this.accountingEntryCreatedIntegrationEventHandler = accountingEntryCreatedIntegrationEventHandler;
this.userScope = userScope;
this.tenantScope = tenantScope;
} }
public Integer getCurrentMetricValue(UsageLimitTargetMetric metric) { public Integer getCurrentMetricValue(UsageLimitTargetMetric metric) {
@ -52,11 +44,23 @@ public class AccountingServiceImpl implements AccountingService {
} }
public void increase(String metric) throws InvalidApplicationException { public void increase(String metric) throws InvalidApplicationException {
this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(metric, AccountingValueType.Plus); String subjectId;
UserCredentialEntity userCredential = this.queryFactory.query(UserCredentialQuery.class).disableTracking().userIds(this.userScope.getUserId()).first();
if (userCredential != null) subjectId = userCredential.getExternalId();
else subjectId = this.userScope.getUserId().toString();
this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(metric, AccountingValueType.Plus, subjectId, this.tenantScope.getTenant());
} }
public void decrease(String metric) throws InvalidApplicationException { public void decrease(String metric) throws InvalidApplicationException {
this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(metric, AccountingValueType.Minus); String subjectId;
UserCredentialEntity userCredential = this.queryFactory.query(UserCredentialQuery.class).disableTracking().userIds(this.userScope.getUserId()).first();
if (userCredential != null) subjectId = userCredential.getExternalId();
else subjectId = this.userScope.getUserId().toString();
this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(metric, AccountingValueType.Minus, subjectId, this.tenantScope.getTenant());
} }
} }

View File

@ -12,4 +12,21 @@ public interface MaintenanceService {
void sendPlanTouchEvents() throws InvalidApplicationException; void sendPlanTouchEvents() throws InvalidApplicationException;
void sendDescriptionTouchEvents() throws InvalidApplicationException; void sendDescriptionTouchEvents() throws InvalidApplicationException;
void sendPlanAccountingEntriesEvents() throws InvalidApplicationException;
void sendBlueprintAccountingEntriesEvents() throws InvalidApplicationException;
void sendDescriptionAccountingEntriesEvents() throws InvalidApplicationException;
void sendDescriptionTemplateAccountingEntriesEvents() throws InvalidApplicationException;
void sendDescriptionTemplateTypeAccountingEntriesEvents() throws InvalidApplicationException;
void sendPrefillingSourceAccountingEntriesEvents() throws InvalidApplicationException;
void sendReferenceTypeAccountingEntriesEvents() throws InvalidApplicationException;
void sendUserAccountingEntriesEvents() throws InvalidApplicationException;
} }

View File

@ -6,8 +6,11 @@ import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.Permission; import org.opencdmp.authorization.Permission;
import org.opencdmp.commons.enums.IsActive; import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.commons.enums.UsageLimitTargetMetric;
import org.opencdmp.commons.enums.accounting.AccountingValueType;
import org.opencdmp.commons.scope.tenant.TenantScope; import org.opencdmp.commons.scope.tenant.TenantScope;
import org.opencdmp.data.*; import org.opencdmp.data.*;
import org.opencdmp.integrationevent.outbox.accountingentrycreated.AccountingEntryCreatedIntegrationEventHandler;
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.tenantremoval.TenantRemovalIntegrationEventHandler; import org.opencdmp.integrationevent.outbox.tenantremoval.TenantRemovalIntegrationEventHandler;
@ -15,25 +18,31 @@ import org.opencdmp.integrationevent.outbox.tenanttouched.TenantTouchedIntegrati
import org.opencdmp.integrationevent.outbox.tenanttouched.TenantTouchedIntegrationEventHandler; import org.opencdmp.integrationevent.outbox.tenanttouched.TenantTouchedIntegrationEventHandler;
import org.opencdmp.integrationevent.outbox.userremoval.UserRemovalIntegrationEventHandler; import org.opencdmp.integrationevent.outbox.userremoval.UserRemovalIntegrationEventHandler;
import org.opencdmp.integrationevent.outbox.usertouched.UserTouchedIntegrationEventHandler; import org.opencdmp.integrationevent.outbox.usertouched.UserTouchedIntegrationEventHandler;
import org.opencdmp.model.DescriptionTemplateType;
import org.opencdmp.model.Tenant; import org.opencdmp.model.Tenant;
import org.opencdmp.model.description.Description; import org.opencdmp.model.description.Description;
import org.opencdmp.model.descriptiontemplate.DescriptionTemplate;
import org.opencdmp.model.plan.Plan; import org.opencdmp.model.plan.Plan;
import org.opencdmp.model.planblueprint.PlanBlueprint;
import org.opencdmp.model.prefillingsource.PrefillingSource;
import org.opencdmp.model.referencetype.ReferenceType;
import org.opencdmp.model.user.User; import org.opencdmp.model.user.User;
import org.opencdmp.query.DescriptionQuery; import org.opencdmp.query.*;
import org.opencdmp.query.PlanQuery; import org.opencdmp.service.accounting.AccountingProperties;
import org.opencdmp.query.TenantQuery; import org.slf4j.Logger;
import org.opencdmp.query.UserQuery;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
@Service @Service
public class MaintenanceServiceImpl implements MaintenanceService { public class MaintenanceServiceImpl implements MaintenanceService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(MaintenanceServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(MaintenanceServiceImpl.class));
private static final Logger log = LoggerFactory.getLogger(MaintenanceServiceImpl.class);
private final TenantEntityManager entityManager; private final TenantEntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
@ -47,12 +56,14 @@ public class MaintenanceServiceImpl implements MaintenanceService {
private final TenantRemovalIntegrationEventHandler tenantRemovalIntegrationEventHandler; private final TenantRemovalIntegrationEventHandler tenantRemovalIntegrationEventHandler;
private final AnnotationEntityRemovalIntegrationEventHandler annotationEntityRemovalIntegrationEventHandler; private final AnnotationEntityRemovalIntegrationEventHandler annotationEntityRemovalIntegrationEventHandler;
private final AnnotationEntityTouchedIntegrationEventHandler annotationEntityTouchedIntegrationEventHandler; private final AnnotationEntityTouchedIntegrationEventHandler annotationEntityTouchedIntegrationEventHandler;
private final AccountingEntryCreatedIntegrationEventHandler accountingEntryCreatedIntegrationEventHandler;
private final TenantScope tenantScope; private final TenantScope tenantScope;
private final TenantEntityManager tenantEntityManager;
private final AccountingProperties accountingProperties;
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, TenantScope tenantScope) { QueryFactory queryFactory, UserTouchedIntegrationEventHandler userTouchedIntegrationEventHandler, UserRemovalIntegrationEventHandler userRemovalIntegrationEventHandler, TenantTouchedIntegrationEventHandler tenantTouchedIntegrationEventHandler, TenantRemovalIntegrationEventHandler tenantRemovalIntegrationEventHandler, AnnotationEntityRemovalIntegrationEventHandler annotationEntityRemovalIntegrationEventHandler, AnnotationEntityTouchedIntegrationEventHandler annotationEntityTouchedIntegrationEventHandler, AccountingEntryCreatedIntegrationEventHandler accountingEntryCreatedIntegrationEventHandler, TenantScope tenantScope, TenantEntityManager tenantEntityManager, AccountingProperties accountingProperties) {
this.entityManager = entityManager; this.entityManager = entityManager;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
@ -62,7 +73,10 @@ public class MaintenanceServiceImpl implements MaintenanceService {
this.tenantRemovalIntegrationEventHandler = tenantRemovalIntegrationEventHandler; this.tenantRemovalIntegrationEventHandler = tenantRemovalIntegrationEventHandler;
this.annotationEntityRemovalIntegrationEventHandler = annotationEntityRemovalIntegrationEventHandler; this.annotationEntityRemovalIntegrationEventHandler = annotationEntityRemovalIntegrationEventHandler;
this.annotationEntityTouchedIntegrationEventHandler = annotationEntityTouchedIntegrationEventHandler; this.annotationEntityTouchedIntegrationEventHandler = annotationEntityTouchedIntegrationEventHandler;
this.accountingEntryCreatedIntegrationEventHandler = accountingEntryCreatedIntegrationEventHandler;
this.tenantScope = tenantScope; this.tenantScope = tenantScope;
this.tenantEntityManager = tenantEntityManager;
this.accountingProperties = accountingProperties;
} }
@ -191,4 +205,180 @@ public class MaintenanceServiceImpl implements MaintenanceService {
} }
return tenants; return tenants;
} }
@Override
public void sendPlanAccountingEntriesEvents() throws InvalidApplicationException {
logger.debug("send plan accounting entries queue events");
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
try {
this.tenantEntityManager.disableTenantFilters();
List<PlanEntity> items = this.queryFactory.query(PlanQuery.class).disableTracking().collectAs(new BaseFieldSet().ensure(Plan._id).ensure(Plan._isActive).ensure(Plan._creator));
List<UserCredentialEntity> userCredentials = this.queryFactory.query(UserCredentialQuery.class).disableTracking().userIds(items.stream().map(x -> x.getCreatorId()).distinct().collect(Collectors.toList())).collect();
for (PlanEntity item : items) {
String subjectId;
if (userCredentials != null) {
UserCredentialEntity userCredential = userCredentials.stream().filter(x -> x.getUserId().equals(item.getCreatorId())).findFirst().orElse(null);
if (userCredential != null) subjectId = userCredential.getExternalId();
else subjectId = item.getCreatorId().toString();
} else {
subjectId = item.getCreatorId().toString();
}
if (item.getIsActive().equals(IsActive.Active)) this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(UsageLimitTargetMetric.PLAN_COUNT.getValue(), AccountingValueType.Plus, subjectId, item.getTenantId());
else this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(UsageLimitTargetMetric.PLAN_COUNT.getValue(), AccountingValueType.Minus, subjectId, item.getTenantId());
}
} finally {
this.tenantEntityManager.reloadTenantFilters();
}
}
@Override
public void sendBlueprintAccountingEntriesEvents() throws InvalidApplicationException {
logger.debug("send plan blueprint accounting entries queue events");
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
try {
this.tenantEntityManager.disableTenantFilters();
List<PlanBlueprintEntity> items = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().collectAs(new BaseFieldSet().ensure(PlanBlueprint._id).ensure(PlanBlueprint._isActive));
for (PlanBlueprintEntity item : items) {
String subjectId = accountingProperties.getSubjectId();
if (item.getIsActive().equals(IsActive.Active)) this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(UsageLimitTargetMetric.BLUEPRINT_COUNT.getValue(), AccountingValueType.Plus, subjectId, item.getTenantId());
else this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(UsageLimitTargetMetric.BLUEPRINT_COUNT.getValue(), AccountingValueType.Minus, subjectId, item.getTenantId());
}
} finally {
this.tenantEntityManager.reloadTenantFilters();
}
}
@Override
public void sendDescriptionAccountingEntriesEvents() throws InvalidApplicationException {
logger.debug("send descriptions entries queue events");
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
try {
this.tenantEntityManager.disableTenantFilters();
List<DescriptionEntity> items = this.queryFactory.query(DescriptionQuery.class).disableTracking().collectAs(new BaseFieldSet().ensure(Description._id).ensure(Description._isActive).ensure(Description._createdBy));
List<UserCredentialEntity> userCredentials = this.queryFactory.query(UserCredentialQuery.class).disableTracking().userIds(items.stream().map(x -> x.getCreatedById()).distinct().collect(Collectors.toList())).collect();
for (DescriptionEntity item : items) {
String subjectId;
if (userCredentials != null) {
UserCredentialEntity userCredential = userCredentials.stream().filter(x -> x.getUserId().equals(item.getCreatedById())).findFirst().orElse(null);
if (userCredential != null) subjectId = userCredential.getExternalId();
else subjectId = item.getCreatedById().toString();
} else {
subjectId = item.getCreatedById().toString();
}
if (item.getIsActive().equals(IsActive.Active)) this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(UsageLimitTargetMetric.DESCRIPTION_COUNT.getValue(), AccountingValueType.Plus, subjectId, item.getTenantId());
else this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(UsageLimitTargetMetric.DESCRIPTION_COUNT.getValue(), AccountingValueType.Minus, subjectId, item.getTenantId());
}
} finally {
this.tenantEntityManager.reloadTenantFilters();
}
}
@Override
public void sendDescriptionTemplateAccountingEntriesEvents() throws InvalidApplicationException {
logger.debug("send description templates accounting entries queue events");
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
try {
this.tenantEntityManager.disableTenantFilters();
List<DescriptionTemplateEntity> items = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().collectAs(new BaseFieldSet().ensure(DescriptionTemplate._id).ensure(DescriptionTemplate._isActive));
for (DescriptionTemplateEntity item : items) {
String subjectId = accountingProperties.getSubjectId();
if (item.getIsActive().equals(IsActive.Active)) this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(UsageLimitTargetMetric.DESCRIPTION_TEMPLATE_COUNT.getValue(), AccountingValueType.Plus, subjectId, item.getTenantId());
else this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(UsageLimitTargetMetric.DESCRIPTION_TEMPLATE_COUNT.getValue(), AccountingValueType.Minus, subjectId, item.getTenantId());
}
} finally {
this.tenantEntityManager.reloadTenantFilters();
}
}
@Override
public void sendDescriptionTemplateTypeAccountingEntriesEvents() throws InvalidApplicationException {
logger.debug("send description templates types accounting entries queue events");
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
try {
this.tenantEntityManager.disableTenantFilters();
List<DescriptionTemplateTypeEntity> items = this.queryFactory.query(DescriptionTemplateTypeQuery.class).disableTracking().collectAs(new BaseFieldSet().ensure(DescriptionTemplateType._id).ensure(DescriptionTemplateType._isActive));
for (DescriptionTemplateTypeEntity item : items) {
String subjectId = accountingProperties.getSubjectId();
if (item.getIsActive().equals(IsActive.Active)) this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(UsageLimitTargetMetric.DESCRIPTION_TEMPLATE_TYPE_COUNT.getValue(), AccountingValueType.Plus, subjectId, item.getTenantId());
else this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(UsageLimitTargetMetric.DESCRIPTION_TEMPLATE_TYPE_COUNT.getValue(), AccountingValueType.Minus, subjectId, item.getTenantId());
}
} finally {
this.tenantEntityManager.reloadTenantFilters();
}
}
@Override
public void sendPrefillingSourceAccountingEntriesEvents() throws InvalidApplicationException {
logger.debug("send prefilling sources accounting entries queue events");
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
try {
this.tenantEntityManager.disableTenantFilters();
List<PrefillingSourceEntity> items = this.queryFactory.query(PrefillingSourceQuery.class).disableTracking().collectAs(new BaseFieldSet().ensure(PrefillingSource._id).ensure(PrefillingSource._isActive));
for (PrefillingSourceEntity item : items) {
String subjectId = accountingProperties.getSubjectId();
if (item.getIsActive().equals(IsActive.Active)) this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(UsageLimitTargetMetric.PREFILLING_SOURCES_COUNT.getValue(), AccountingValueType.Plus, subjectId, item.getTenantId());
else this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(UsageLimitTargetMetric.PREFILLING_SOURCES_COUNT.getValue(), AccountingValueType.Minus, subjectId, item.getTenantId());
}
} finally {
this.tenantEntityManager.reloadTenantFilters();
}
}
@Override
public void sendReferenceTypeAccountingEntriesEvents() throws InvalidApplicationException {
logger.debug("send reference types accounting entries queue events");
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
try {
this.tenantEntityManager.disableTenantFilters();
List<ReferenceTypeEntity> items = this.queryFactory.query(ReferenceTypeQuery.class).disableTracking().collectAs(new BaseFieldSet().ensure(ReferenceType._id).ensure(ReferenceType._isActive));
for (ReferenceTypeEntity item : items) {
String subjectId = accountingProperties.getSubjectId();
if (item.getIsActive().equals(IsActive.Active)) this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(UsageLimitTargetMetric.REFERENCE_TYPE_COUNT.getValue(), AccountingValueType.Plus, subjectId, item.getTenantId());
else this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(UsageLimitTargetMetric.REFERENCE_TYPE_COUNT.getValue(), AccountingValueType.Minus, subjectId, item.getTenantId());
}
} finally {
this.tenantEntityManager.reloadTenantFilters();
}
}
@Override
public void sendUserAccountingEntriesEvents() throws InvalidApplicationException {
logger.debug("send users accounting entries queue events");
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
try {
this.tenantEntityManager.disableTenantFilters();
List<TenantUserEntity> items = this.queryFactory.query(TenantUserQuery.class).disableTracking().collectAs(new BaseFieldSet().ensure(TenantUserEntity._id).ensure(TenantUserEntity._userId).ensure(TenantUserEntity._isActive));
List<UserCredentialEntity> userCredentials = this.queryFactory.query(UserCredentialQuery.class).disableTracking().userIds(items.stream().map(x -> x.getUserId()).distinct().collect(Collectors.toList())).collect();
for (TenantUserEntity item : items) {
String subjectId;
if (userCredentials != null) {
UserCredentialEntity userCredential = userCredentials.stream().filter(x -> x.getUserId().equals(item.getUserId())).findFirst().orElse(null);
if (userCredential != null) subjectId = userCredential.getExternalId();
else subjectId = item.getUserId().toString();
} else {
subjectId = item.getUserId().toString();
}
if (item.getIsActive().equals(IsActive.Active)) this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(UsageLimitTargetMetric.USER_COUNT.getValue(), AccountingValueType.Plus, subjectId, item.getTenantId());
else this.accountingEntryCreatedIntegrationEventHandler.handleAccountingEntry(UsageLimitTargetMetric.USER_COUNT.getValue(), AccountingValueType.Minus, subjectId, item.getTenantId());
}
} finally {
this.tenantEntityManager.reloadTenantFilters();
}
}
} }

View File

@ -101,4 +101,84 @@ public class MaintenanceController {
this.auditService.track(AuditableAction.Maintenance_SendDescriptionTouchEvents); this.auditService.track(AuditableAction.Maintenance_SendDescriptionTouchEvents);
} }
@RequestMapping(method = RequestMethod.POST, value = "/events/plans/accounting-entry")
public void sendPlanAccountingEntriesEvents() throws InvalidApplicationException {
logger.debug("send plan accounting entries queue events");
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
this.maintenanceService.sendPlanAccountingEntriesEvents();
this.auditService.track(AuditableAction.Maintenance_SendPlanAccountingEntriesEvents);
}
@RequestMapping(method = RequestMethod.POST, value = "/events/descriptions/accounting-entry")
public void sendDescriptionAccountingEntriesEvents() throws InvalidApplicationException {
logger.debug("send plan accounting entries queue events");
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
this.maintenanceService.sendDescriptionAccountingEntriesEvents();
this.auditService.track(AuditableAction.Maintenance_SendDescriptionAccountingEntriesEvents);
}
@RequestMapping(method = RequestMethod.POST, value = "/events/plan-blueprints/accounting-entry")
public void sendBlueprintAccountingEntriesEvents() throws InvalidApplicationException {
logger.debug("send blueprints accounting entries queue events");
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
this.maintenanceService.sendBlueprintAccountingEntriesEvents();
this.auditService.track(AuditableAction.Maintenance_SendBlueprintAccountingEntriesEvents);
}
@RequestMapping(method = RequestMethod.POST, value = "/events/description-templates/accounting-entry")
public void sendDescriptionTemplateAccountingEntriesEvents() throws InvalidApplicationException {
logger.debug("send description templates accounting entries queue events");
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
this.maintenanceService.sendDescriptionTemplateAccountingEntriesEvents();
this.auditService.track(AuditableAction.Maintenance_SendDescriptionTemplateAccountingEntriesEvents);
}
@RequestMapping(method = RequestMethod.POST, value = "/events/description-template-types/accounting-entry")
public void sendDescriptionTemplateTypeAccountingEntriesEvents() throws InvalidApplicationException {
logger.debug("send description template types accounting entries queue events");
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
this.maintenanceService.sendDescriptionTemplateTypeAccountingEntriesEvents();
this.auditService.track(AuditableAction.Maintenance_SendDescriptionTemplateTypeAccountingEntriesEvents);
}
@RequestMapping(method = RequestMethod.POST, value = "/events/prefilling-sources/accounting-entry")
public void sendPrefillingSourceAccountingEntriesEvents() throws InvalidApplicationException {
logger.debug("send prefilling source accounting entries queue events");
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
this.maintenanceService.sendPrefillingSourceAccountingEntriesEvents();
this.auditService.track(AuditableAction.Maintenance_SendPrefillingSourceAccountingEntriesEvents);
}
@RequestMapping(method = RequestMethod.POST, value = "/events/reference-types/accounting-entry")
public void sendReferenceTypeAccountingEntriesEvents() throws InvalidApplicationException {
logger.debug("send reference type accounting entries queue events");
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
this.maintenanceService.sendReferenceTypeAccountingEntriesEvents();
this.auditService.track(AuditableAction.Maintenance_SendReferenceTypeAccountingEntriesEvents);
}
@RequestMapping(method = RequestMethod.POST, value = "/events/users/accounting-entry")
public void sendUserAccountingEntriesEvents() throws InvalidApplicationException {
logger.debug("send user accounting entries queue events");
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
this.maintenanceService.sendUserAccountingEntriesEvents();
this.auditService.track(AuditableAction.Maintenance_SendUserAccountingEntriesEvents);
}
} }

View File

@ -1,3 +1,4 @@
accounting: accounting:
serviceId: ${SERVICE_ID} serviceId: ${SERVICE_ID}
action: ${ACCOUNTING_ACTION} action: ${ACCOUNTING_ACTION}
subjectId: unknown

View File

@ -56,4 +56,61 @@ export class MaintenanceService extends BaseService {
.post<any>(url, null).pipe( .post<any>(url, null).pipe(
catchError((error: any) => throwError(error))); catchError((error: any) => throwError(error)));
} }
sendPlanAccountingEntriesEvents(): Observable<any> {
const url = `${this.apiBase}/events/plans/accounting-entry`;
return this.http
.post<any>(url, null).pipe(
catchError((error: any) => throwError(error)));
}
sendDescriptionAccountingEntriesEvents(): Observable<any> {
const url = `${this.apiBase}/events/descriptions/accounting-entry`;
return this.http
.post<any>(url, null).pipe(
catchError((error: any) => throwError(error)));
}
sendBlueprintAccountingEntriesEvents(): Observable<any> {
const url = `${this.apiBase}/events/plan-blueprints/accounting-entry`;
return this.http
.post<any>(url, null).pipe(
catchError((error: any) => throwError(error)));
}
sendDescriptionTemplateAccountingEntriesEvents(): Observable<any> {
const url = `${this.apiBase}/events/description-templates/accounting-entry`;
return this.http
.post<any>(url, null).pipe(
catchError((error: any) => throwError(error)));
}
sendDescriptionTemplateTypeAccountingEntriesEvents(): Observable<any> {
const url = `${this.apiBase}/events/description-template-types/accounting-entry`;
return this.http
.post<any>(url, null).pipe(
catchError((error: any) => throwError(error)));
}
sendPrefillingSourceAccountingEntriesEvents(): Observable<any> {
const url = `${this.apiBase}/events/prefilling-sources/accounting-entry`;
return this.http
.post<any>(url, null).pipe(
catchError((error: any) => throwError(error)));
}
sendReferenceTypeAccountingEntriesEvents(): Observable<any> {
const url = `${this.apiBase}/events/reference-types/accounting-entry`;
return this.http
.post<any>(url, null).pipe(
catchError((error: any) => throwError(error)));
}
sendUserAccountingEntriesEvents(): Observable<any> {
const url = `${this.apiBase}/events/users/accounting-entry`;
return this.http
.post<any>(url, null).pipe(
catchError((error: any) => throwError(error)));
}
} }

View File

@ -35,6 +35,14 @@
<button mat-raised-button color="primary" (click)="sendTenantTouchEvents($event)" class="lightblue-btn button">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-TENANT-TOUCH')}}</button> <button mat-raised-button color="primary" (click)="sendTenantTouchEvents($event)" class="lightblue-btn button">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-TENANT-TOUCH')}}</button>
<button mat-raised-button color="primary" (click)="sendPlanTouchEvents($event)" class="lightblue-btn button">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-PLAN-TOUCH')}}</button> <button mat-raised-button color="primary" (click)="sendPlanTouchEvents($event)" class="lightblue-btn button">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-PLAN-TOUCH')}}</button>
<button mat-raised-button color="primary" (click)="sendDescriptionTouchEvents($event)" class="lightblue-btn button">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-DESCRIPTION-TOUCH')}}</button> <button mat-raised-button color="primary" (click)="sendDescriptionTouchEvents($event)" class="lightblue-btn button">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-DESCRIPTION-TOUCH')}}</button>
<button mat-raised-button color="primary" (click)="sendPlanAccountingEntriesEvents($event)" class="lightblue-btn button">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-PLAN-ACCOUNTING-ENTRIES')}}</button>
<button mat-raised-button color="primary" (click)="sendDescriptionAccountingEntriesEvents($event)" class="lightblue-btn button">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-DESCRIPTION-ACCOUNTING-ENTRIES')}}</button>
<button mat-raised-button color="primary" (click)="sendBlueprintAccountingEntriesEvents($event)" class="lightblue-btn button">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-PLAN-BLUEPRINT-ACCOUNTING-ENTRIES')}}</button>
<button mat-raised-button color="primary" (click)="sendDescriptionTemplateAccountingEntriesEvents($event)" class="lightblue-btn button">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-DESCRIPTION-TEMPLATE-ACCOUNTING-ENTRIES')}}</button>
<button mat-raised-button color="primary" (click)="sendDescriptionTemplateTypeAccountingEntriesEvents($event)" class="lightblue-btn button">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-DESCRIPTION-TEMPLATE-TYPE-ACCOUNTING-ENTRIES')}}</button>
<button mat-raised-button color="primary" (click)="sendPrefillingSourceAccountingEntriesEvents($event)" class="lightblue-btn button">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-PREFILLING-SOURCE-ACCOUNTING-ENTRIES')}}</button>
<button mat-raised-button color="primary" (click)="sendReferenceTypeAccountingEntriesEvents($event)" class="lightblue-btn button">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES')}}</button>
<button mat-raised-button color="primary" (click)="sendUserAccountingEntriesEvents($event)" class="lightblue-btn button">{{language.instant('MAINTENANCE-TASKS.SECTIONS.EVENTS.ACTIONS.SEND-USER-ACCOUNTING-ENTRIES')}}</button>
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>
</mat-accordion> </mat-accordion>

View File

@ -217,6 +217,254 @@ export class MaintenanceTasksComponent extends BaseComponent implements OnInit {
); );
} }
sendPlanAccountingEntriesEvents(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.doSendPlanAccountingEntriesEvents(ev);
}
});
}
private doSendPlanAccountingEntriesEvents(ev: Event) {
(ev.target as HTMLButtonElement).disabled = true;
this.maintenanceService.sendPlanAccountingEntriesEvents().pipe(takeUntil(this._destroyed)).subscribe(
_ => {
(ev.target as HTMLButtonElement).disabled = false;
this.onCallbackSuccess();
},
error => {
(ev.target as HTMLButtonElement).disabled = false;
this.onCallbackError(error);
}
);
}
sendDescriptionAccountingEntriesEvents(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.doSendDescriptionAccountingEntriesEvents(ev);
}
});
}
private doSendDescriptionAccountingEntriesEvents(ev: Event) {
(ev.target as HTMLButtonElement).disabled = true;
this.maintenanceService.sendDescriptionAccountingEntriesEvents().pipe(takeUntil(this._destroyed)).subscribe(
_ => {
(ev.target as HTMLButtonElement).disabled = false;
this.onCallbackSuccess();
},
error => {
(ev.target as HTMLButtonElement).disabled = false;
this.onCallbackError(error);
}
);
}
sendBlueprintAccountingEntriesEvents(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.doSendBlueprintAccountingEntriesEvents(ev);
}
});
}
private doSendBlueprintAccountingEntriesEvents(ev: Event) {
(ev.target as HTMLButtonElement).disabled = true;
this.maintenanceService.sendBlueprintAccountingEntriesEvents().pipe(takeUntil(this._destroyed)).subscribe(
_ => {
(ev.target as HTMLButtonElement).disabled = false;
this.onCallbackSuccess();
},
error => {
(ev.target as HTMLButtonElement).disabled = false;
this.onCallbackError(error);
}
);
}
sendDescriptionTemplateAccountingEntriesEvents(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.doSendDescriptionTemplateAccountingEntriesEvents(ev);
}
});
}
private doSendDescriptionTemplateAccountingEntriesEvents(ev: Event) {
(ev.target as HTMLButtonElement).disabled = true;
this.maintenanceService.sendDescriptionTemplateAccountingEntriesEvents().pipe(takeUntil(this._destroyed)).subscribe(
_ => {
(ev.target as HTMLButtonElement).disabled = false;
this.onCallbackSuccess();
},
error => {
(ev.target as HTMLButtonElement).disabled = false;
this.onCallbackError(error);
}
);
}
sendDescriptionTemplateTypeAccountingEntriesEvents(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.doSendDescriptionTemplateTypeAccountingEntriesEvents(ev);
}
});
}
private doSendDescriptionTemplateTypeAccountingEntriesEvents(ev: Event) {
(ev.target as HTMLButtonElement).disabled = true;
this.maintenanceService.sendDescriptionTemplateTypeAccountingEntriesEvents().pipe(takeUntil(this._destroyed)).subscribe(
_ => {
(ev.target as HTMLButtonElement).disabled = false;
this.onCallbackSuccess();
},
error => {
(ev.target as HTMLButtonElement).disabled = false;
this.onCallbackError(error);
}
);
}
sendPrefillingSourceAccountingEntriesEvents(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.doSendPrefillingSourceAccountingEntriesEvents(ev);
}
});
}
private doSendPrefillingSourceAccountingEntriesEvents(ev: Event) {
(ev.target as HTMLButtonElement).disabled = true;
this.maintenanceService.sendPrefillingSourceAccountingEntriesEvents().pipe(takeUntil(this._destroyed)).subscribe(
_ => {
(ev.target as HTMLButtonElement).disabled = false;
this.onCallbackSuccess();
},
error => {
(ev.target as HTMLButtonElement).disabled = false;
this.onCallbackError(error);
}
);
}
sendReferenceTypeAccountingEntriesEvents(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.doSendReferenceTypeAccountingEntriesEvents(ev);
}
});
}
private doSendReferenceTypeAccountingEntriesEvents(ev: Event) {
(ev.target as HTMLButtonElement).disabled = true;
this.maintenanceService.sendReferenceTypeAccountingEntriesEvents().pipe(takeUntil(this._destroyed)).subscribe(
_ => {
(ev.target as HTMLButtonElement).disabled = false;
this.onCallbackSuccess();
},
error => {
(ev.target as HTMLButtonElement).disabled = false;
this.onCallbackError(error);
}
);
}
sendUserAccountingEntriesEvents(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.doSendUserAccountingEntriesEvents(ev);
}
});
}
private doSendUserAccountingEntriesEvents(ev: Event) {
(ev.target as HTMLButtonElement).disabled = true;
this.maintenanceService.sendUserAccountingEntriesEvents().pipe(takeUntil(this._destroyed)).subscribe(
_ => {
(ev.target as HTMLButtonElement).disabled = false;
this.onCallbackSuccess();
},
error => {
(ev.target as HTMLButtonElement).disabled = false;
this.onCallbackError(error);
}
);
}
onCallbackSuccess(): void { onCallbackSuccess(): void {
this.uiNotificationService.snackBarNotification(this.translate.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); this.uiNotificationService.snackBarNotification(this.translate.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/reload']).then(() => this.router.navigate([this.routerUtils.generateUrl('/maintenance-tasks')])); this.router.navigate(['/reload']).then(() => this.router.navigate([this.routerUtils.generateUrl('/maintenance-tasks')]));

View File

@ -366,7 +366,15 @@
"SEND-USER-TOUCH": "Send user touch events", "SEND-USER-TOUCH": "Send user touch events",
"SEND-TENANT-TOUCH": "Send tenant touch events", "SEND-TENANT-TOUCH": "Send tenant touch events",
"SEND-PLAN-TOUCH": "Send plan touch events", "SEND-PLAN-TOUCH": "Send plan touch events",
"SEND-DESCRIPTION-TOUCH": "Send description touch events" "SEND-DESCRIPTION-TOUCH": "Send description touch events",
"SEND-PLAN-ACCOUNTING-ENTRIES": "Send plan accounting entries events",
"SEND-PLAN-BLUEPRINT-ACCOUNTING-ENTRIES": "Send plan blueprint accounting entries events",
"SEND-DESCRIPTION-ACCOUNTING-ENTRIES": "Send description accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-ACCOUNTING-ENTRIES": "Send description template accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-TYPE-ACCOUNTING-ENTRIES": "Send description template types accounting entries events",
"SEND-PREFILLING-SOURCE-ACCOUNTING-ENTRIES": "Send prefilling source accounting entries events",
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events"
} }
} }
}, },

View File

@ -366,7 +366,15 @@
"SEND-USER-TOUCH": "Send user touch events", "SEND-USER-TOUCH": "Send user touch events",
"SEND-TENANT-TOUCH": "Send tenant touch events", "SEND-TENANT-TOUCH": "Send tenant touch events",
"SEND-PLAN-TOUCH": "Send plan touch events", "SEND-PLAN-TOUCH": "Send plan touch events",
"SEND-DESCRIPTION-TOUCH": "Send description touch events" "SEND-DESCRIPTION-TOUCH": "Send description touch events",
"SEND-PLAN-ACCOUNTING-ENTRIES": "Send plan accounting entries events",
"SEND-PLAN-BLUEPRINT-ACCOUNTING-ENTRIES": "Send plan blueprint accounting entries events",
"SEND-DESCRIPTION-ACCOUNTING-ENTRIES": "Send description accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-ACCOUNTING-ENTRIES": "Send description template accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-TYPE-ACCOUNTING-ENTRIES": "Send description template types accounting entries events",
"SEND-PREFILLING-SOURCE-ACCOUNTING-ENTRIES": "Send prefilling source accounting entries events",
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events"
} }
} }
}, },

View File

@ -366,7 +366,15 @@
"SEND-USER-TOUCH": "Send user touch events", "SEND-USER-TOUCH": "Send user touch events",
"SEND-TENANT-TOUCH": "Send tenant touch events", "SEND-TENANT-TOUCH": "Send tenant touch events",
"SEND-PLAN-TOUCH": "Send plan touch events", "SEND-PLAN-TOUCH": "Send plan touch events",
"SEND-DESCRIPTION-TOUCH": "Send description touch events" "SEND-DESCRIPTION-TOUCH": "Send description touch events",
"SEND-PLAN-ACCOUNTING-ENTRIES": "Send plan accounting entries events",
"SEND-PLAN-BLUEPRINT-ACCOUNTING-ENTRIES": "Send plan blueprint accounting entries events",
"SEND-DESCRIPTION-ACCOUNTING-ENTRIES": "Send description accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-ACCOUNTING-ENTRIES": "Send description template accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-TYPE-ACCOUNTING-ENTRIES": "Send description template types accounting entries events",
"SEND-PREFILLING-SOURCE-ACCOUNTING-ENTRIES": "Send prefilling source accounting entries events",
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events"
} }
} }
}, },

View File

@ -366,7 +366,15 @@
"SEND-USER-TOUCH": "Send user touch events", "SEND-USER-TOUCH": "Send user touch events",
"SEND-TENANT-TOUCH": "Send tenant touch events", "SEND-TENANT-TOUCH": "Send tenant touch events",
"SEND-PLAN-TOUCH": "Send plan touch events", "SEND-PLAN-TOUCH": "Send plan touch events",
"SEND-DESCRIPTION-TOUCH": "Send description touch events" "SEND-DESCRIPTION-TOUCH": "Send description touch events",
"SEND-PLAN-ACCOUNTING-ENTRIES": "Send plan accounting entries events",
"SEND-PLAN-BLUEPRINT-ACCOUNTING-ENTRIES": "Send plan blueprint accounting entries events",
"SEND-DESCRIPTION-ACCOUNTING-ENTRIES": "Send description accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-ACCOUNTING-ENTRIES": "Send description template accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-TYPE-ACCOUNTING-ENTRIES": "Send description template types accounting entries events",
"SEND-PREFILLING-SOURCE-ACCOUNTING-ENTRIES": "Send prefilling source accounting entries events",
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events"
} }
} }
}, },

View File

@ -366,7 +366,15 @@
"SEND-USER-TOUCH": "Send user touch events", "SEND-USER-TOUCH": "Send user touch events",
"SEND-TENANT-TOUCH": "Send tenant touch events", "SEND-TENANT-TOUCH": "Send tenant touch events",
"SEND-PLAN-TOUCH": "Send plan touch events", "SEND-PLAN-TOUCH": "Send plan touch events",
"SEND-DESCRIPTION-TOUCH": "Send description touch events" "SEND-DESCRIPTION-TOUCH": "Send description touch events",
"SEND-PLAN-ACCOUNTING-ENTRIES": "Send plan accounting entries events",
"SEND-PLAN-BLUEPRINT-ACCOUNTING-ENTRIES": "Send plan blueprint accounting entries events",
"SEND-DESCRIPTION-ACCOUNTING-ENTRIES": "Send description accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-ACCOUNTING-ENTRIES": "Send description template accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-TYPE-ACCOUNTING-ENTRIES": "Send description template types accounting entries events",
"SEND-PREFILLING-SOURCE-ACCOUNTING-ENTRIES": "Send prefilling source accounting entries events",
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events"
} }
} }
}, },

View File

@ -366,7 +366,15 @@
"SEND-USER-TOUCH": "Send user touch events", "SEND-USER-TOUCH": "Send user touch events",
"SEND-TENANT-TOUCH": "Send tenant touch events", "SEND-TENANT-TOUCH": "Send tenant touch events",
"SEND-PLAN-TOUCH": "Send plan touch events", "SEND-PLAN-TOUCH": "Send plan touch events",
"SEND-DESCRIPTION-TOUCH": "Send description touch events" "SEND-DESCRIPTION-TOUCH": "Send description touch events",
"SEND-PLAN-ACCOUNTING-ENTRIES": "Send plan accounting entries events",
"SEND-PLAN-BLUEPRINT-ACCOUNTING-ENTRIES": "Send plan blueprint accounting entries events",
"SEND-DESCRIPTION-ACCOUNTING-ENTRIES": "Send description accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-ACCOUNTING-ENTRIES": "Send description template accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-TYPE-ACCOUNTING-ENTRIES": "Send description template types accounting entries events",
"SEND-PREFILLING-SOURCE-ACCOUNTING-ENTRIES": "Send prefilling source accounting entries events",
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events"
} }
} }
}, },

View File

@ -366,7 +366,15 @@
"SEND-USER-TOUCH": "Send user touch events", "SEND-USER-TOUCH": "Send user touch events",
"SEND-TENANT-TOUCH": "Send tenant touch events", "SEND-TENANT-TOUCH": "Send tenant touch events",
"SEND-PLAN-TOUCH": "Send plan touch events", "SEND-PLAN-TOUCH": "Send plan touch events",
"SEND-DESCRIPTION-TOUCH": "Send description touch events" "SEND-DESCRIPTION-TOUCH": "Send description touch events",
"SEND-PLAN-ACCOUNTING-ENTRIES": "Send plan accounting entries events",
"SEND-PLAN-BLUEPRINT-ACCOUNTING-ENTRIES": "Send plan blueprint accounting entries events",
"SEND-DESCRIPTION-ACCOUNTING-ENTRIES": "Send description accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-ACCOUNTING-ENTRIES": "Send description template accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-TYPE-ACCOUNTING-ENTRIES": "Send description template types accounting entries events",
"SEND-PREFILLING-SOURCE-ACCOUNTING-ENTRIES": "Send prefilling source accounting entries events",
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events"
} }
} }
}, },

View File

@ -366,7 +366,15 @@
"SEND-USER-TOUCH": "Send user touch events", "SEND-USER-TOUCH": "Send user touch events",
"SEND-TENANT-TOUCH": "Send tenant touch events", "SEND-TENANT-TOUCH": "Send tenant touch events",
"SEND-PLAN-TOUCH": "Send plan touch events", "SEND-PLAN-TOUCH": "Send plan touch events",
"SEND-DESCRIPTION-TOUCH": "Send description touch events" "SEND-DESCRIPTION-TOUCH": "Send description touch events",
"SEND-PLAN-ACCOUNTING-ENTRIES": "Send plan accounting entries events",
"SEND-PLAN-BLUEPRINT-ACCOUNTING-ENTRIES": "Send plan blueprint accounting entries events",
"SEND-DESCRIPTION-ACCOUNTING-ENTRIES": "Send description accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-ACCOUNTING-ENTRIES": "Send description template accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-TYPE-ACCOUNTING-ENTRIES": "Send description template types accounting entries events",
"SEND-PREFILLING-SOURCE-ACCOUNTING-ENTRIES": "Send prefilling source accounting entries events",
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events"
} }
} }
}, },

View File

@ -366,7 +366,15 @@
"SEND-USER-TOUCH": "Send user touch events", "SEND-USER-TOUCH": "Send user touch events",
"SEND-TENANT-TOUCH": "Send tenant touch events", "SEND-TENANT-TOUCH": "Send tenant touch events",
"SEND-PLAN-TOUCH": "Send plan touch events", "SEND-PLAN-TOUCH": "Send plan touch events",
"SEND-DESCRIPTION-TOUCH": "Send description touch events" "SEND-DESCRIPTION-TOUCH": "Send description touch events",
"SEND-PLAN-ACCOUNTING-ENTRIES": "Send plan accounting entries events",
"SEND-PLAN-BLUEPRINT-ACCOUNTING-ENTRIES": "Send plan blueprint accounting entries events",
"SEND-DESCRIPTION-ACCOUNTING-ENTRIES": "Send description accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-ACCOUNTING-ENTRIES": "Send description template accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-TYPE-ACCOUNTING-ENTRIES": "Send description template types accounting entries events",
"SEND-PREFILLING-SOURCE-ACCOUNTING-ENTRIES": "Send prefilling source accounting entries events",
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events"
} }
} }
}, },

View File

@ -366,7 +366,15 @@
"SEND-USER-TOUCH": "Send user touch events", "SEND-USER-TOUCH": "Send user touch events",
"SEND-TENANT-TOUCH": "Send tenant touch events", "SEND-TENANT-TOUCH": "Send tenant touch events",
"SEND-PLAN-TOUCH": "Send plan touch events", "SEND-PLAN-TOUCH": "Send plan touch events",
"SEND-DESCRIPTION-TOUCH": "Send description touch events" "SEND-DESCRIPTION-TOUCH": "Send description touch events",
"SEND-PLAN-ACCOUNTING-ENTRIES": "Send plan accounting entries events",
"SEND-PLAN-BLUEPRINT-ACCOUNTING-ENTRIES": "Send plan blueprint accounting entries events",
"SEND-DESCRIPTION-ACCOUNTING-ENTRIES": "Send description accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-ACCOUNTING-ENTRIES": "Send description template accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-TYPE-ACCOUNTING-ENTRIES": "Send description template types accounting entries events",
"SEND-PREFILLING-SOURCE-ACCOUNTING-ENTRIES": "Send prefilling source accounting entries events",
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events"
} }
} }
}, },

View File

@ -366,7 +366,15 @@
"SEND-USER-TOUCH": "Send user touch events", "SEND-USER-TOUCH": "Send user touch events",
"SEND-TENANT-TOUCH": "Send tenant touch events", "SEND-TENANT-TOUCH": "Send tenant touch events",
"SEND-PLAN-TOUCH": "Send plan touch events", "SEND-PLAN-TOUCH": "Send plan touch events",
"SEND-DESCRIPTION-TOUCH": "Send description touch events" "SEND-DESCRIPTION-TOUCH": "Send description touch events",
"SEND-PLAN-ACCOUNTING-ENTRIES": "Send plan accounting entries events",
"SEND-PLAN-BLUEPRINT-ACCOUNTING-ENTRIES": "Send plan blueprint accounting entries events",
"SEND-DESCRIPTION-ACCOUNTING-ENTRIES": "Send description accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-ACCOUNTING-ENTRIES": "Send description template accounting entries events",
"SEND-DESCRIPTION-TEMPLATE-TYPE-ACCOUNTING-ENTRIES": "Send description template types accounting entries events",
"SEND-PREFILLING-SOURCE-ACCOUNTING-ENTRIES": "Send prefilling source accounting entries events",
"SEND-REFERENCE-TYPE-ACCOUNTING-ENTRIES": "Send reference type accounting entries events",
"SEND-USER-ACCOUNTING-ENTRIES": "Send user accounting entries events"
} }
} }
}, },