company-service http://jira.mfd.msk:8088/browse/CLS-333 часть 2.
This commit is contained in:
parent
5fee2ac276
commit
58dcfe6061
4 changed files with 7 additions and 14 deletions
|
|
@ -57,9 +57,6 @@ public class ProfileDocumentValidationConfig {
|
|||
FieldRequiredRule.instance("issuer",
|
||||
ProfileDocumentNewRequest::getIssuer,
|
||||
CompanyErrors.RequiredFieldEmpty),
|
||||
FieldRequiredRule.instance("issuerCode",
|
||||
ProfileDocumentNewRequest::getIssuerCode,
|
||||
CompanyErrors.RequiredFieldEmpty),
|
||||
FieldRequiredRule.instance("name",
|
||||
ProfileDocumentNewRequest::getName,
|
||||
CompanyErrors.RequiredFieldEmpty),
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
|||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgId;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.ImdgTransaction;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
|
|
@ -34,6 +34,7 @@ public class ClearingMemberCategoryService extends QueueConsumer implements Init
|
|||
private final Imdg<ClearingMemberCategory> clearingMemberCategoryMap;
|
||||
private final Imdg<Company> companyMap;
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final ImdgId idSequence;
|
||||
|
||||
private final Function<ClearingMemberCategoryNewRequest, IValidator> clearingMemberCategoryNewRequestValidator;
|
||||
private final Function<ClearingMemberCategoryUpdateRequest, IValidator> clearingMemberCategoryUpdateRequestValidator;
|
||||
|
|
@ -56,6 +57,7 @@ public class ClearingMemberCategoryService extends QueueConsumer implements Init
|
|||
this.clearingMemberCategoryMap = imdgProvider.getImdg(IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class);
|
||||
this.companyMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.idSequence = imdgProvider.getImdgIdGenerator();
|
||||
this.clearingMemberCategoryNewRequestValidator = clearingMemberCategoryNewRequestValidator;
|
||||
this.clearingMemberCategoryUpdateRequestValidator = clearingMemberCategoryUpdateRequestValidator;
|
||||
this.clearingMemberCategoryDeleteRequestValidator = clearingMemberCategoryDeleteRequestValidator;
|
||||
|
|
@ -88,6 +90,7 @@ public class ClearingMemberCategoryService extends QueueConsumer implements Init
|
|||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
ClearingMemberCategoryNewRequest req = userRequest.getRequestPayload();
|
||||
ClearingMemberCategory newCategory = new ClearingMemberCategory();
|
||||
newCategory.setId(idSequence.nextId());
|
||||
newCategory.setCompanyId(req.getCompanyId());
|
||||
newCategory.setClearingMemberCategory(req.getClearingMemberCategory());
|
||||
|
||||
|
|
@ -96,7 +99,7 @@ public class ClearingMemberCategoryService extends QueueConsumer implements Init
|
|||
transaction.beginTransaction();
|
||||
boolean txOk = false;
|
||||
try {
|
||||
companyService.relationService.createNewRelation(transaction, req.getCompanyId());
|
||||
companyService.relationService.createNewRelation(transaction, req.getCompanyId(), newCategory);
|
||||
Imdg<ClearingMemberCategory> txClearingMemberCategoryMap = transaction.getImdg(IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class);
|
||||
txClearingMemberCategoryMap.insert(newCategory);
|
||||
txOk = true;
|
||||
|
|
|
|||
|
|
@ -141,11 +141,6 @@ public class CompanyService extends QueueConsumer implements InitializingBean {
|
|||
companyMap.insert(company);
|
||||
log.debug("company-new request processed, BaseRequest.id = {}, company.id={}",
|
||||
companyNewRequestBaseRequest.getId(), company.getId());
|
||||
//todo see this CLS-333.2
|
||||
relationService.createNewRelation(transaction, company.getId());
|
||||
if (!(WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()))) { // Block
|
||||
relationService.onChangeWorkflowStatus(transaction, company, null, company.getWorkflowStatus());
|
||||
}
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk)
|
||||
|
|
@ -197,7 +192,6 @@ public class CompanyService extends QueueConsumer implements InitializingBean {
|
|||
if (updateRequest.getWorkflowStatus() != null) {
|
||||
company.setWorkflowStatus(updateRequest.getWorkflowStatus());
|
||||
if (!Objects.equals(prevStatus, company.getWorkflowStatus())) {
|
||||
//todo see this CLS-333.2
|
||||
relationService.onChangeWorkflowStatus(transaction, company, prevStatus, company.getWorkflowStatus());
|
||||
} else {
|
||||
log.trace("Status was not changed");
|
||||
|
|
|
|||
|
|
@ -280,16 +280,15 @@ public class RelationService extends QueueConsumer implements InitializingBean {
|
|||
|
||||
// --- internal API ---
|
||||
|
||||
protected void createNewRelation(ImdgTransaction transaction, Long companyId) {
|
||||
protected void createNewRelation(ImdgTransaction transaction, Long companyId, ClearingMemberCategory clearingMemberCategory) {
|
||||
Imdg<Relation> relationMap = transaction.getImdg(IMDGDistributedNames.Map_Relation, Relation.class);
|
||||
Relation relation = new Relation();
|
||||
Company company = transaction.getImdg(IMDGDistributedNames.Map_Company, Company.class).getSingleObjectByFieldValues(Map.of("id", companyId));
|
||||
ClearingMemberCategory clearingMemberCategory = transaction.getImdg(IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class).getSingleObjectByFieldValues(Map.of("companyId", companyId));
|
||||
|
||||
WorkflowStatus workflowStatus = getEnumByKey(WorkflowStatus.class, company.getWorkflowStatus());
|
||||
String serviceStatus = null;
|
||||
if (clearingMemberCategory == null) {
|
||||
log.debug("clearingMemberCategory not found for companyId={}", companyId);
|
||||
log.warn("clearingMemberCategory not set for companyId={}", companyId);
|
||||
} else {
|
||||
ClearingCategory clearingCategory = getEnumByKey(ClearingCategory.class, clearingMemberCategory.getClearingMemberCategory());
|
||||
switch (Objects.requireNonNull(clearingCategory)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue