refactor IMDG getSingle* -> getFirst*

This commit is contained in:
ialbert 2023-07-12 14:22:15 +03:00
parent 8da9583854
commit e184c68be2
115 changed files with 300 additions and 273 deletions

View file

@ -134,7 +134,7 @@ public class ClearingAccountValidationConfig {
Imdg<Company> companyImdg = context.obtainMap(
IMDGDistributedNames.Map_Company, Company.class
);
Company company = companyImdg.getSingleObjectByFieldValues(Map.of("tradingCode", dealValue));
Company company = companyImdg.getFirstObjectByFieldValues(Map.of("tradingCode", dealValue));
if (company == null) return AccountError.WrongFieldValue;
return null;
})

View file

@ -19,7 +19,6 @@ import ru.spcex.clearing.validation.common.rules.IdPresentRule;
import ru.spcex.platform.classes.base.SpcexObjectBase;
import ru.spcex.platform.enumeration.AccountType;
import ru.spcex.platform.enumeration.CompanySymbol;
import ru.spcex.platform.enumeration.ServiceStatus;
import ru.spcex.platform.imdg.api.Imdg;
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
@ -65,7 +64,7 @@ public class TradingClearingRegistryValidationConfig {
true,
company -> {
Imdg<CompanySymbols> companySymbolsImdg = context.obtainMap(IMDGDistributedNames.Map_CompanySymbols, CompanySymbols.class);
CompanySymbols symbol = companySymbolsImdg.getSingleObjectByFieldValues(Map.of(
CompanySymbols symbol = companySymbolsImdg.getFirstObjectByFieldValues(Map.of(
"companyId", company.getId(),
"companySymbol", CompanySymbol.CLRC.getKey()
));
@ -113,7 +112,7 @@ public class TradingClearingRegistryValidationConfig {
depoAccountId -> {
if (depoAccountId == null) return null;
Imdg<DepoAccount> depoAccountImdg = context.obtainMap(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);
DepoAccount depoAccount = depoAccountImdg.getSingleObjectByFieldValues(
DepoAccount depoAccount = depoAccountImdg.getFirstObjectByFieldValues(
Map.of("accountId", depoAccountId)
);
if (depoAccount == null) return AccountError.AccountNotFound;

View file

@ -175,7 +175,7 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
Account account = accountImdg.getCollectionObjectsByPredicate(finalPredicate).iterator().next();
Long accountId = account.getId();
ClearingAccount clearingAccount = clearingAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", accountId));
ClearingAccount clearingAccount = clearingAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", accountId));
if (clearingAccount == null)
return requestHelper.makeErrorResponse(userRequest, AccountError.AccountNotFound, account.getAccount());

View file

@ -36,7 +36,6 @@ import ru.spcex.platform.imdg.api.ImdgId;
import ru.spcex.platform.imdg.api.ImdgProvider;
import ru.spcex.platform.utils.enumeration.EnumMessage;
import ru.spcex.platform.utils.enumeration.IMessageResolver;
import ru.spcex.platform.utils.error.ClearingBaseException;
import ru.spcex.platform.utils.log.ExceptionUtils;
import ru.spcex.platform.utils.validation.IValidator;
@ -132,7 +131,7 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
if (companyId == null) {
error = new EnumMessage(AccountError.RequiredFieldEmpty, "companyId");
} else {
TradingClearingRegistry tcr = tradingClearingRegistryMap.getSingleObjectByFieldValues(Map.of("companyId", companyId));
TradingClearingRegistry tcr = tradingClearingRegistryMap.getFirstObjectByFieldValues(Map.of("companyId", companyId));
if (tcr==null) {
error=new EnumMessage(AccountError.TradingClearingRegistryNotFound, companyId);
}
@ -292,7 +291,7 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
if (depoAccountId != null) {
query.put("depoAccountId", depoAccountId);
}
TradingClearingRegistry result = tradingClearingRegistryMap.getSingleObjectByFieldValues(query);
TradingClearingRegistry result = tradingClearingRegistryMap.getFirstObjectByFieldValues(query);
log.trace("TradingClearingRegistry by: {}; {}found", query, result == null ? "not " : "");
return result;
}

View file

@ -141,13 +141,13 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
tradingClearingRegistry.setDepoAccountId(req.getDepoAccountId());
Account depoAccountMain = req.getDepoAccountId() != null ? accountImdg.getSingleObjectByID(req.getDepoAccountId()) : null;
DepoAccount depoAccount = depoAccountMain != null ? depoAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", req.getDepoAccountId())) : null;
DepoAccount depoAccount = depoAccountMain != null ? depoAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", req.getDepoAccountId())) : null;
// InformationAccount infoAccount = null;
ClearingAccount clearingAccount = null;
Account accountMain = null;
if (req.getMoneyAccountId() != null) {
clearingAccount = clearingAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", req.getMoneyAccountId()));
clearingAccount = clearingAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", req.getMoneyAccountId()));
// if (clearingAccount == null) infoAccount = informationAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", req.getMoneyAccountId()));
Long accountId = req.getMoneyAccountId(); //clearingAccount != null ? clearingAccount.getAccountId() : infoAccount.getAccountId();
accountMain = accountImdg.getSingleObjectByID(accountId);
@ -155,7 +155,7 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
// кроссвалидация
if (req.getMoneyAccountId() == null && (req.getMoneyAccountId() == null || req.getDepoAccountId() == null)) {
TradingClearingRegistry registryByCompany = tradingClearingRegistryImdg.getSingleObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
TradingClearingRegistry registryByCompany = tradingClearingRegistryImdg.getFirstObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
if (registryByCompany == null) {
log.trace("Not found registry with companyId={}",
req.getCompanyId());
@ -177,9 +177,9 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
log.warn("TradingClearingRegister with MoneyAccountId for companyId={} not found. Search exist accounts for company", req.getCompanyId());
Long accountId;
InformationAccount infoAccount = null;
clearingAccount = clearingAccountImdg.getSingleObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
clearingAccount = clearingAccountImdg.getFirstObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
if (clearingAccount == null) {
infoAccount = informationAccountImdg.getSingleObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
infoAccount = informationAccountImdg.getFirstObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
if (infoAccount == null) {
log.warn("ClearingAccount and InfoAccount not exist for company {}.", req.getCompanyId());
accountId = null;
@ -286,7 +286,7 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
TradingClearingRegistryNewRequest req = userRequest.getRequestPayload();
// Дополнительная проверка
if (req.getMoneyAccountId() == null && (req.getMoneyAccountId() == null || req.getDepoAccountId() == null)) {
TradingClearingRegistry registryByCompany = tradingClearingRegistryImdg.getSingleObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
TradingClearingRegistry registryByCompany = tradingClearingRegistryImdg.getFirstObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
if (registryByCompany == null) {
return requestHelper.makeErrorResponse(userRequest,
AccountError.TradingClearingRegistryNotFound,
@ -301,8 +301,8 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
tradingClearingRegistry.setMoneyAccountId(req.getMoneyAccountId());
tradingClearingRegistry.setDepoAccountId(req.getDepoAccountId());
DepoAccount depoAccount = req.getDepoAccountId() != null ? depoAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", req.getDepoAccountId())) : null;
ClearingAccount clearingAccount = req.getMoneyAccountId() != null ? clearingAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", req.getMoneyAccountId())) : null;
DepoAccount depoAccount = req.getDepoAccountId() != null ? depoAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", req.getDepoAccountId())) : null;
ClearingAccount clearingAccount = req.getMoneyAccountId() != null ? clearingAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", req.getMoneyAccountId())) : null;
if (req.getStatus() == null) {
tradingClearingRegistry.setStatus(ServiceStatus.Active.getKey());

View file

@ -38,7 +38,7 @@ public enum AccountValidationRule implements IValidationRule<ImdgValidationConte
public Optional<EnumMessage> validate(ImdgValidationContext<BankAccountNewRequest> context) {
BankAccountNewRequest bankAccountRequest = context.getValidatedObject();
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
Account account = accountImdg.getSingleObjectByFieldValues(Map.of("account", bankAccountRequest.getAccount(),
Account account = accountImdg.getFirstObjectByFieldValues(Map.of("account", bankAccountRequest.getAccount(),
"accountStatus", Status.Active.getKey()));
if (account != null) {
return of(AccountError.AccountAlreadyExist);

View file

@ -179,8 +179,8 @@ public class BankAccountServiceTest {
addRecordToKafka((MockConsumer) bankAccountService.getConsumer(), TOPIC_ACCOUNT_NEW, PARTITION, 0, jsonString);
waitingSendAndCheckRecord(ID, mockProducer);
Account accountResult = accountImdg.getSingleObjectBySQL(String.format("account = %s", acc));
BankAccount bankAccountResult = bankAccountImdg.getSingleObjectBySQL(String.format("account = %s or companyId = %s", acc, addresseeIdNew));
Account accountResult = accountImdg.getFirstObjectBySQL(String.format("account = %s", acc));
BankAccount bankAccountResult = bankAccountImdg.getFirstObjectBySQL(String.format("account = %s or companyId = %s", acc, addresseeIdNew));
predictableBankAccount.setAccountId(accountResult.getId());
predictableBankAccount.setId(bankAccountResult.getId());
setSameValueToField(accountResult, predictableAccount);

View file

@ -1,7 +1,5 @@
package ru.spcex.clearing.account.service;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.kafka.clients.consumer.MockConsumer;
import org.apache.kafka.clients.producer.MockProducer;
import org.apache.kafka.clients.producer.Producer;
@ -28,35 +26,23 @@ import ru.spcex.clearing.account.config.validation.ClearingAccountValidationConf
import ru.spcex.clearing.account.config.validation.ValidationConfig;
import ru.spcex.clearing.account.utils.MatcherFactory;
import ru.spcex.clearing.imdg.IMDGDistributedNames;
import ru.spcex.clearing.platform.messaging.domain.ActionType;
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
import ru.spcex.clearing.platform.messaging.domain.Consts;
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClearingAccountNewRequest;
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClearingAccountUpdateRequest;
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdf01Request;
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdfRequestPart;
import ru.spcex.clearing.platform.messaging.domain.cud.balance.AccountSdfToStatementRequestPart;
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
import ru.spcex.clearing.platform.messaging.service.RequestInfo;
import ru.spcex.clearing.platform.messaging.service.Status;
import ru.spcex.clearing.test.TestObjectCreator;
import ru.spcex.clearing.test.config.ImdgTestConfig;
import ru.spcex.clearing.test.config.KafkaTestConfig;
import ru.spcex.platform.enumeration.*;
import ru.spcex.platform.imdg.api.Imdg;
import ru.spcex.platform.imdg.iml.hazelcast.adapter.ImdgHazelcast;
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
import javax.annotation.PostConstruct;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
import static ru.spcex.clearing.account.utils.MatcherFactory.usingIgnoringFieldsComparator;
import static ru.spcex.clearing.test.TestUtils.*;
import static ru.spcex.clearing.test.config.ImdgTestConfig.currentID;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {
@ -187,8 +173,8 @@ class ClearingAccountServiceTest {
predictableClearingAccount.setCompanyId(companyId);
predictableClearingAccount.setClearingAccountType(CLEARING_ACCOUNT_TYPE_DICT);
Account resultAccountNew = accountImdg.getSingleObjectByFieldValues(Map.of("accountType", AccountType.Clrn.getKey()));
ClearingAccount resultClearingAccountNew = clearingAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", resultAccountNew.getId()));
Account resultAccountNew = accountImdg.getFirstObjectByFieldValues(Map.of("accountType", AccountType.Clrn.getKey()));
ClearingAccount resultClearingAccountNew = clearingAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", resultAccountNew.getId()));
predictableAccount.setId(resultAccountNew.getId());
predictableClearingAccount.setAccountId(resultAccountNew.getId());

View file

@ -1,7 +1,6 @@
package ru.spcex.clearing.account.service;
import org.apache.kafka.clients.consumer.MockConsumer;
import org.apache.kafka.clients.producer.MockProducer;
import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.junit.jupiter.api.Assertions;
@ -9,10 +8,8 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import ru.clearing.classes.statics.data.account.Account;
@ -211,7 +208,7 @@ class ClientCodeServiceTest {
//ASSERT
waitingSendAndCheckRecord(ID, mockProducer);
ClientCode resultNew = clientCodeImdg.getSingleObjectBySQL(String.format("code = '%s'", ccCode));
ClientCode resultNew = clientCodeImdg.getFirstObjectBySQL(String.format("code = '%s'", ccCode));
predictableClientCode.setId(resultNew.getId());
CLIENT_CODE_MATCHER.assertMatch(resultNew, predictableClientCode);
assertNotNull(resultNew.getCreated());
@ -249,7 +246,7 @@ class ClientCodeServiceTest {
//ASSERT
TestUtils.waitingSendAndCheckRecord(ID, mockProducer, producerRecord);
ClientCode resultNew = clientCodeImdg.getSingleObjectBySQL(String.format("code = '%s'", ccCode));
ClientCode resultNew = clientCodeImdg.getFirstObjectBySQL(String.format("code = '%s'", ccCode));
predictableClientCode.setId(resultNew.getId());
CLIENT_CODE_MATCHER.assertMatch(resultNew, predictableClientCode);
assertNotNull(resultNew.getCreated());
@ -289,7 +286,7 @@ class ClientCodeServiceTest {
//ASSERT
waitingSendAndCheckRecord(ID, mockProducer);
ClientCode resultNew = clientCodeImdg.getSingleObjectBySQL(String.format("code = '%s'", ccCode));
ClientCode resultNew = clientCodeImdg.getFirstObjectBySQL(String.format("code = '%s'", ccCode));
predictableClientCode.setId(resultNew.getId());
CLIENT_CODE_MATCHER.assertMatch(resultNew, predictableClientCode);
assertNotNull(resultNew.getCreated());

View file

@ -173,8 +173,8 @@ class DepoAccountServiceTest {
predictableDepoAccount.setCompanyId(companyId);
predictableDepoAccount.setDepoAccountType(DEPO_ACCOUNT_TYPE_DICT);
Account resultAccountNew = accountImdg.getSingleObjectByFieldValues(Map.of("accountType", AccountType.Depo.getKey()));
DepoAccount resultDepoAccountNew = depoAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", resultAccountNew.getId()));
Account resultAccountNew = accountImdg.getFirstObjectByFieldValues(Map.of("accountType", AccountType.Depo.getKey()));
DepoAccount resultDepoAccountNew = depoAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", resultAccountNew.getId()));
predictableAccount.setId(resultAccountNew.getId());
predictableDepoAccount.setAccountId(resultAccountNew.getId());

View file

@ -166,8 +166,8 @@ class InformationAccountServiceTest {
predictableInfoAccount.setCompanyId(companyId);
predictableInfoAccount.setClearingAccountId(anltAccountId);
Account resultAccountNew = accountImdg.getSingleObjectByFieldValues(Map.of("accountType", AccountType.Info.getKey()));
InformationAccount resultInfoAccountNew = informationAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", resultAccountNew.getId()));
Account resultAccountNew = accountImdg.getFirstObjectByFieldValues(Map.of("accountType", AccountType.Info.getKey()));
InformationAccount resultInfoAccountNew = informationAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", resultAccountNew.getId()));
predictableAccount.setId(resultAccountNew.getId());
predictableAccount.setAccount(informationAccountService.generateInfoAccount(resultInfoAccountNew.getId()));

View file

@ -69,14 +69,14 @@ public class LauncherController extends AbstractQueueController {
@ResponseBody
public CudResponse add(@ApiParam(value = "Код задания из taskDictionary", required = true, example = "ABLK")
@PathVariable("task-code") String dictionaryName) throws ExecutionException, InterruptedException {
AbstractDictionary taskEnum = taskDictionary.getSingleObjectByFieldValues(Map.of("code", dictionaryName));
AbstractDictionary taskEnum = taskDictionary.getFirstObjectByFieldValues(Map.of("code", dictionaryName));
if (taskEnum == null) {
throw new NotFound404Exception("task dictionary element with code '" + dictionaryName + "'");
}
LauncherNew launcherCommand = new LauncherNew();
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String username = KeycloakUtils.getUserNameFromAuthentication(authentication);
User user = userImdg.getSingleObjectByFieldValues(Map.of("identifier", username));
User user = userImdg.getFirstObjectByFieldValues(Map.of("identifier", username));
if (user == null) {
throw new IllegalStateException("cannot obtain userId from logged in user " + username);
}
@ -96,7 +96,7 @@ public class LauncherController extends AbstractQueueController {
if (launcherNew.getTask() == null) {
throw new NotFound404Exception("task dictionary element with code '" + launcherNew.getTask() + "'");
}
AbstractDictionary taskEnum = taskDictionary.getSingleObjectByFieldValues(Map.of("code", launcherNew.getTask()));
AbstractDictionary taskEnum = taskDictionary.getFirstObjectByFieldValues(Map.of("code", launcherNew.getTask()));
if (taskEnum == null) {
throw new NotFound404Exception("task dictionary element with code '" + launcherNew.getTask() + "'");
}
@ -105,7 +105,7 @@ public class LauncherController extends AbstractQueueController {
}
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String username = KeycloakUtils.getUserNameFromAuthentication(authentication);
User user = userImdg.getSingleObjectByFieldValues(Map.of("identifier", username));
User user = userImdg.getFirstObjectByFieldValues(Map.of("identifier", username));
if (user == null) {
throw new IllegalStateException("cannot obtain userId from logged in user " + username);
}

View file

@ -68,7 +68,7 @@ public class UserController extends AbstractQueueController {
UserIdResponse response = new UserIdResponse();
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String username = KeycloakUtils.getUserNameFromAuthentication(authentication);
User user = userImdg.getSingleObjectByFieldValues(Map.of("identifier", username));
User user = userImdg.getFirstObjectByFieldValues(Map.of("identifier", username));
if (user == null) {
log.info("getId user {} authenticated, but User object was not created", username);
throw new IllegalStateException("couldn't return user id");

View file

@ -52,7 +52,7 @@ public class UserSettingsController extends AbstractQueueController {
public CommonGetAllResponse getAllForCurrentUser() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String username = KeycloakUtils.getUserNameFromAuthentication(authentication);
User user = username == null ? null : userImdg.getSingleObjectByFieldValues(Map.of("identifier", username));
User user = username == null ? null : userImdg.getFirstObjectByFieldValues(Map.of("identifier", username));
if (user == null) {
throw new IllegalStateException("cannot obtain userId from logged in user " + username);
}
@ -74,7 +74,7 @@ public class UserSettingsController extends AbstractQueueController {
@RequestBody UserSettingsUpdateAction userSettingsUpdateAction) throws ExecutionException, InterruptedException {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String username = KeycloakUtils.getUserNameFromAuthentication(authentication);
User user = userImdg.getSingleObjectByFieldValues(Map.of("identifier", username));
User user = userImdg.getFirstObjectByFieldValues(Map.of("identifier", username));
if (user == null) {
throw new IllegalStateException("cannot obtain userId from logged in user " + username);
}

View file

@ -84,7 +84,7 @@ public class DictionaryController {
@ApiParam(value = "Код словаря", required = true, example = "1234")
@PathVariable("code") String code) {
Imdg<AbstractDictionary> dictionary = extractDictionaryImdgFromUrlParameter(dictionaryName, AbstractDictionary.class);
AbstractDictionary value = dictionary.getSingleObjectByFieldValues(Map.of("code", code));
AbstractDictionary value = dictionary.getFirstObjectByFieldValues(Map.of("code", code));
if (value == null) throw new NotFound404Exception(dictionaryName + " code='" + code + "'");
DictionaryBackendGetSingleValueV2 response = new DictionaryBackendGetSingleValueV2();
response.setPayload(responseFactory.responseFromDictionary(dictionaryName, value));

View file

@ -58,7 +58,7 @@ public class OperatorImpl implements IOperator {
protected Long currentUserId() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String username = KeycloakUtils.getUserNameFromAuthentication(authentication);
User user = StringUtils.isEmpty(username) ? null : userImdg.getSingleObjectByFieldValues(Map.of("identifier", username));
User user = StringUtils.isEmpty(username) ? null : userImdg.getFirstObjectByFieldValues(Map.of("identifier", username));
if (user == null) {
log.warn("UserID not found by login \"{}\"", username);
return null;

View file

@ -18,7 +18,7 @@ public enum LauncherNewValidationRule implements IValidationRule<ImdgValidationC
public Optional<EnumMessage> validate(ImdgValidationContext<LauncherNew> context) {
LauncherNew validatedObject = context.getValidatedObject();
Imdg<AbstractDictionary> taskDictionaryImdg = context.obtainMap(IMDGDistributedNames.Map_TaskDictionary, AbstractDictionary.class);
AbstractDictionary taskEnum = taskDictionaryImdg.getSingleObjectByFieldValues(Map.of("code", validatedObject.getTask()));
AbstractDictionary taskEnum = taskDictionaryImdg.getFirstObjectByFieldValues(Map.of("code", validatedObject.getTask()));
if (taskEnum == null) {
return of(BackEndError.ResourceNotFound, "taskDictionary " + validatedObject.getTask());
}

View file

@ -6,8 +6,8 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ru.clearing.classes.statics.data.account.Account;
import ru.clearing.classes.statics.data.account.AccountBalance;
import ru.clearing.classes.statics.data.company.Company;
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
import ru.clearing.classes.statics.data.company.Company;
import ru.spcex.clearing.balance.validation.AccountBalanceValidation;
import ru.spcex.clearing.balance.validation.ValidationStored;
import ru.spcex.clearing.imdg.IMDGDistributedNames;
@ -57,7 +57,7 @@ public class AccountBalanceService {
Company company = validator.getStored(ValidationStored.Company);
//которой accountBalance.accountId=statement.accountId и accountBalance.companyId=statement.companyId:
AccountBalance accountBalance = accountBalanceImdg.getSingleObjectByFieldValues(
AccountBalance accountBalance = accountBalanceImdg.getFirstObjectByFieldValues(
Map.of("accountId", accountId, "companyId", addresseeId)
);
if (accountBalance == null) {
@ -114,7 +114,7 @@ public class AccountBalanceService {
}
private ClearingCategory getClearingCategoryByCompanyId(Long companyId) {
ClearingMemberCategory category = clearingCategoryImdg.getSingleObjectByFieldValues(
ClearingMemberCategory category = clearingCategoryImdg.getFirstObjectByFieldValues(
Map.of("companyId", companyId));
return IEnumKey.getEnumByKey(ClearingCategory.class,
category.getClearingMemberCategory());
@ -197,14 +197,14 @@ public class AccountBalanceService {
}
private AccountBalance loadAccountBalance(Long accountId, Long companyId, AccountType type) {
return accountBalanceImdg.getSingleObjectByFieldValues(
return accountBalanceImdg.getFirstObjectByFieldValues(
Map.of("accountId", accountId, "companyId", companyId,
"accountType", type.getKey())
);
}
private AccountBalance loadAccountBalance(AccountType type) {
return accountBalanceImdg.getSingleObjectByFieldValues(
return accountBalanceImdg.getFirstObjectByFieldValues(
Map.of("companyId", 1L,
"accountType", type.getKey())
);

View file

@ -93,7 +93,7 @@ public class Sdf16Executor extends AbstractExecutor<SDf16> {
sdf17Imdg.insert(createErrorSdfRes(sdfItem, error.get(), generationIdForGroup));
continue;
}
Statement statement = statementImdg.getSingleObjectByFieldValues(Map.of("account", sdfItem.getAccount()));
Statement statement = statementImdg.getFirstObjectByFieldValues(Map.of("account", sdfItem.getAccount()));
if (statement == null) {
statement = createFlow(sdfItem,
company,

View file

@ -34,7 +34,7 @@ public class AccountBalanceFreeAmountEnough<T extends WithAccount & WithSum> imp
return empty();
}
Imdg<AccountBalance> balanceImdg = context.obtainMap(IMDGDistributedNames.Map_AccountBalance, AccountBalance.class);
AccountBalance balance = balanceImdg.getSingleObjectByFieldValues(Map.of("account", validatedObject.getAccount(),
AccountBalance balance = balanceImdg.getFirstObjectByFieldValues(Map.of("account", validatedObject.getAccount(),
"accountType", AccountType.Clrn.getKey()));
if (balance == null) {
return of(BalanceError.BalanceNotEnough);

View file

@ -40,7 +40,7 @@ public enum AccountBalanceValidationRule implements IValidationRule<ImdgValidati
return of(BalanceError.AccountNotPresent);
}
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
Account account = accountImdg.getSingleObjectByFieldValues(Map.of("id", validatedObject.accountId(),
Account account = accountImdg.getFirstObjectByFieldValues(Map.of("id", validatedObject.accountId(),
"accountType", AccountType.Clrn.getKey()));
if (account == null) {
return of(BalanceError.AccountNotPresent);

View file

@ -23,7 +23,7 @@ public enum ExistClrnAccountValidationRule implements IValidationRule<ImdgValida
return of(BalanceError.AccountNotPresent);
}
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
Account account = accountImdg.getSingleObjectByFieldValues(Map.of("account", withAccount.getAccount(),
Account account = accountImdg.getFirstObjectByFieldValues(Map.of("account", withAccount.getAccount(),
"accountType", AccountType.Clrn.getKey()));
if (account == null) {
return of(BalanceError.AccountNotPresent);

View file

@ -41,7 +41,7 @@ public enum Sdf16ValidationRule implements IValidationRule<ImdgValidationContext
return of(BalanceError.CompanyNotFound, "inn and bic is empty");
}
Company company = null;
CompanySymbols companySymbols = companySymbolsImdg.getSingleObjectBySQL(sql);
CompanySymbols companySymbols = companySymbolsImdg.getFirstObjectBySQL(sql);
log.debug("By sdf16 found companySymbol: {}", companySymbols == null ? null : companySymbols.getId());
if (companySymbols != null) {
company = companyImdg.getSingleObjectByID(companySymbols.getCompanyId());

View file

@ -73,7 +73,7 @@ class Sdf08ServiceTest extends AbstractServiceTest {
BaseRequest<Object> baseRequest = (BaseRequest<Object>) producerRecord.getValue().value();
ExportToFileRequest exportToFileRequest = (ExportToFileRequest) baseRequest.getRequestPayload();
SDf08 resultsSDf08 = sdf08Imdg.getSingleObjectBySQL(String.format("generationId = %s and id != null", exportToFileRequest.getSdfGroupId()));
SDf08 resultsSDf08 = sdf08Imdg.getFirstObjectBySQL(String.format("generationId = %s and id != null", exportToFileRequest.getSdfGroupId()));
RequestInfo resultRequestInfo = requestInfoImdg.getSingleObjectByID(baseRequest.getId());
assertNotNull(baseRequest);

View file

@ -101,9 +101,9 @@ class Sdf16ExecutorTest extends AbstractServiceTest {
BaseRequest<Object> baseRequest = (BaseRequest<Object>) producerRecord.getValue().value();
NotificationNewRequest notificationNewRequest = (NotificationNewRequest) baseRequest.getRequestPayload();
Statement resultStatement = statementImdg.getSingleObjectByFieldValues(Map.of("account", acc));
SDf17 resultSdf17 = sdf17Imdg.getSingleObjectByFieldValues(Map.of("account", acc));
AccountBalance resultAccountBalance = accountBalanceImdg.getSingleObjectByFieldValues(Map.of("account", acc));
Statement resultStatement = statementImdg.getFirstObjectByFieldValues(Map.of("account", acc));
SDf17 resultSdf17 = sdf17Imdg.getFirstObjectByFieldValues(Map.of("account", acc));
AccountBalance resultAccountBalance = accountBalanceImdg.getFirstObjectByFieldValues(Map.of("account", acc));
assertEquals(Consts.NOTIFICATION_NEW, producerRecord.getValue().topic());
assertEquals(notificationNewRequest.getObjectId(), resultStatement.getId());
@ -176,7 +176,7 @@ class Sdf16ExecutorTest extends AbstractServiceTest {
//BalanceNotEnough
sdf16.setSum(new BigDecimal(-1700));
AccountBalance balance = accountBalanceImdg.getSingleObjectByFieldValues(Map.of("account", sdf16.getAccount(),
AccountBalance balance = accountBalanceImdg.getFirstObjectByFieldValues(Map.of("account", sdf16.getAccount(),
"accountType", AccountType.Clrn.getKey()));
if (balance != null) accountBalanceImdg.delete(balance);
else balance = getTestAccountBalance(ID, account, company);

View file

@ -11,7 +11,7 @@ import ru.spcex.platform.utils.enumeration.EnumMessage;
import java.math.BigDecimal;
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
@Deprecated // sDf16 was deleted
class Sdf16ValidationRuleTest {
@ -36,7 +36,7 @@ class Sdf16ValidationRuleTest {
}
@Override
public T getSingleObjectBySQL(String sql) {
public T getFirstObjectBySQL(String sql) {
return null;
}
};

View file

@ -25,7 +25,7 @@ public class SortingConfig {
@Bean
public Function<Long, ClearingCategory> clearingMemberCategoryProvider() {
return companyId -> {
ClearingMemberCategory category = clearingCategoryImdg.getSingleObjectByFieldValues(
ClearingMemberCategory category = clearingCategoryImdg.getFirstObjectByFieldValues(
Map.of("companyId", companyId));
return IEnumKey.getEnumByKey(ClearingCategory.class,
category.getClearingMemberCategory());

View file

@ -143,7 +143,7 @@ public class Clearing {
log.trace("executionDeposit {} was updated DENIED", execDeposit.getId());
//также необходимо установить статус DEND встречной сделке контрагента этой компании, которая выбирается из executionDeposit по ключу:
//securityId И чтобы сделка была компании категории clearingMemberCategory.clearingMemberCategory той категории, сделка которой обрабатывается в настоящий момент.
ExecutionDeposit matchedExecDeposit = executionDepositImdg.getSingleObjectBySQL(
ExecutionDeposit matchedExecDeposit = executionDepositImdg.getFirstObjectBySQL(
"exchangeExecutionId = " + execDeposit.getExchangeExecutionId()
+ " AND side != '" + execDeposit.getSide() + "'");
if (matchedExecDeposit != null) {

View file

@ -35,7 +35,7 @@ public class PaymentUpdateBySdf04 {
log.warn("sdf04.id={} cannot parse docnm_ref={} as payment id", sDf04.getId(), sDf04.getDocnm_ref());
continue;
}
PaymentInstruction payment = paymentImdgs.getSingleObjectByFieldValues(Map.of("id", paymentId));
PaymentInstruction payment = paymentImdgs.getFirstObjectByFieldValues(Map.of("id", paymentId));
if ("OK!".equals(sDf04.getImp_result())) {
payment.setTransactionStatus(TransactionStatus.ok.getKey());
} else {

View file

@ -44,7 +44,7 @@ public class RegistryService {
//todo для компани всегда один объект TradingClearingRegistry? пока предполагаю что да и нужно добавить такую проверку(в ТЗ ее нет);
//todo see TradingClearingRegistryService.tradingClearingRegistryNew
TradingClearingRegistry tcrByCompanyId = tradingClearingRegistryImdg.getSingleObjectBySQL(byCompanySqlPredicate);
TradingClearingRegistry tcrByCompanyId = tradingClearingRegistryImdg.getFirstObjectBySQL(byCompanySqlPredicate);
if (tcrByCompanyId != null) {
log.trace("Found tradingClearingRegistry with id: {}", tcrByCompanyId.getId());
Registry registry = new Registry();

View file

@ -43,7 +43,7 @@ public class Sdf03Creator {
String c_acc_deb = null;
String c_acc_cred = null;
if (AccountType.Info.equals(creditAccType) ^ AccountType.Info.equals(debAccType)) {
Account anltAcc = accountImdg.getSingleObjectBySQL("accountType = '%s' and status = '%s'"
Account anltAcc = accountImdg.getFirstObjectBySQL("accountType = '%s' and status = '%s'"
.formatted(AccountType.Anlt.getKey(), Status.Active.getKey()));
if (anltAcc == null) {
throw new IllegalStateException("SDF03 creation error: paymentInstruction.creditLeg_accountId="

View file

@ -207,7 +207,7 @@ public class SdfCreatorBySTLDPayment {
}
ClearingCategory getClearingCategory(PaymentInstruction paymentInstruction) {
ClearingMemberCategory category = clearingMemberCategoryImdg.getSingleObjectByFieldValues(
ClearingMemberCategory category = clearingMemberCategoryImdg.getFirstObjectByFieldValues(
Map.of("companyId", paymentInstruction.getSenderId()));
if (category == null) {
log.trace("ClearingMemberCategory not found by paymentInstruction[{}].companyId={}",

View file

@ -105,7 +105,7 @@ public class LiabilitiesClaimsAssetsCreator {
Long companyId,
Long securityId,
LocalDate dt) {
LiabilitiesClaimsAssets asset = assetsImdg.getSingleObjectByFieldValues(
LiabilitiesClaimsAssets asset = assetsImdg.getFirstObjectByFieldValues(
Map.of("accountId", accountId,
"companyId", companyId,
"securityId", securityId,

View file

@ -31,7 +31,7 @@ public class LiabilitiesClaimsMoneyCreator {
}
public Optional<LiabilitiesClaimsMoney> searchLcmBySettlementDate(Long accountId, Long companyId, LocalDate settlementDate) {
LiabilitiesClaimsMoney liabilitiesClaimsMoney = liabilitiesClaimsMoneyImdg.getSingleObjectByFieldValues(
LiabilitiesClaimsMoney liabilitiesClaimsMoney = liabilitiesClaimsMoneyImdg.getFirstObjectByFieldValues(
Map.of("accountId", accountId, "companyId", companyId, "settlementDate", settlementDate));
return Optional.ofNullable(liabilitiesClaimsMoney);
}
@ -80,7 +80,7 @@ public class LiabilitiesClaimsMoneyCreator {
}
public Optional<LiabilitiesClaimsMoney> searchLcmByRefundDate(Long accountId, Long companyId, LocalDate refundDate) {
LiabilitiesClaimsMoney liabilitiesClaimsMoney = liabilitiesClaimsMoneyImdg.getSingleObjectByFieldValues(
LiabilitiesClaimsMoney liabilitiesClaimsMoney = liabilitiesClaimsMoneyImdg.getFirstObjectByFieldValues(
Map.of("accountId", accountId, "companyId", companyId, "settlementDate", refundDate));
return Optional.ofNullable(liabilitiesClaimsMoney);
}

View file

@ -67,7 +67,7 @@ public class PaymentInstructionBuilder {
Registry registry = registryLM.get();
paymentInstruction.setSenderId(registry.getCompanyId());
CompanySymbols companySymbols = companySymbolsImdg.getSingleObjectByFieldValues(Map.of(
CompanySymbols companySymbols = companySymbolsImdg.getFirstObjectByFieldValues(Map.of(
"companyId", registry.getCompanyId(),
"companySymbol", CompanySymbol.BIC.getKey()));
@ -101,7 +101,7 @@ public class PaymentInstructionBuilder {
CompanySymbols companySymbols = null;
if (registry.getCounterPartyId() != null) {
companySymbols = companySymbolsImdg.getSingleObjectByFieldValues(Map.of(
companySymbols = companySymbolsImdg.getFirstObjectByFieldValues(Map.of(
"companyId", registry.getCompanyId(),
"companySymbol", CompanySymbol.BIC.getKey())
);

View file

@ -247,7 +247,7 @@ public class PaymentInstructionBuilderFinalMkrDeals {
if (companyId == null) {
return null;
}
CompanySymbols cSymbol = companySymbolsImdg.getSingleObjectByFieldValues(Map.of(
CompanySymbols cSymbol = companySymbolsImdg.getFirstObjectByFieldValues(Map.of(
"companyId", companyId,
"companySymbol", symbol.getKey()));
if (cSymbol == null) {
@ -261,7 +261,7 @@ public class PaymentInstructionBuilderFinalMkrDeals {
if (companyId == null) {
return null;
}
Account account = accountImdg.getSingleObjectByFieldValues(Map.of(
Account account = accountImdg.getFirstObjectByFieldValues(Map.of(
"companyId", companyId,
"accountType", accountType.getKey(),
"status", accountStatus.getKey(),

View file

@ -542,7 +542,7 @@ public class PaymentInstructionCreator {
criteria.put("senderId", lca.getCompanyId());
criteria.put("paymentPurpose", paymentPurpose(lca.getContract()));
criteria.put("settlementDate", lca.getSettlementDate());
PaymentInstruction payment1 = paymentInstructionImdg.getSingleObjectByFieldValues(criteria);
PaymentInstruction payment1 = paymentInstructionImdg.getFirstObjectByFieldValues(criteria);
return payment1;
}
@ -601,7 +601,7 @@ public class PaymentInstructionCreator {
if (companyId == null) {
return null;
}
CompanySymbols cSymbol = companySymbolsImdg.getSingleObjectByFieldValues(Map.of(
CompanySymbols cSymbol = companySymbolsImdg.getFirstObjectByFieldValues(Map.of(
"companyId", companyId,
"companySymbol", symbol.getKey()));
if (cSymbol == null) {
@ -615,7 +615,7 @@ public class PaymentInstructionCreator {
if (companyId == null) {
return null;
}
Account account = accountImdg.getSingleObjectByFieldValues(Map.of(
Account account = accountImdg.getFirstObjectByFieldValues(Map.of(
"companyId", companyId,
"accountType", accountType.getKey(),
"accountStatus", accountStatus.getKey(),

View file

@ -77,7 +77,7 @@ public class RegistryBuilder {
AccountType accType = IEnumKey.getEnumByKey(AccountType.class, account.getAccountType());
if (AccountType.Clrn.equals(accType)) {
ClearingAccount accountForStatement = clearingAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", statement.getAccountId()));
ClearingAccount accountForStatement = clearingAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", statement.getAccountId()));
if (accountForStatement != null) {
rgs.setRegistryCapacity(accountForStatement.getClearingAccountType());
}

View file

@ -116,7 +116,7 @@ public class ExecutionDepositComponent {
return true;
}
MoneyFlowSide excDepSide = sTrdSide.equals(Side.BUY) ? MoneyFlowSide.BUY : MoneyFlowSide.SELL;
return executionDepositImdg.getSingleObjectByFieldValues(
return executionDepositImdg.getFirstObjectByFieldValues(
Map.of("tradingDate", sTrd.getTradeDate(),
"exchangeExecutionId", sTrd.getTradeNum(),
"side", excDepSide.getKey())) != null;
@ -173,7 +173,7 @@ public class ExecutionDepositComponent {
Company company = validator.getStored(ValidationStored.STradesCompany);
Company counterCompany = validator.getStored(ValidationStored.STradesCounterCompany);
TradingClearingRegistry rgstr = validator.getStored(ValidationStored.STradesTradingClearingRegistry);
Listing listing = listingImdg.getSingleObjectByFieldValues(Map.of("securityId", security.getId()));
Listing listing = listingImdg.getFirstObjectByFieldValues(Map.of("securityId", security.getId()));
ExecutionDeposit eDeposit = new ExecutionDeposit();
final Instant now = Instant.now();

View file

@ -110,7 +110,7 @@ public class ExecutionFondComponent {
return true;
}
Side excDepSide = sTrdSide.equals(Side.BUY) ? Side.BUY : Side.SELL;
return executionFondImdg.getSingleObjectByFieldValues(
return executionFondImdg.getFirstObjectByFieldValues(
Map.of("tradingDate", sTrd.getTradeDate(),
"exchangeExecutionId", sTrd.getTradeNum(),
"side", excDepSide.getKey())) != null;
@ -167,7 +167,7 @@ public class ExecutionFondComponent {
Company company = validator.getStored(ValidationStored.STradesCompany);
Company counterCompany = validator.getStored(ValidationStored.STradesCounterCompany);
TradingClearingRegistry rgstr = validator.getStored(ValidationStored.STradesTradingClearingRegistry);
ClientCode clientCode = clientCodeImdg.getSingleObjectByFieldValues(Map.of("code", sTrades.getClientCode()));
ClientCode clientCode = clientCodeImdg.getFirstObjectByFieldValues(Map.of("code", sTrades.getClientCode()));
ExecutionFond eFond = new ExecutionFond();
final Instant now = Instant.now();
@ -179,7 +179,7 @@ public class ExecutionFondComponent {
eFond.setTradingClearingRegistryId(rgstr.getId());
//todo можем ли просто переложить sTrades.getClassCode() или все такие искать, одно и тоже же
ru.clearing.classes.statics.data.misc.Market market = marketImdg.getSingleObjectBySQL("code = '%s'".formatted(sTrades.getClassCode()));
ru.clearing.classes.statics.data.misc.Market market = marketImdg.getFirstObjectBySQL("code = '%s'".formatted(sTrades.getClassCode()));
eFond.setMarket(sTrades.getClassCode());
eFond.setPrice(sTrades.getPrice());

View file

@ -242,7 +242,7 @@ public class Sdf01Executor extends AbstractExecutor<SDf01> {
stmt.setInSDfId(sdf01.getId());
stmt.setInOutSDfType(InOutSDfType.type1.getKey());
stmt.setClearingDate(LocalDate.now());
Currency currency = currencyImdg.getSingleObjectByFieldValues(Map.of("currencyCode", CurrencyCode.RUB.getKey()));
Currency currency = currencyImdg.getFirstObjectByFieldValues(Map.of("currencyCode", CurrencyCode.RUB.getKey()));
if (currency != null) {
stmt.setSecurityId(currency.getId());
}

View file

@ -67,7 +67,7 @@ public class Sdf04Executor extends AbstractExecutor<SDf04> {
//обычно мы ищем по группу sdf04, здесь как будто всегда только одна запись, todo нужно прочекать этот момент
log.debug("Process sdf04 record; sdf04.id: {}", sdf04.getId());
Collection<Registry> registries;
Account anltAcc = accountImdg.getSingleObjectBySQL("account = '%s' and accountType = '%s'"
Account anltAcc = accountImdg.getFirstObjectBySQL("account = '%s' and accountType = '%s'"
.formatted(sdf04.getC_acc_deb(), AccountType.Anlt.getKey()));
//если сдф04 не по аналитическому счету, выбираем по тому c_acc_deb что пришло
if (anltAcc == null) {

View file

@ -148,7 +148,7 @@ public class Sdf06Executor {
}
Company company = validator.getStored(ValidationStored.Sdf06Company);
Account account = validator.getStored(ValidationStored.Sdf06Account);
TradingClearingRegistry tcr = tradingClearingRegistryImdg.getSingleObjectByFieldValues(
TradingClearingRegistry tcr = tradingClearingRegistryImdg.getFirstObjectByFieldValues(
Map.of("moneyAccountId", account.getId())
);
//проверка существует ли statement пока убрал

View file

@ -230,9 +230,9 @@ public class Sdf08Executor extends AbstractExecutor<SDf08> {
stmt.setInSDfId(sdf08.getId());
stmt.setInOutSDfType(InOutSDfType.type08.getKey());
stmt.setClearingDate(LocalDate.now());
Security security = fixedIncomeSecurityImdg.getSingleObjectByFieldValues(Map.of("securitySymbol", sdf08.getSecurityCode()));
Security security = fixedIncomeSecurityImdg.getFirstObjectByFieldValues(Map.of("securitySymbol", sdf08.getSecurityCode()));
if (security == null) {
security = equitySecurityImdg.getSingleObjectByFieldValues(Map.of("securitySymbol", sdf08.getSecurityCode()));
security = equitySecurityImdg.getFirstObjectByFieldValues(Map.of("securitySymbol", sdf08.getSecurityCode()));
}
if (security != null) {
stmt.setSecurityId(security.getId());
@ -266,7 +266,7 @@ public class Sdf08Executor extends AbstractExecutor<SDf08> {
rgs.setAccount(account.getAccount());
rgs.setRegistryDesignation(RegistryDesignation.A.getKey());
rgs.setRegistryInstrumentType(RegistryInstrumentType.S.getKey());
DepoAccount depoAccount = depoAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", statement.getAccountId()));
DepoAccount depoAccount = depoAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", statement.getAccountId()));
if (depoAccount != null) {
rgs.setRegistryCapacity(depoAccount.getDepoAccountType());
}

View file

@ -65,7 +65,7 @@ public class Sdf13Executor extends AbstractExecutor<SDf13> {
}
protected SDf12 selectSdf12bySdf13(SDf13 sDf13) {
SDf12 sdf12 = sdf12Imdg.getSingleObjectByFieldValues(Map.of("outDocument", sDf13.getInDocument()));
SDf12 sdf12 = sdf12Imdg.getFirstObjectByFieldValues(Map.of("outDocument", sDf13.getInDocument()));
return sdf12;
}

View file

@ -415,7 +415,7 @@ public class Sdf57Executor extends AbstractExecutor<SDf57> {
statement.setComment(sdf57.getSpecif());
statement.setAccountId(accountDeb.getId());
Currency currency = currencyImdg.getSingleObjectByFieldValues(Map.of("currencyCode", "RUB"));
Currency currency = currencyImdg.getFirstObjectByFieldValues(Map.of("currencyCode", "RUB"));
if (currency != null) {
statement.setSecurityId(currency.getId());
}

View file

@ -109,7 +109,7 @@ public class SdfLegacyExecutor extends AbstractExecutor<SDf01> {
sdf02Imdg.insert(createErrorSdf02(sdf01, error.get(), generationIdForGroup));
continue;
}
Statement statement = statementImdg.getSingleObjectByFieldValues(Map.of("account", sdf01.getAccount()));
Statement statement = statementImdg.getFirstObjectByFieldValues(Map.of("account", sdf01.getAccount()));
if (statement == null) {
statement = createFlow(sdf01,
company,

View file

@ -22,7 +22,7 @@ public enum ExecutionDepositValidationRule implements IValidationRule<ImdgValida
public Optional<EnumMessage> validate(ImdgValidationContext<ExecutionDeposit> context) {
ExecutionDeposit validatedObject = context.getValidatedObject();
Imdg<Relation> relationImdg = context.obtainMap(IMDGDistributedNames.Map_Relation, Relation.class);
Relation relation = relationImdg.getSingleObjectByFieldValues(Map.of("consumerId", validatedObject.getCompanyId()));
Relation relation = relationImdg.getFirstObjectByFieldValues(Map.of("consumerId", validatedObject.getCompanyId()));
if (relation == null || !ServiceStatus.Active.equalsByKey(relation.getServiceStatus())) {
return of(ClearingErrorInternal.ClearingNotAllowed);
}
@ -52,7 +52,7 @@ public enum ExecutionDepositValidationRule implements IValidationRule<ImdgValida
public Optional<EnumMessage> validate(ImdgValidationContext<ExecutionDeposit> context) {
ExecutionDeposit validatedObject = context.getValidatedObject();
Imdg<Company> companyImdg = context.obtainMap(IMDGDistributedNames.Map_Company, Company.class);
Company company = companyImdg.getSingleObjectByFieldValues(Map.of("id", validatedObject.getCompanyId()));
Company company = companyImdg.getFirstObjectByFieldValues(Map.of("id", validatedObject.getCompanyId()));
if (company == null || !WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) {
return of(ClearingErrorInternal.CompanyNotActive);
}

View file

@ -33,7 +33,7 @@ public enum RegistryStep3ValidationRule implements IValidationRule<ImdgValidatio
if (session == null) {
return "null";
} else {
SectionDictionary section = sectionDictionaryImdg.getSingleObjectBySQL("code ='" + session.getSection() + "'");
SectionDictionary section = sectionDictionaryImdg.getFirstObjectBySQL("code ='" + session.getSection() + "'");
if (section == null) {
return "null";
} else {
@ -47,7 +47,7 @@ public enum RegistryStep3ValidationRule implements IValidationRule<ImdgValidatio
Imdg<Relation> relationImdg = context.obtainMap(IMDGDistributedNames.Map_Relation, Relation.class);
Imdg<Session> sessionImdg = context.obtainMap(IMDGDistributedNames.Map_Session, Session.class);
Session activeSession = sessionImdg.getSingleObjectByID(validatedObject.getSessionId());
Relation relation = relationImdg.getSingleObjectByFieldValues(Map.of(
Relation relation = relationImdg.getFirstObjectByFieldValues(Map.of(
"consumerId", validatedObject.getCompanyId(),
"service", activeSession.getSection()));
if (relation == null || (!ServiceStatus.Active.equalsByKey(relation.getServiceStatus()) && !ServiceStatus.Reopened.equalsByKey(relation.getServiceStatus()))) {
@ -62,7 +62,7 @@ public enum RegistryStep3ValidationRule implements IValidationRule<ImdgValidatio
public Optional<EnumMessage> validate(ImdgValidationContext<Registry> context) {
Registry validatedObject = context.getValidatedObject();
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
Account account = accountImdg.getSingleObjectBySQL("id = %d".formatted(validatedObject.getAccountId()));
Account account = accountImdg.getFirstObjectBySQL("id = %d".formatted(validatedObject.getAccountId()));
if (account == null || (!IEnumKey.contains(account.getStatus(), ServiceStatus.Active, ServiceStatus.Reopened))) {
return of(ClearingError.AccountNotActive, validatedObject.getAccountId());
}
@ -77,7 +77,7 @@ public enum RegistryStep3ValidationRule implements IValidationRule<ImdgValidatio
if (validatedObject.getCompanyId() == null) {
return of(ClearingError.CompanyNotActive, validatedObject.getCompanyId());
}
Company company = companyImdg.getSingleObjectBySQL("id = %d".formatted(validatedObject.getCompanyId()));
Company company = companyImdg.getFirstObjectBySQL("id = %d".formatted(validatedObject.getCompanyId()));
if (company == null || !WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) {
return of(ClearingError.CompanyNotActive, validatedObject.getCompanyId());
}
@ -92,7 +92,7 @@ public enum RegistryStep3ValidationRule implements IValidationRule<ImdgValidatio
return of(ClearingError.TradingClearingRegistryNotActive, validatedObject.getTradingClearingRegistryId());
}
Imdg<TradingClearingRegistry> tradingClearingRegistryImdg = context.obtainMap(IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
TradingClearingRegistry tcr = tradingClearingRegistryImdg.getSingleObjectBySQL("id = " + validatedObject.getTradingClearingRegistryId());
TradingClearingRegistry tcr = tradingClearingRegistryImdg.getFirstObjectBySQL("id = " + validatedObject.getTradingClearingRegistryId());
if (tcr == null || !(ServiceStatus.Active.equalsByKey(tcr.getStatus()) || ServiceStatus.Reopened.equalsByKey(tcr.getStatus())))
return of(ClearingError.TradingClearingRegistryNotActive, validatedObject.getTradingClearingRegistryId());
return empty();

View file

@ -30,7 +30,7 @@ public enum STradesValidationRule implements IValidationRule<ImdgValidationConte
return of(ClearingError.SecurityNotFound, validatedObject.getSecCode());
}
Imdg<Security> securityImdg = context.obtainMap(IMDGDistributedNames.Map_Security, Security.class);
Security security = securityImdg.getSingleObjectByFieldValues(Map.of("securitySymbol", validatedObject.getSecCode()));
Security security = securityImdg.getFirstObjectByFieldValues(Map.of("securitySymbol", validatedObject.getSecCode()));
if (security == null) {
return of(ClearingError.SecurityNotFound, validatedObject.getSecCode());
}
@ -48,7 +48,7 @@ public enum STradesValidationRule implements IValidationRule<ImdgValidationConte
String secCode = validatedObject.getSecCode().trim();
secCode = secCode.substring(0, Math.min(7, secCode.length()));
Imdg<MoneyMarketSecurity> securityImdg = context.obtainMap(IMDGDistributedNames.Map_MoneyMarketSecurity, MoneyMarketSecurity.class);
Security security = securityImdg.getSingleObjectByFieldValues(Map.of("securitySymbol", secCode));
Security security = securityImdg.getFirstObjectByFieldValues(Map.of("securitySymbol", secCode));
if (security == null) {
return of(ClearingError.SecurityNotFound, secCode);
}
@ -66,7 +66,7 @@ public enum STradesValidationRule implements IValidationRule<ImdgValidationConte
return of(ClearingError.CompanyNotFound, validatedObject.getFirmId());
}
Imdg<Company> companyImdg = context.obtainMap(IMDGDistributedNames.Map_Company, Company.class);
Company company = companyImdg.getSingleObjectByFieldValues(Map.of("tradingCode", validatedObject.getFirmId()));
Company company = companyImdg.getFirstObjectByFieldValues(Map.of("tradingCode", validatedObject.getFirmId()));
if (company == null) {
return of(ClearingError.CompanyNotFound, validatedObject.getFirmId());
}
@ -82,7 +82,7 @@ public enum STradesValidationRule implements IValidationRule<ImdgValidationConte
return of(ClearingError.CompanyNotFound, validatedObject.getCpFirmId());
}
Imdg<Company> companyImdg = context.obtainMap(IMDGDistributedNames.Map_Company, Company.class);
Company company = companyImdg.getSingleObjectByFieldValues(Map.of("tradingCode", validatedObject.getCpFirmId()));
Company company = companyImdg.getFirstObjectByFieldValues(Map.of("tradingCode", validatedObject.getCpFirmId()));
if (company == null) {
return of(ClearingError.CompanyNotFound, validatedObject.getCpFirmId());
}
@ -105,7 +105,7 @@ public enum STradesValidationRule implements IValidationRule<ImdgValidationConte
return of(ClearingError.CompanyNotFound, validatedObject.getSecCode());
}
Imdg<TradingClearingRegistry> registryImdg = context.obtainMap(IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
TradingClearingRegistry tcRegister = registryImdg.getSingleObjectByFieldValues(
TradingClearingRegistry tcRegister = registryImdg.getFirstObjectByFieldValues(
Map.of("code", validatedObject.getAccount().trim(),
"companyId", ((Company) context.getStoredObject(ValidationStored.STradesCompany)).getId()
));

View file

@ -29,7 +29,7 @@ public enum Sdf01NewValidationRule implements IValidationRule<ImdgValidationCont
of(ClearingError.CompanyNotFoundB, sdf01.getDeal());
}
Company company = companyImdg.getSingleObjectBySQL("tradingCode = '" + sdf01.getDeal() + "'");
Company company = companyImdg.getFirstObjectBySQL("tradingCode = '" + sdf01.getDeal() + "'");
if (company == null) {
return of(ClearingError.CompanyNotFoundB, sdf01.getDeal());
}
@ -51,7 +51,7 @@ public enum Sdf01NewValidationRule implements IValidationRule<ImdgValidationCont
public Optional<EnumMessage> validate(ImdgValidationContext<SDf01> context) {
SDf01 sdf01 = context.getValidatedObject();
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
Account acc = accountImdg.getSingleObjectBySQL("account = '" + sdf01.getAccount()
Account acc = accountImdg.getFirstObjectBySQL("account = '" + sdf01.getAccount()
+ "' and accountType='" + ru.spcex.platform.enumeration.AccountType.Clrn.getKey() + "'");
if (acc == null) {
return of (ClearingErrorInternal.AccountNotPresent, sdf01.getAccount());

View file

@ -26,7 +26,7 @@ public enum Sdf01ValidationRule implements IValidationRule<ImdgValidationContext
return of(ClearingError.CompanyNotFound);
}
Imdg<Company> companyImdg = context.obtainMap(IMDGDistributedNames.Map_Company, Company.class);
Company company = companyImdg.getSingleObjectByFieldValues(Map.of("tradingCode", sdf01.getDeal()));
Company company = companyImdg.getFirstObjectByFieldValues(Map.of("tradingCode", sdf01.getDeal()));
if (company == null) {
return of(ClearingError.CompanyNotFound);
}
@ -42,7 +42,7 @@ public enum Sdf01ValidationRule implements IValidationRule<ImdgValidationContext
return of(ClearingError.AccountNotPresent);
}
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
Account account = accountImdg.getSingleObjectByFieldValues(Map.of("account", sdf01.getAccount(),
Account account = accountImdg.getFirstObjectByFieldValues(Map.of("account", sdf01.getAccount(),
"accountType", AccountType.Clrn.getKey()));
if (account == null) {
return of(ClearingError.AccountNotPresent);

View file

@ -40,11 +40,11 @@ public enum Sdf06NewValidationRule implements IValidationRule<ImdgValidationCont
CompanySymbols companySymbols = null;
if (sdf06.getInn() != null) { //TextUtil.isEmpty
companySymbols = companySymbolsImdg.getSingleObjectByFieldValues(Map.of(
companySymbols = companySymbolsImdg.getFirstObjectByFieldValues(Map.of(
"companySymbol", CompanySymbol.INN.getKey(),
"companySymbolValue", sdf06.getInn()));
} else if (sdf06.getBic() != null) {
companySymbols = companySymbolsImdg.getSingleObjectByFieldValues(Map.of(
companySymbols = companySymbolsImdg.getFirstObjectByFieldValues(Map.of(
"companySymbol", CompanySymbol.BIC.getKey(),
"companySymbolValue", sdf06.getBic()));
}
@ -71,7 +71,7 @@ public enum Sdf06NewValidationRule implements IValidationRule<ImdgValidationCont
return of(ClearingError.AccountNotFoundB, sdf06.getAccount());
}
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
Account account = accountImdg.getSingleObjectByFieldValues(Map.of(
Account account = accountImdg.getFirstObjectByFieldValues(Map.of(
"account", sdf06.getAccount(),
"accountType", AccountType.Clrn.getKey()));
if (account == null) {

View file

@ -27,7 +27,7 @@ public enum Sdf08NewValidationRule implements IValidationRule<ImdgValidationCont
of(ClearingError.CompanyNotFoundB, sdf08.getClientName());
}
Company company = companyImdg.getSingleObjectBySQL("fullName = '" + sdf08.getClientName() + "'");
Company company = companyImdg.getFirstObjectBySQL("fullName = '" + sdf08.getClientName() + "'");
if (company == null) {
return of(ClearingError.CompanyNotFoundB, sdf08.getClientName());
}
@ -39,7 +39,7 @@ public enum Sdf08NewValidationRule implements IValidationRule<ImdgValidationCont
public Optional<EnumMessage> validate(ImdgValidationContext<SDf08> context) {
SDf08 sdf08 = context.getValidatedObject();
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
Account acc = accountImdg.getSingleObjectByFieldValues(Map.of(
Account acc = accountImdg.getFirstObjectByFieldValues(Map.of(
"account", sdf08.getDepoCode()
, "accountType",ru.spcex.platform.enumeration.AccountType.Depo.getKey()));
if (acc == null) {

View file

@ -24,11 +24,11 @@ public enum Sdf57ValidationRule implements IValidationRule<ImdgValidationContext
Optional<Company> companyCredFound = Optional.empty();
if (!TextUtil.isEmpty(sdf57.getDeal_deb())) {
companyDebFound = Optional.ofNullable(companyImdg.getSingleObjectBySQL("tradingCode = '" + sdf57.getDeal_deb() + "'"));
companyDebFound = Optional.ofNullable(companyImdg.getFirstObjectBySQL("tradingCode = '" + sdf57.getDeal_deb() + "'"));
companyDebFound.ifPresent(companyDeb -> context.storeObject(ValidationStored.Sdf57CompanyDeb, companyDeb));
}
if (!TextUtil.isEmpty(sdf57.getDeal_cred())) {
companyCredFound = Optional.ofNullable(companyImdg.getSingleObjectBySQL("tradingCode = '" + sdf57.getDeal_cred() + "'"));
companyCredFound = Optional.ofNullable(companyImdg.getFirstObjectBySQL("tradingCode = '" + sdf57.getDeal_cred() + "'"));
companyCredFound.ifPresent(companyCred -> context.storeObject(ValidationStored.Sdf57CompanyCred, companyCred));
}
@ -47,12 +47,12 @@ public enum Sdf57ValidationRule implements IValidationRule<ImdgValidationContext
Optional<Account> accountDebFound = Optional.empty();
Optional<Account> accountCredFound = Optional.empty();
if (!TextUtil.isEmpty(sdf57.getAcc_deb())) {
accountDebFound = Optional.ofNullable(accountImdg.getSingleObjectBySQL("account = '" + sdf57.getAcc_deb() + "'"));
accountDebFound = Optional.ofNullable(accountImdg.getFirstObjectBySQL("account = '" + sdf57.getAcc_deb() + "'"));
accountDebFound.ifPresent(accountDeb -> context.storeObject(ValidationStored.Sdf57AccountDeb, accountDeb));
}
if (!TextUtil.isEmpty(sdf57.getAcc_kr())) {
accountCredFound = Optional.ofNullable(accountImdg.getSingleObjectBySQL("account = '" + sdf57.getAcc_kr() + "'"));
accountCredFound = Optional.ofNullable(accountImdg.getFirstObjectBySQL("account = '" + sdf57.getAcc_kr() + "'"));
accountCredFound.ifPresent(accountCred -> context.storeObject(ValidationStored.Sdf57AccountCred, accountCred));
}
if (accountDebFound.isEmpty() && accountCredFound.isEmpty()) {

View file

@ -92,7 +92,7 @@ public abstract class AbstractSession {
}
protected void initSessionIfPresent() {
Session session = sessionImdg.getSingleObjectByFieldValues(Map.of(
Session session = sessionImdg.getFirstObjectByFieldValues(Map.of(
"sessionType", sessionType().getKey(),
"section", section().getKey(),
"workflowStatus", SessionStatus.ACTV.getKey())

View file

@ -87,7 +87,7 @@ public class BalanceRevise implements ISessionStage {
stmt.getAccount(),
stmt.getSecurityId()
);
Registry rgsAMT = registryImdg.getSingleObjectBySQL(registrySqlAMT);
Registry rgsAMT = registryImdg.getFirstObjectBySQL(registrySqlAMT);
rgsAMT.setCheckBalance(stmt.getAmount());
rgsAMT.setDiffBalance(safeBD(rgsAMT.getBalance()).subtract(safeBD(rgsAMT.getCheckBalance())));
}

View file

@ -127,7 +127,7 @@ public class FormingPaymentInstructionDealsFinalMkr implements ISessionStage {
Collection<Registry> registries = selectRegistries();
log.debug("found registries.size() = {}", registries.size());
//клиринговый счет, через который будут проводиться сделки
Account tranAcc = accountImdg.getSingleObjectBySQL("accountType = '%s' and status = '%s' and processingSign = '%s'"
Account tranAcc = accountImdg.getFirstObjectBySQL("accountType = '%s' and status = '%s' and processingSign = '%s'"
.formatted(AccountType.Tran.getKey(), AccountStatus.ACTIVE.getKey(), Allowed.ALLOWED.getKey()));
if (tranAcc == null) {
return new StageResult<>(

View file

@ -208,7 +208,7 @@ public class FormingPaymentInstructionDepositReturn implements ISessionStage {
Optional<Registry> dmtClnr = searchDmtClrn(lm_t);
if (dmtClnr.isPresent()) {
Account tranAcc = accountImdg.getSingleObjectBySQL("accountType = '%s' and status = '%s' and processingSign = '%s'"
Account tranAcc = accountImdg.getFirstObjectBySQL("accountType = '%s' and status = '%s' and processingSign = '%s'"
.formatted(AccountType.Tran.getKey(), AccountStatus.ACTIVE.getKey(), Allowed.ALLOWED.getKey()));
if (tranAcc == null) {
return new StageResult<>(
@ -278,7 +278,7 @@ public class FormingPaymentInstructionDepositReturn implements ISessionStage {
String sqlCondition = String.format("(%s) and companyId = %d",
RegistryCodeSqlBuilder.getInstance(DM_X).build(),
rgs.getCounterPartyId());
Registry dmx = registryImdg.getSingleObjectBySQL(sqlCondition);
Registry dmx = registryImdg.getFirstObjectBySQL(sqlCondition);
return Optional.ofNullable(dmx);
}
@ -292,7 +292,7 @@ public class FormingPaymentInstructionDepositReturn implements ISessionStage {
AccountType.Info.getKey(),
rgs.getCompanyId(),
rgs.getCounterPartyId());
Registry dmt = registryImdg.getSingleObjectBySQL(sqlCondition);
Registry dmt = registryImdg.getFirstObjectBySQL(sqlCondition);
return Optional.ofNullable(dmt);
}

View file

@ -149,7 +149,7 @@ public class FormingPaymentInstructionReturnMkr implements ISessionStage {
}
Optional<Registry> dmtClnr = searchDmtClrn(lm_t);
if (dmtClnr.isPresent()) {
Account tranAcc = accountImdg.getSingleObjectBySQL("accountType = '%s' and status = '%s' and processingSign = '%s'"
Account tranAcc = accountImdg.getFirstObjectBySQL("accountType = '%s' and status = '%s' and processingSign = '%s'"
.formatted(AccountType.Tran.getKey(), AccountStatus.ACTIVE.getKey(), Allowed.ALLOWED.getKey()));
if (tranAcc == null) {
return new StageResult<>(
@ -216,7 +216,7 @@ public class FormingPaymentInstructionReturnMkr implements ISessionStage {
String sqlCondition = String.format("(%s) and companyId = %d",
RegistryCodeSqlBuilder.getInstance(DM_X).build(),
rgs.getCounterPartyId());
Registry dmx = registryImdg.getSingleObjectBySQL(sqlCondition);
Registry dmx = registryImdg.getFirstObjectBySQL(sqlCondition);
return Optional.ofNullable(dmx);
}

View file

@ -124,7 +124,7 @@ public class FormingPaymentInstructionSecondaryT0 implements ISessionStage {
Collection<Registry> registries = selectRegistries();
log.debug("found registries.size() = {}", registries.size());
//клиринговый счет, через который будут проводиться сделки
Account dtrnAcc = accountImdg.getSingleObjectBySQL("accountType = '%s' and status = '%s' and processingSign = '%s'"
Account dtrnAcc = accountImdg.getFirstObjectBySQL("accountType = '%s' and status = '%s' and processingSign = '%s'"
.formatted(AccountType.Dtrn.getKey(), AccountStatus.ACTIVE.getKey(), Allowed.ALLOWED.getKey()));
if (dtrnAcc == null) {
return new StageResult<>(

View file

@ -113,7 +113,7 @@ public class InspectionObligations implements ISessionStage {
}
String sqlAssetRegistryCondition = searchAssetsByObligationSql(obligation);
log.debug("search asset by registry.id={} sql {}", obligation.getId(), sqlAssetRegistryCondition);
Registry asset = registryImdg.getSingleObjectBySQL(sqlAssetRegistryCondition);
Registry asset = registryImdg.getFirstObjectBySQL(sqlAssetRegistryCondition);
if (asset == null) {
log.warn("Not found asset by registry.id={}", obligation.getId());
isUncovered = true;

View file

@ -200,7 +200,7 @@ public class InspectionObligationsDepositReturn implements ISessionStage {
String sqlCondition = String.format("(%s) and companyId = %d",
RegistryCodeSqlBuilder.getInstance(DM_X).build(),
rgs.getCounterPartyId());
Registry dmx = registryImdg.getSingleObjectBySQL(sqlCondition);
Registry dmx = registryImdg.getFirstObjectBySQL(sqlCondition);
return Optional.ofNullable(dmx);
}
@ -213,7 +213,7 @@ public class InspectionObligationsDepositReturn implements ISessionStage {
AccountType.Info.getKey(),
rgs.getCompanyId(),
rgs.getCounterPartyId());
Registry dmt = registryImdg.getSingleObjectBySQL(sqlCondition);
Registry dmt = registryImdg.getFirstObjectBySQL(sqlCondition);
return Optional.ofNullable(dmt);
}
@ -226,7 +226,7 @@ public class InspectionObligationsDepositReturn implements ISessionStage {
AccountType.Clrn.getKey(),
rgs.getCompanyId(),
rgs.getCounterPartyId());
Registry dmt = registryImdg.getSingleObjectBySQL(sqlCondition);
Registry dmt = registryImdg.getFirstObjectBySQL(sqlCondition);
return Optional.ofNullable(dmt);
}
@ -237,7 +237,7 @@ public class InspectionObligationsDepositReturn implements ISessionStage {
RegistryCodeSqlBuilder.getInstance(AM_F).build(),
obligation.getTradingClearingRegistryId(),
obligation.getCompanyId());
Registry amf = registryImdg.getSingleObjectBySQL(sqlCondition);
Registry amf = registryImdg.getFirstObjectBySQL(sqlCondition);
return Optional.ofNullable(amf);
}

View file

@ -101,7 +101,7 @@ public class RegistryDepoBuilder implements IRegistryBuilder {
if ((isOSelling || isTBuying) && !secondLeg || (isOBuying || isTSelling) && secondLeg) {
reg.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
reg.setBalanceDimension(BalanceDimension.MONY.getKey());
Currency currency = currencyImdg.getSingleObjectByFieldValues(Map.of("currencyCode", exec.getSettlementCurrency()));
Currency currency = currencyImdg.getFirstObjectByFieldValues(Map.of("currencyCode", exec.getSettlementCurrency()));
reg.setSecurityId(currency.getId());
reg.setSecuritySymbol(currency.getCurrencyCode());
} else {
@ -156,7 +156,7 @@ public class RegistryDepoBuilder implements IRegistryBuilder {
private Long groupId() {
LocalDate now = LocalDate.now();
Market market = marketImdg.getSingleObjectBySQL("code = '" + exec.getMarket() + "'");
Market market = marketImdg.getFirstObjectBySQL("code = '" + exec.getMarket() + "'");
return Long.valueOf(now.format(yyyyMMdd) + exec.getExchangeExecutionId() + market.getId());
}
@ -167,7 +167,7 @@ public class RegistryDepoBuilder implements IRegistryBuilder {
}
private Company searchCompany() {
return companyImdg.getSingleObjectBySQL("id = " + exec.getCompanyId());
return companyImdg.getFirstObjectBySQL("id = " + exec.getCompanyId());
}
private TradingClearingRegistry searchTradingClearingRegistry() {

View file

@ -99,7 +99,7 @@ public class RegistryFondBuilder implements IRegistryBuilder {
account = accountImdg.getSingleObjectByID(tcr.getMoneyAccountId());
reg.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
reg.setBalanceDimension(BalanceDimension.MONY.getKey()); //fixme add second leg code branch
Currency currency = currencyImdg.getSingleObjectByFieldValues(Map.of("currencyCode", exec.getSettlementCurrency()));
Currency currency = currencyImdg.getFirstObjectByFieldValues(Map.of("currencyCode", exec.getSettlementCurrency()));
reg.setSecurityId(currency.getId());
reg.setSecuritySymbol(currency.getCurrencyCode());
capacityByAccount = defineCapacityByAccountType(account.getAccountType(), tcr.getMoneyAccountId());
@ -155,7 +155,7 @@ public class RegistryFondBuilder implements IRegistryBuilder {
private Long groupId() {
LocalDate now = LocalDate.now();
Market market = marketImdg.getSingleObjectBySQL("code = '" + exec.getMarket() + "'");
Market market = marketImdg.getFirstObjectBySQL("code = '" + exec.getMarket() + "'");
return Long.valueOf(now.format(yyyyMMdd) + exec.getExchangeExecutionId() + market.getId());
}
@ -166,7 +166,7 @@ public class RegistryFondBuilder implements IRegistryBuilder {
}
private Company searchCompany() {
return companyImdg.getSingleObjectBySQL("id = " + exec.getCompanyId());
return companyImdg.getFirstObjectBySQL("id = " + exec.getCompanyId());
}
private TradingClearingRegistry searchTradingClearingRegistry() {

View file

@ -142,9 +142,9 @@ class ClearingServiceTest extends AbstractClearingTest {
assertEquals(Task.createOrder.topic(), producerRecord.getValue().topic());
//First LiabilitiesClaimsAssets && LiabilitiesClaimsMoney
LiabilitiesClaimsAssets resultFirstClaimsAssets = liabilitiesClaimsAssetsImdg.getSingleObjectByFieldValues(
LiabilitiesClaimsAssets resultFirstClaimsAssets = liabilitiesClaimsAssetsImdg.getFirstObjectByFieldValues(
Map.of("accountId", accountIdI1, "settlementDate", firstSettlementDateI1));
LiabilitiesClaimsMoney resultFirstClaimsMoney = liabilitiesClaimsMoneyImdg.getSingleObjectByFieldValues(
LiabilitiesClaimsMoney resultFirstClaimsMoney = liabilitiesClaimsMoneyImdg.getFirstObjectByFieldValues(
Map.of("accountId", accountIdI1, "settlementDate", firstSettlementDateI1));
LiabilitiesClaimsAssets predictableFirstClaimsAssets = lbltsClmsAssetsCreator.createFirstLegLCA(category, executionDeposit);
predictableFirstClaimsAssets.setId(resultFirstClaimsAssets.getId());
@ -155,9 +155,9 @@ class ClearingServiceTest extends AbstractClearingTest {
LIABILITIES_CLAIMS_ASSETS_MATCHER.assertMatch(resultFirstClaimsAssets, predictableFirstClaimsAssets);
LIABILITIES_CLAIMS_MONEY_MATCHER.assertMatch(resultFirstClaimsMoney, predictableFirstClaimsMoney);
//Second LiabilitiesClaimsAssets && LiabilitiesClaimsMoney
LiabilitiesClaimsAssets resultSecondClaimsAssets = liabilitiesClaimsAssetsImdg.getSingleObjectByFieldValues(
LiabilitiesClaimsAssets resultSecondClaimsAssets = liabilitiesClaimsAssetsImdg.getFirstObjectByFieldValues(
Map.of("accountId", accountIdI1, "settlementDate", secondSettlementDateI2));
LiabilitiesClaimsMoney resultSecondClaimsMoney = liabilitiesClaimsMoneyImdg.getSingleObjectByFieldValues(
LiabilitiesClaimsMoney resultSecondClaimsMoney = liabilitiesClaimsMoneyImdg.getFirstObjectByFieldValues(
Map.of("accountId", accountIdI1, "settlementDate", secondSettlementDateI2));
LiabilitiesClaimsAssets predictableSecondClaimsAssets = lbltsClmsAssetsCreator.createSecondLegLCA(category, executionDeposit);
predictableSecondClaimsAssets.setId(resultSecondClaimsAssets.getId());
@ -173,7 +173,7 @@ class ClearingServiceTest extends AbstractClearingTest {
predictablePaymentInstruction.setDocumentNumber(resultPaymentInstruction.getDocumentNumber());
PAYMENT_INSTRUCTION_MATCHER.assertMatch(resultPaymentInstruction, predictablePaymentInstruction);
//ExecutionDeposit
ExecutionDeposit resultExecutionDeposit = executionDepositImdg.getSingleObjectByFieldValues(
ExecutionDeposit resultExecutionDeposit = executionDepositImdg.getFirstObjectByFieldValues(
Map.of("accountId", accountIdI1, "securityId", securityIdI1));
executionDeposit.setSessionId(resultExecutionDeposit.getSessionId());
EXECUTION_DEPOSIT_MATCHER.assertMatch(resultExecutionDeposit, executionDeposit);
@ -237,9 +237,9 @@ class ClearingServiceTest extends AbstractClearingTest {
assertEquals(Task.createOrder.topic(), producerRecord.getValue().topic());
//First LiabilitiesClaimsAssets && LiabilitiesClaimsMoney
LiabilitiesClaimsAssets resultFirstClaimsAssets = liabilitiesClaimsAssetsImdg.getSingleObjectByFieldValues(
LiabilitiesClaimsAssets resultFirstClaimsAssets = liabilitiesClaimsAssetsImdg.getFirstObjectByFieldValues(
Map.of("accountId", accountIdI1, "settlementDate", firstSettlementDateI1));
LiabilitiesClaimsMoney resultFirstClaimsMoney = liabilitiesClaimsMoneyImdg.getSingleObjectByFieldValues(
LiabilitiesClaimsMoney resultFirstClaimsMoney = liabilitiesClaimsMoneyImdg.getFirstObjectByFieldValues(
Map.of("accountId", accountIdI1, "settlementDate", firstSettlementDateI1));
predictableFirstClaimsAssets.setPaymentId(resultFirstClaimsAssets.getPaymentId());
predictableFirstClaimsAssets.setLiabilitiesClaimsMoneyId(resultFirstClaimsMoney.getId());
@ -248,9 +248,9 @@ class ClearingServiceTest extends AbstractClearingTest {
LIABILITIES_CLAIMS_ASSETS_MATCHER.assertMatch(resultFirstClaimsAssets, predictableFirstClaimsAssets);
LIABILITIES_CLAIMS_MONEY_MATCHER.assertMatch(resultFirstClaimsMoney, predictableFirstClaimsMoney);
//Second LiabilitiesClaimsAssets && LiabilitiesClaimsMoney
LiabilitiesClaimsAssets resultSecondClaimsAssets = liabilitiesClaimsAssetsImdg.getSingleObjectByFieldValues(
LiabilitiesClaimsAssets resultSecondClaimsAssets = liabilitiesClaimsAssetsImdg.getFirstObjectByFieldValues(
Map.of("accountId", accountIdI1, "settlementDate", secondSettlementDateI2));
LiabilitiesClaimsMoney resultSecondClaimsMoney = liabilitiesClaimsMoneyImdg.getSingleObjectByFieldValues(
LiabilitiesClaimsMoney resultSecondClaimsMoney = liabilitiesClaimsMoneyImdg.getFirstObjectByFieldValues(
Map.of("accountId", accountIdI1, "settlementDate", secondSettlementDateI2));
predictableSecondClaimsAssets.setLiabilitiesClaimsMoneyId(resultSecondClaimsMoney.getId());
@ -265,7 +265,7 @@ class ClearingServiceTest extends AbstractClearingTest {
predictablePaymentInstruction.setDocumentNumber(resultPaymentInstruction.getDocumentNumber());
PAYMENT_INSTRUCTION_MATCHER.assertMatch(resultPaymentInstruction, predictablePaymentInstruction);
//ExecutionDeposit
ExecutionDeposit resultExecutionDeposit = executionDepositImdg.getSingleObjectByFieldValues(
ExecutionDeposit resultExecutionDeposit = executionDepositImdg.getFirstObjectByFieldValues(
Map.of("accountId", accountIdI1, "securityId", securityIdI1));
executionDeposit.setSessionId(resultExecutionDeposit.getSessionId());
EXECUTION_DEPOSIT_MATCHER.assertMatch(resultExecutionDeposit, executionDeposit);
@ -417,7 +417,7 @@ class ClearingServiceTest extends AbstractClearingTest {
//ASSERT
assertEquals(Task.createOrder.topic(), producerRecord.getValue().topic());
ExecutionDeposit resultExecutionDeposit = executionDepositImdg.getSingleObjectBySQL("settlementCurrency = 'settlementCurrency'");
ExecutionDeposit resultExecutionDeposit = executionDepositImdg.getFirstObjectBySQL("settlementCurrency = 'settlementCurrency'");
executionDeposit.setUpdated(resultExecutionDeposit.getUpdated());
executionDeposit.setCoverageStatus(Allowed.DENIED.getKey());
EXECUTION_DEPOSIT_MATCHER.assertMatch(resultExecutionDeposit, executionDeposit);

View file

@ -9,7 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ru.clearing.classes.statics.data.company.CompanyRoleSet;
import ru.spcex.clearing.company.error.CompanyErrors;
import ru.spcex.clearing.util.services.RequestHelper;
import ru.spcex.clearing.imdg.IMDGDistributedNames;
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
import ru.spcex.clearing.platform.messaging.domain.Consts;
@ -18,6 +17,7 @@ import ru.spcex.clearing.platform.messaging.domain.cud.company.CompanyRoleSetNew
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
import ru.spcex.clearing.util.security.UserRoleVerification;
import ru.spcex.clearing.util.services.RequestHelper;
import ru.spcex.clearing.validation.common.ValidationHelper;
import ru.spcex.platform.imdg.api.Imdg;
import ru.spcex.platform.imdg.api.ImdgId;
@ -87,7 +87,7 @@ public class CompanyRoleSetService extends QueueConsumer implements Initializing
// if (requestInfoUpdate != null) return requestInfoUpdate;
}
//todo какие проверки нужны? 1. есть компания, 2. есть справочники
CompanyRoleSet newRole = companyRoleSetMap.getSingleObjectByFieldValues(Map.of(
CompanyRoleSet newRole = companyRoleSetMap.getFirstObjectByFieldValues(Map.of(
"companyId", req.getCompanyId(),
"companyRole", req.getCompanyRole()
));

View file

@ -37,7 +37,10 @@ import ru.spcex.platform.utils.error.ValidationException;
import ru.spcex.platform.utils.validation.IValidator;
import java.time.Instant;
import java.util.*;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -261,7 +264,7 @@ public class RelationService extends QueueConsumer implements InitializingBean {
return null;
}
Imdg<Relation> currentRelationMap = tx == null ? relationMap : tx.getImdg(IMDGDistributedNames.Map_Relation, Relation.class);
Relation existRelation = currentRelationMap.getSingleObjectByFieldValues(Map.of(
Relation existRelation = currentRelationMap.getFirstObjectByFieldValues(Map.of(
"consumerId", consumerId,
"service", svc
));
@ -562,7 +565,7 @@ public class RelationService extends QueueConsumer implements InitializingBean {
protected void createNewRelation(ImdgTransaction transaction, Long companyId, ClearingMemberCategory clearingMemberCategory) {
Objects.requireNonNull(companyId, "companyId");
Imdg<Relation> relationMap = transaction.getImdg(IMDGDistributedNames.Map_Relation, Relation.class);
Company company = transaction.getImdg(IMDGDistributedNames.Map_Company, Company.class).getSingleObjectByFieldValues(Map.of("id", companyId));
Company company = transaction.getImdg(IMDGDistributedNames.Map_Company, Company.class).getFirstObjectByFieldValues(Map.of("id", companyId));
WorkflowStatus workflowStatus = getEnumByKey(WorkflowStatus.class, company.getWorkflowStatus());
String serviceStatus = null;
@ -656,7 +659,7 @@ public class RelationService extends QueueConsumer implements InitializingBean {
protected void cancelingOfAgreementUpdateRelation(ImdgTransaction transaction, Long companyId) {
Imdg<Relation> relationMap = transaction.getImdg(IMDGDistributedNames.Map_Relation, Relation.class);
Relation relation = relationMap.getSingleObjectByFieldValues(Map.of("consumerId", companyId));
Relation relation = relationMap.getFirstObjectByFieldValues(Map.of("consumerId", companyId));
if (relation == null) {
log.warn("Relation with consumerId={} not found", companyId);
return;

View file

@ -115,7 +115,7 @@ class ClearingMemberCategoryServiceTest {
//ASSERT
waitingSendAndCheckRecord(ID, mockProducer);
ClearingMemberCategory resultNew = memberCategoryImdg.getSingleObjectBySQL(String.format("clearingMemberCategory = %s", clearingMemberCategory));
ClearingMemberCategory resultNew = memberCategoryImdg.getFirstObjectBySQL(String.format("clearingMemberCategory = %s", clearingMemberCategory));
predictableClearingMemberCategory.setId(resultNew.getId());
MEMBER_CATEGORY_MATCHER.assertMatch(resultNew, predictableClearingMemberCategory);
}
@ -180,7 +180,7 @@ class ClearingMemberCategoryServiceTest {
//ASSERT
waitingSendAndCheckRecord(id, mockProducer);
ClearingMemberCategory resultDeleting = memberCategoryImdg.getSingleObjectBySQL(String.format("clearingMemberCategory = %s", clearingMemberCategory));
ClearingMemberCategory resultDeleting = memberCategoryImdg.getFirstObjectBySQL(String.format("clearingMemberCategory = %s", clearingMemberCategory));
Assertions.assertNull(resultDeleting);
}
}

View file

@ -135,7 +135,7 @@ class CompanyServiceTest {
waitingSendAndCheckRecord(ID, mockProducer);
//Company resultDeleting = companyImdg.getSingleObjectByID(ID);
Company resultDeleting = companyImdg.getSingleObjectBySQL("id=" + ID);
Company resultDeleting = companyImdg.getFirstObjectBySQL("id=" + ID);
Assertions.assertEquals(WorkflowStatus.Blocked.getKey(), resultDeleting.getWorkflowStatus());
{
@ -177,7 +177,7 @@ class CompanyServiceTest {
//ASSERT
waitingSendAndCheckRecord(ID, mockProducer);
Company resultNew = companyImdg.getSingleObjectByFieldValues(Map.of("ShortName", "ClrIPO"));
Company resultNew = companyImdg.getFirstObjectByFieldValues(Map.of("ShortName", "ClrIPO"));
Assertions.assertNotNull(resultNew);
Assertions.assertEquals("ClrIPO", resultNew.getShortName());
Assertions.assertEquals(WorkflowStatus.Active.getKey(), resultNew.getWorkflowStatus());
@ -213,7 +213,7 @@ class CompanyServiceTest {
String.valueOf(CompanyErrors.CompanyWithCompanySymbolAlreadyExist.getId()),
Arrays.asList("CIO", "test_value"));
Company resultNew = companyImdg.getSingleObjectByFieldValues(Map.of("ShortName", "ClrIPO"));
Company resultNew = companyImdg.getFirstObjectByFieldValues(Map.of("ShortName", "ClrIPO"));
Assertions.assertNull(resultNew);
}
}

View file

@ -135,7 +135,7 @@ class CompanySymbolServiceTest {
//ASSERT
waitingSendAndCheckRecord(ID, mockProducer);
CompanySymbols resultUpdating = companySymbolsImdg.getSingleObjectBySQL(String.format("companySymbolValue = %s", companySymbolValue));
CompanySymbols resultUpdating = companySymbolsImdg.getFirstObjectBySQL(String.format("companySymbolValue = %s", companySymbolValue));
COMPANY_SYMBOL_MATCHER.assertMatch(resultUpdating, predictableCompanySymbols);
}
}

View file

@ -154,7 +154,7 @@ class ProfileDocumentServiceTest {
//ASSERT
waitingSendAndCheckRecord(ID, mockProducer);
ProfileDocument resultNew = profileDocumentMap.getSingleObjectBySQL(String.format("companyId = %d", COMPANY_ID));
ProfileDocument resultNew = profileDocumentMap.getFirstObjectBySQL(String.format("companyId = %d", COMPANY_ID));
predictableProfileDocument.setId(resultNew.getId());
PROFILE_DOCUMENT_MATCHER.assertMatch(resultNew, predictableProfileDocument);
}
@ -215,7 +215,7 @@ class ProfileDocumentServiceTest {
//ASSERT
waitingSendAndCheckRecord(ID, mockProducer);
ProfileDocument resultUpdate = profileDocumentMap.getSingleObjectBySQL(String.format("companyId = %d", COMPANY_ID));
ProfileDocument resultUpdate = profileDocumentMap.getFirstObjectBySQL(String.format("companyId = %d", COMPANY_ID));
// predictableProfileDocument.setId(resultUpdate.getId());
PROFILE_DOCUMENT_MATCHER.assertMatch(resultUpdate, predictableProfileDocument);
}

View file

@ -129,7 +129,7 @@ class RelationServiceTest {
//ASSERT
waitingSendAndCheckRecord(ID, mockProducer);
Relation resultNew = relationMap.getSingleObjectBySQL("serviceStatus=ACTV"); // String.format("supplierId = %d", COMPANY_ID));
Relation resultNew = relationMap.getFirstObjectBySQL("serviceStatus=ACTV"); // String.format("supplierId = %d", COMPANY_ID));
predictableRelation.setId(resultNew.getId());
RELATION_MATCHER.assertMatch(resultNew, predictableRelation);
}
@ -168,7 +168,7 @@ class RelationServiceTest {
//ASSERT
waitingSendAndCheckRecord(ID, mockProducer);
Relation resultUpdate = relationMap.getSingleObjectBySQL(String.format("id = %d", RELATION_ID));
Relation resultUpdate = relationMap.getFirstObjectBySQL(String.format("id = %d", RELATION_ID));
// predictableProfileDocument.setId(resultUpdate.getId());
RELATION_MATCHER.assertMatch(resultUpdate, predictableRelation);
}

View file

@ -84,8 +84,8 @@ public class AdmittedLiabilitiesRegisterService extends QueueConsumer implements
private void insertAdmittedLiabilitiesRegister(Registry registry) {
log.trace("Started generating AdmittedLiabilitiesRegister entity...");
AdmittedLiabilitiesRegister admittedLiabilitiesRegister = new AdmittedLiabilitiesRegister();
Company company = companyMap.getSingleObjectByFieldValues(Map.of("id", 1L));
Security security = securityMap.getSingleObjectByFieldValues(Map.of("id", registry.getSecurityId()));
Company company = companyMap.getFirstObjectByFieldValues(Map.of("id", 1L));
Security security = securityMap.getFirstObjectByFieldValues(Map.of("id", registry.getSecurityId()));
String securitySymbol = security != null ? security.getSecuritySymbol() : null;
String securityFullName = security != null ? security.getShortName() : null;
String companyFullName = security != null ? company.getFullName() : null;

View file

@ -85,8 +85,8 @@ public class CoveredLiabilitiesRegisterService extends QueueConsumer implements
private void insertCoveredLiabilitiesRegister(Registry registry) {
log.trace("insert CoveredLiabilitiesRegister in map...");
CoveredLiabilitiesRegister coveredLiabilitiesRegister = new CoveredLiabilitiesRegister();
Company company = companyMap.getSingleObjectByFieldValues(Map.of("id", 1L));
Security security = securityMap.getSingleObjectByFieldValues(Map.of("id", registry.getSecurityId()));
Company company = companyMap.getFirstObjectByFieldValues(Map.of("id", 1L));
Security security = securityMap.getFirstObjectByFieldValues(Map.of("id", registry.getSecurityId()));
String securitySymbol = security != null ? security.getSecuritySymbol() : null;
String securityFullName = security != null ? security.getShortName() : null;
String companyFullName = security != null ? company.getFullName() : null;

View file

@ -69,7 +69,7 @@ public class DepoPaymentInstructionRegisterService extends QueueConsumer impleme
Collection<PaymentInstruction> paymentInstructionBySessionId =
paymentInstructionMap.getCollectionObjectsByFieldValues(fieldValues);
for (PaymentInstruction paymentInstruction : paymentInstructionBySessionId) {
DepoPaymentInstructionRegister depoPaymentInstructionRegister = depoPaymentInstructionRegisterMap.getSingleObjectByFieldValues(Map.of(
DepoPaymentInstructionRegister depoPaymentInstructionRegister = depoPaymentInstructionRegisterMap.getFirstObjectByFieldValues(Map.of(
"companyId", paymentInstruction.getSenderId(),
"sessionId", paymentInstruction.getSessionId())
);
@ -85,8 +85,8 @@ public class DepoPaymentInstructionRegisterService extends QueueConsumer impleme
private void insertDepoPaymentInstructionRegister(PaymentInstruction paymentInstruction) {
log.trace("Started generating DepoPaymentInstructionRegister entity...");
DepoPaymentInstructionRegister depoPaymentInstructionRegister = new DepoPaymentInstructionRegister();
TradingClearingRegistry tradingClearingRegistry = tradingClearingRegistryMap.getSingleObjectByFieldValues(Map.of("companyId", paymentInstruction.getSenderId()));
InOutDirectionDictionary inOutDirectionDictionary = InOutDirectionDictionaryMap.getSingleObjectByFieldValues(Map.of("code", paymentInstruction.getCreditLeg_direction()));
TradingClearingRegistry tradingClearingRegistry = tradingClearingRegistryMap.getFirstObjectByFieldValues(Map.of("companyId", paymentInstruction.getSenderId()));
InOutDirectionDictionary inOutDirectionDictionary = InOutDirectionDictionaryMap.getFirstObjectByFieldValues(Map.of("code", paymentInstruction.getCreditLeg_direction()));
depoPaymentInstructionRegister.setCreated(Instant.now());
depoPaymentInstructionRegister.setUpdated(Instant.now());
depoPaymentInstructionRegister.setCompanyId(paymentInstruction.getSenderId());

View file

@ -90,11 +90,11 @@ public class ExcludeLiabilitiesRegisterService extends QueueConsumer implements
log.trace("Started generating ExcludeLiabilitiesRegister entity...");
ExcludeLiabilitiesRegister excludeLiabilitiesRegister = new ExcludeLiabilitiesRegister();
//hz communicating
Session sessionBySessionId = sessionMap.getSingleObjectByFieldValues(Map.of("clearingDate", registry.getSessionId()));
Session sessionBySessionId = sessionMap.getFirstObjectByFieldValues(Map.of("clearingDate", registry.getSessionId()));
LocalDate validToDate = TimeUtil.toLocalDate(sessionBySessionId.getUpdated());
Map<String, ? extends Comparable<?>> innPredicates = Map.of("companySymbol", "INN", "companyId", registry.getCompanyId());
ru.clearing.classes.statics.data.company.CompanySymbols companySymbol = companySymbolMap.getSingleObjectByFieldValues(innPredicates);
MoneyMarketSecurity moneyMarketSecurity = moneyMarketSecurityMap.getSingleObjectByFieldValues(Map.of("securityId", registry.getSecurityId()));
ru.clearing.classes.statics.data.company.CompanySymbols companySymbol = companySymbolMap.getFirstObjectByFieldValues(innPredicates);
MoneyMarketSecurity moneyMarketSecurity = moneyMarketSecurityMap.getFirstObjectByFieldValues(Map.of("securityId", registry.getSecurityId()));
excludeLiabilitiesRegister.setSessionId(registry.getSessionId());
excludeLiabilitiesRegister.setValidFromDate(sessionBySessionId.getClearingDate());

View file

@ -169,25 +169,25 @@ public class ExecutionRegisterService extends QueueConsumer implements Initializ
private Optional<CompanySymbols> getCompanySymbolsByCompanyIdAndCompanySymbol(String companySymbol, Long companyId) {
Map<String, ? extends Comparable<?>> fieldValues = Map.of("companySymbol", companySymbol, "companyId", companyId);
CompanySymbols companySymbols = companySymbolsMap.getSingleObjectByFieldValues(fieldValues);
CompanySymbols companySymbols = companySymbolsMap.getFirstObjectByFieldValues(fieldValues);
return Optional.ofNullable(companySymbols);
}
private Optional<CompanySymbols> getCompanySymbolsByCompanyId(Long companyId) {
Map<String, ? extends Comparable<?>> fieldValues = Map.of("companyId", companyId);
CompanySymbols companySymbols = companySymbolsMap.getSingleObjectByFieldValues(fieldValues);
CompanySymbols companySymbols = companySymbolsMap.getFirstObjectByFieldValues(fieldValues);
return Optional.ofNullable(companySymbols);
}
private Optional<TradingClearingRegistry> getTradingClearingRegistryByCompanyId(Long companyId) {
Map<String, ? extends Comparable<?>> fieldValues = Map.of("companyId", companyId);
TradingClearingRegistry tradingClearingRegistry = tradingClearingRegistryMap.getSingleObjectByFieldValues(fieldValues);
TradingClearingRegistry tradingClearingRegistry = tradingClearingRegistryMap.getFirstObjectByFieldValues(fieldValues);
return Optional.ofNullable(tradingClearingRegistry);
}
private Optional<TradingClearingRegistry> getTradingClearingRegistryByCode(String code) {
Map<String, ? extends Comparable<?>> fieldValues = Map.of("code", code);
TradingClearingRegistry tradingClearingRegistry = tradingClearingRegistryMap.getSingleObjectByFieldValues(fieldValues);
TradingClearingRegistry tradingClearingRegistry = tradingClearingRegistryMap.getFirstObjectByFieldValues(fieldValues);
return Optional.ofNullable(tradingClearingRegistry);
}
}

View file

@ -85,20 +85,20 @@ public class LiabilitiesRegisterService extends QueueConsumer implements Initial
private void insertLiabilitiesRegister(Registry registry) {
log.trace("Started generating LiabilitiesRegister entity...");
LiabilitiesRegister liabilitiesRegister = new LiabilitiesRegister();
Session session = sessionMap.getSingleObjectByFieldValues(
Session session = sessionMap.getFirstObjectByFieldValues(
Map.of(
"id",
registry.getCompanyId()
)
);
CompanySymbols companySymbols = companySymbolsMap.getSingleObjectByFieldValues(
CompanySymbols companySymbols = companySymbolsMap.getFirstObjectByFieldValues(
Map.of("companyId",
registry.getCompanyId(),
"companySymbol",
"INN"
)
);
MoneyMarketSecurity moneyMarketSecurity = moneyMarketSecurityMap.getSingleObjectByFieldValues(
MoneyMarketSecurity moneyMarketSecurity = moneyMarketSecurityMap.getFirstObjectByFieldValues(
Map.of(
"securityId",
registry.getSecurityId()

View file

@ -84,22 +84,22 @@ public class MoneyBalanceRegisterService extends QueueConsumer implements Initia
private void insertMoneyBalanceRegister(Registry registry) {
log.trace("Started generating MoneyBalanceRegister entity...");
MoneyBalanceRegister moneyBalanceRegister = new MoneyBalanceRegister();
Registry registryForRemainderSum = registryMap.getSingleObjectBySQL(getSqlForRemainderSum(registry.getCompanyId(), registry.getAccount()));
Registry registryForBlockedSum = registryMap.getSingleObjectBySQL(getSqlForBlockedSum(registry.getCompanyId(), registry.getAccount()));
Registry registryForUnblockedSum = registryMap.getSingleObjectBySQL(getSqlForUnblockedSum(registry.getCompanyId(), registry.getAccount()));
Company company = companyMap.getSingleObjectByFieldValues(Map.of("id", 2L));
CompanySymbols companySymbol = companySymbolsMap.getSingleObjectByFieldValues(Map.of("companyId", registry.getCompanyId()));
Registry registryForRemainderSum = registryMap.getFirstObjectBySQL(getSqlForRemainderSum(registry.getCompanyId(), registry.getAccount()));
Registry registryForBlockedSum = registryMap.getFirstObjectBySQL(getSqlForBlockedSum(registry.getCompanyId(), registry.getAccount()));
Registry registryForUnblockedSum = registryMap.getFirstObjectBySQL(getSqlForUnblockedSum(registry.getCompanyId(), registry.getAccount()));
Company company = companyMap.getFirstObjectByFieldValues(Map.of("id", 2L));
CompanySymbols companySymbol = companySymbolsMap.getFirstObjectByFieldValues(Map.of("companyId", registry.getCompanyId()));
String setHouseName = company != null ? company.getShortName() : null;
String inn = companySymbol != null ? companySymbol.getCompanySymbolValue() : null;
String accountType = registry.getAccountType();
String account = null;
String infoAccount = null;
if ("CLRN".equalsIgnoreCase(accountType)) {
Account accountValue = accountMap.getSingleObjectByFieldValues(Map.of("companyId", registry.getCompanyId(), "accountType", "INFO"));
Account accountValue = accountMap.getFirstObjectByFieldValues(Map.of("companyId", registry.getCompanyId(), "accountType", "INFO"));
account = registry.getAccount();
infoAccount = accountValue != null ? accountValue.getAccount() : null;
} else if ("INFO".equalsIgnoreCase(accountType)) {
Account accountValue = accountMap.getSingleObjectByFieldValues(Map.of("companyId", registry.getCompanyId(), "accountType", "CLRN"));
Account accountValue = accountMap.getFirstObjectByFieldValues(Map.of("companyId", registry.getCompanyId(), "accountType", "CLRN"));
account = accountValue != null ? accountValue.getAccount() : null;
infoAccount = registry.getAccount();
}

View file

@ -60,7 +60,7 @@ public class MoneyPaymentInstructionRegisterService extends QueueConsumer implem
paymentInstructionMap.getCollectionObjectsByFieldValues(fieldValuesSessionId);
for (PaymentInstruction paymentInstruction : paymentInstructionBySessionId) {
Map<String, ? extends Comparable<?>> fieldValuesCompanyIdSessionId = getFieldValuesOrThrowException(Map.of("senderId", paymentInstruction.getSenderId(), "date", paymentInstruction.getClearingDate()));
MoneyPaymentInstructionRegister moneyPaymentInstructionRegister = moneyPaymentInstructionRegisterMap.getSingleObjectByFieldValues(fieldValuesCompanyIdSessionId);
MoneyPaymentInstructionRegister moneyPaymentInstructionRegister = moneyPaymentInstructionRegisterMap.getFirstObjectByFieldValues(fieldValuesCompanyIdSessionId);
if (moneyPaymentInstructionRegister == null) {
insertMoneyPaymentInstructionRegister(paymentInstruction);
}

View file

@ -65,7 +65,7 @@ public abstract class ExecutedDealReportBuilderCommon<P> extends CSVReportBuilde
STrades sTrade = null;
if (executionFond.getSide() != null && executionFond.getExchangeExecutionId() != null) {
sTrade = sTradesImdg.getSingleObjectByFieldValues(
sTrade = sTradesImdg.getFirstObjectByFieldValues(
Map.of(
"tradeNum", executionFond.getExchangeExecutionId(),
"operation", executionFond.getSide()

View file

@ -79,7 +79,7 @@ public class UnfulfilledDealReportBuilder extends CSVReportBuilder<SessionIdPara
Company company = companyImdg.getSingleObjectByID(executionFond.getCompanyId());
if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) continue;;
STrades sTrade = sTradesImdg.getSingleObjectByFieldValues(
STrades sTrade = sTradesImdg.getFirstObjectByFieldValues(
Map.of(
"settleCode", executionFond.getSettlementCode(),
"operation", executionFond.getSide()

View file

@ -98,7 +98,7 @@ public class KSRepCashRegistersReportBuilder extends CSVReportBuilder<EmptyParam
ksRepCashRegistersReport.setCloseBalance(registry.getCloseBalance());
ksRepCashRegistersReport.setRemarks("");
RegistryCodeDictionary registryCodeDictionary = registryCodeDictionaryImdg.getSingleObjectByFieldValues(Map.of("code", registry.getRegistryCode()));
RegistryCodeDictionary registryCodeDictionary = registryCodeDictionaryImdg.getFirstObjectByFieldValues(Map.of("code", registry.getRegistryCode()));
if (registryCodeDictionary != null) ksRepCashRegistersReport.setRegisterName(registryCodeDictionary.getName());
if (registry.getSettledCredit() != null) {

View file

@ -96,7 +96,7 @@ public class KSRepDepoRegistersReportBuilder extends CSVReportBuilder<EmptyParam
ksRepDepoRegistersReport.setCloseQuantity(registry.getCloseBalance());
ksRepDepoRegistersReport.setRemarks(null);
RegistryCodeDictionary registryCodeDescription = registryCodeDictionaryImdg.getSingleObjectByFieldValues(Map.of("code", registry.getRegistryCode()));
RegistryCodeDictionary registryCodeDescription = registryCodeDictionaryImdg.getFirstObjectByFieldValues(Map.of("code", registry.getRegistryCode()));
if (registryCodeDescription != null) ksRepDepoRegistersReport.setRegisterName(registryCodeDescription.getName());
if (registry.getSettledCredit() != null) {

View file

@ -66,21 +66,21 @@ public class KSRepFirmDetailsReportBuilder extends CSVReportBuilder<EmptyParams,
rows = new ArrayList<>(companies.size());
for (Company company : companies) {
try {
CompanySymbols innCompanySymbol = companySymbolsImdg.getSingleObjectByFieldValues(
CompanySymbols innCompanySymbol = companySymbolsImdg.getFirstObjectByFieldValues(
Map.of(
"companyId", company.getId(),
"companySymbol", CompanySymbol.INN.getKey()
)
);
CompanySymbols cppCompanySymbol = companySymbolsImdg.getSingleObjectByFieldValues(
CompanySymbols cppCompanySymbol = companySymbolsImdg.getFirstObjectByFieldValues(
Map.of(
"companyId", company.getId(),
"companySymbol", CompanySymbol.CPP.getKey()
)
);
ProfileDocument profileDocument = profileDocumentImdg.getSingleObjectByFieldValues(
ProfileDocument profileDocument = profileDocumentImdg.getFirstObjectByFieldValues(
Map.of(
"companyId", company.getId(),
"documentType", DocumentTypes.cntr.getKey()

View file

@ -152,7 +152,7 @@ public class ClearingCalendarService extends QueueConsumer implements Initializi
boolean isWeekend = Arrays.asList(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY).contains(currentDate.getDayOfWeek());
if (isValidWorkday(clearingCalendar, isWeekend)) {
for (PlannerTemplate plannerTemplate : plannerTemplateMap.getAllValues()) {
PlannerAllToday plannerAllToday = plannerAllTodayMap.getSingleObjectBySQL(String.format("parentId = %s", plannerTemplate.getId()));
PlannerAllToday plannerAllToday = plannerAllTodayMap.getFirstObjectBySQL(String.format("parentId = %s", plannerTemplate.getId()));
if (plannerAllToday == null) {
plannerAllToday = PlannerAllTodayBuilder.builder().append(plannerTemplate).build();
plannerAllTodayMap.insert(plannerAllToday);

View file

@ -160,7 +160,7 @@ public class PlannerService extends QueueConsumer implements InitializingBean {
public void cudPlannerAllToday(Planner planner) {
if (planner.getTaskStatus().equalsIgnoreCase(Status.Active.getKey())) {
PlannerAllToday plannerAllToday = PlannerAllTodayBuilder.builder().append(planner).build();
PlannerAllToday oldPlannerAllToday = plannerAllTodayMap.getSingleObjectBySQL(String.format("parentId = %s", planner.getId()));
PlannerAllToday oldPlannerAllToday = plannerAllTodayMap.getFirstObjectBySQL(String.format("parentId = %s", planner.getId()));
if (oldPlannerAllToday != null) {
plannerAllToday.setId(oldPlannerAllToday.getId());
plannerAllTodayMap.insert(plannerAllToday);

View file

@ -138,7 +138,7 @@ public class PlannerTemplateService extends QueueConsumer implements Initializin
if (todayWorkDay()) {
PlannerAllToday plannerAllToday = PlannerAllTodayBuilder.builder().append(plannerTemplate).build();
PlannerAllToday oldPlannerAllToday = plannerAllTodayMap.getSingleObjectBySQL(String.format("parentId = %s", plannerTemplate.getId()));
PlannerAllToday oldPlannerAllToday = plannerAllTodayMap.getFirstObjectBySQL(String.format("parentId = %s", plannerTemplate.getId()));
if (oldPlannerAllToday != null) {
plannerAllToday.setId(oldPlannerAllToday.getId());
plannerAllTodayMap.insert(plannerAllToday);
@ -164,7 +164,7 @@ public class PlannerTemplateService extends QueueConsumer implements Initializin
PlannerTemplate plannerTemplate = plannerTemplateMap.getSingleObjectByID(req.getId());
if (todayWorkDay()) {
PlannerAllToday plannerAllToday = plannerAllTodayMap.getSingleObjectBySQL(String.format("parentId = %s", plannerTemplate.getId()));
PlannerAllToday plannerAllToday = plannerAllTodayMap.getFirstObjectBySQL(String.format("parentId = %s", plannerTemplate.getId()));
if (plannerAllToday != null) {
plannerAllTodayMap.delete(plannerAllToday);
addToPlannerQueue(TaskManager.Process.delete, plannerAllToday);

View file

@ -158,14 +158,14 @@ public abstract class AbstractServiceTest {
protected void checkPlannerAllTodayByPlannerTemplate(PlannerTemplate plannerTemplate) {
PlannerAllToday plannerAllToday = PlannerAllTodayBuilder.builder().append(plannerTemplate).build();
PlannerAllToday plannerAllTodayRes = plannerAllTodayImdg.getSingleObjectBySQL(String.format("companyId = %s", plannerTemplate.getCompanyId()));
PlannerAllToday plannerAllTodayRes = plannerAllTodayImdg.getFirstObjectBySQL(String.format("companyId = %s", plannerTemplate.getCompanyId()));
plannerAllToday.setId(plannerAllTodayRes.getId());
PLANNER_ALL_TODAY_MATCHER.assertMatch(plannerAllTodayRes, plannerAllToday);
}
protected void checkPlannerAllTodayByPlanner(Planner planner) {
PlannerAllToday plannerAllToday = PlannerAllTodayBuilder.builder().append(planner).build();
PlannerAllToday plannerAllTodayRes = plannerAllTodayImdg.getSingleObjectBySQL(String.format("companyId = %s", planner.getCompanyId()));
PlannerAllToday plannerAllTodayRes = plannerAllTodayImdg.getFirstObjectBySQL(String.format("companyId = %s", planner.getCompanyId()));
plannerAllToday.setId(plannerAllTodayRes.getId());
PLANNER_ALL_TODAY_MATCHER.assertMatch(plannerAllTodayRes, plannerAllToday);
}

View file

@ -77,7 +77,7 @@ class ClearingCalendarServiceTest extends AbstractServiceTest {
//ASSERT
waitingSendAndCheckRecord(ID, mockProducer);
ClearingCalendar clearingCalendarRes = clearingCalendarImdg.getSingleObjectBySQL(String.format("companyId = %s", clearingCalendar.getCompanyId()));
ClearingCalendar clearingCalendarRes = clearingCalendarImdg.getFirstObjectBySQL(String.format("companyId = %s", clearingCalendar.getCompanyId()));
clearingCalendar.setId(clearingCalendarRes.getId());
CLEARING_CALENDAR_MATCHER.assertMatch(clearingCalendarRes, clearingCalendar);
checkPlannerAllTodayByPlannerTemplate(plannerTemplate);
@ -115,7 +115,7 @@ class ClearingCalendarServiceTest extends AbstractServiceTest {
//ASSERT
waitingSendAndCheckRecord(ID, mockProducer);
ClearingCalendar clearingCalendarRes = clearingCalendarImdg.getSingleObjectBySQL(String.format("companyId = %s", clearingCalendar.getCompanyId()));
ClearingCalendar clearingCalendarRes = clearingCalendarImdg.getFirstObjectBySQL(String.format("companyId = %s", clearingCalendar.getCompanyId()));
clearingCalendar.setId(clearingCalendarRes.getId());
CLEARING_CALENDAR_MATCHER.assertMatch(clearingCalendarRes, clearingCalendar);
checkPlannerAllTodayByPlannerTemplate(plannerTemplate);
@ -150,9 +150,9 @@ class ClearingCalendarServiceTest extends AbstractServiceTest {
//ASSERT
waitingSendAndCheckRecord(id, mockProducer);
ClearingCalendar plannerTemplateRes = clearingCalendarImdg.getSingleObjectBySQL(String.format("companyId = %s", clearingCalendar.getCompanyId()));
ClearingCalendar plannerTemplateRes = clearingCalendarImdg.getFirstObjectBySQL(String.format("companyId = %s", clearingCalendar.getCompanyId()));
assertNull(plannerTemplateRes);
PlannerAllToday plannerAllTodayRes = plannerAllTodayImdg.getSingleObjectBySQL(String.format("companyId = %s", plannerTemplate.getCompanyId()));
PlannerAllToday plannerAllTodayRes = plannerAllTodayImdg.getFirstObjectBySQL(String.format("companyId = %s", plannerTemplate.getCompanyId()));
assertNull(plannerAllTodayRes);
//добавим в clearingCalendarImdg валидный clearingCalendar на случай если тесты plannerTemplate еще не отработали

View file

@ -91,7 +91,7 @@ class LauncherServiceTest extends AbstractServiceTest {
BASE_REQUEST_MATCHER.assertMatch(baseRequestResult, predictableBaseRequest);
Launcher launcherReq = launcherMap.getSingleObjectBySQL(String.format("senderId = %s", launcher.getSenderId()));
Launcher launcherReq = launcherMap.getFirstObjectBySQL(String.format("senderId = %s", launcher.getSenderId()));
launcher.setId(launcherReq.getId());
LAUNCHER_MATCHER.assertMatch(launcherReq, launcher);
}

View file

@ -71,7 +71,7 @@ class PlannerServiceTest extends AbstractServiceTest {
//ASSERT
waitingSendAndCheckRecord(ID, mockProducer);
Planner plannerReq = plannerImdg.getSingleObjectBySQL(String.format("companyId = %s", planner.getCompanyId()));
Planner plannerReq = plannerImdg.getFirstObjectBySQL(String.format("companyId = %s", planner.getCompanyId()));
planner.setId(plannerReq.getId());
PLANNER_MATCHER.assertMatch(plannerReq, planner);
checkPlannerAllTodayByPlanner(planner);
@ -107,7 +107,7 @@ class PlannerServiceTest extends AbstractServiceTest {
//ASSERT
waitingSendAndCheckRecord(planner.getId(), mockProducer);
Planner plannerReq = plannerImdg.getSingleObjectBySQL(String.format("companyId = %s", planner.getCompanyId()));
Planner plannerReq = plannerImdg.getFirstObjectBySQL(String.format("companyId = %s", planner.getCompanyId()));
planner.setId(plannerReq.getId());
PLANNER_MATCHER.assertMatch(plannerReq, planner);
checkPlannerAllTodayByPlanner(planner);
@ -139,9 +139,9 @@ class PlannerServiceTest extends AbstractServiceTest {
//ASSERT
waitingSendAndCheckRecord(plannerId, mockProducer);
Planner plannerReq = plannerImdg.getSingleObjectBySQL(String.format("companyId = %s", planner.getCompanyId()));
Planner plannerReq = plannerImdg.getFirstObjectBySQL(String.format("companyId = %s", planner.getCompanyId()));
assertNull(plannerReq);
PlannerAllToday plannerAllTodayRes = plannerAllTodayImdg.getSingleObjectBySQL(String.format("companyId = %s", planner.getCompanyId()));
PlannerAllToday plannerAllTodayRes = plannerAllTodayImdg.getFirstObjectBySQL(String.format("companyId = %s", planner.getCompanyId()));
assertNull(plannerAllTodayRes);
}
@ -166,7 +166,7 @@ class PlannerServiceTest extends AbstractServiceTest {
planner.setTaskStatus(Status.Cancel.getKey());
plannerAllTodayImdg.insert(PlannerAllTodayBuilder.builder().append(planner).build());
plannerService.cudPlannerAllToday(planner);
PlannerAllToday plannerAllTodayRes = plannerAllTodayImdg.getSingleObjectBySQL(String.format("parentId = %s", planner.getId()));
PlannerAllToday plannerAllTodayRes = plannerAllTodayImdg.getFirstObjectBySQL(String.format("parentId = %s", planner.getId()));
assertNull(plannerAllTodayRes);
}
}

View file

@ -63,7 +63,7 @@ class PlannerTemplateServiceTest extends AbstractServiceTest {
//ASSERT
waitingSendAndCheckRecord(ID, mockProducer);
PlannerTemplate plannerTemplateRes = plannerTemplateImdg.getSingleObjectBySQL(String.format("companyId = %s", plannerTemplate.getCompanyId()));
PlannerTemplate plannerTemplateRes = plannerTemplateImdg.getFirstObjectBySQL(String.format("companyId = %s", plannerTemplate.getCompanyId()));
plannerTemplate.setId(plannerTemplateRes.getId());
PLANNER_TEMPLATE_MATCHER.assertMatch(plannerTemplateRes, plannerTemplate);
checkPlannerAllTodayByPlannerTemplate(plannerTemplate);
@ -98,7 +98,7 @@ class PlannerTemplateServiceTest extends AbstractServiceTest {
//ASSERT
waitingSendAndCheckRecord(ID, mockProducer);
PlannerTemplate plannerTemplateRes = plannerTemplateImdg.getSingleObjectBySQL(String.format("companyId = %s", plannerTemplate.getCompanyId()));
PlannerTemplate plannerTemplateRes = plannerTemplateImdg.getFirstObjectBySQL(String.format("companyId = %s", plannerTemplate.getCompanyId()));
plannerTemplate.setId(plannerTemplateRes.getId());
PLANNER_TEMPLATE_MATCHER.assertMatch(plannerTemplateRes, plannerTemplate);
checkPlannerAllTodayByPlannerTemplate(plannerTemplate);
@ -129,9 +129,9 @@ class PlannerTemplateServiceTest extends AbstractServiceTest {
//ASSERT
waitingSendAndCheckRecord(id, mockProducer);
PlannerTemplate plannerTemplateRes = plannerTemplateImdg.getSingleObjectBySQL(String.format("companyId = %s", plannerTemplate.getCompanyId()));
PlannerTemplate plannerTemplateRes = plannerTemplateImdg.getFirstObjectBySQL(String.format("companyId = %s", plannerTemplate.getCompanyId()));
assertNull(plannerTemplateRes);
PlannerAllToday plannerAllTodayRes = plannerAllTodayImdg.getSingleObjectBySQL(String.format("companyId = %s", plannerTemplate.getCompanyId()));
PlannerAllToday plannerAllTodayRes = plannerAllTodayImdg.getFirstObjectBySQL(String.format("companyId = %s", plannerTemplate.getCompanyId()));
assertNull(plannerAllTodayRes);
}
}

View file

@ -297,7 +297,7 @@ public class GatewaySecurityService extends QueueConsumer implements Initializin
Map<String, Comparable<?>> query = new HashMap<>();
query.put("securityId", byRequest.getSecurityId());
query.put("market", byRequest.getMarket());
Listing existListing = listingImdg.getSingleObjectByFieldValues(query);
Listing existListing = listingImdg.getFirstObjectByFieldValues(query);
if (existListing == null)
log.trace("Listing not found by query {}", query);
else
@ -308,7 +308,7 @@ public class GatewaySecurityService extends QueueConsumer implements Initializin
CouponPeriod findCouponPeriod(CouponPeriodNewRequest byRequest) {
if (byRequest.getSecurityId() == null)
return null;
CouponPeriod existCouponPeriod = couponPeriodImdg.getSingleObjectByFieldValues(Map.of("securityId", byRequest.getSecurityId()));
CouponPeriod existCouponPeriod = couponPeriodImdg.getFirstObjectByFieldValues(Map.of("securityId", byRequest.getSecurityId()));
if (existCouponPeriod == null)
log.trace("CouponPeriod not found by securityId={}", byRequest.getSecurityId());
@ -325,7 +325,7 @@ public class GatewaySecurityService extends QueueConsumer implements Initializin
log.error("Not a number \"{}\": {}", byRequest.getSecuritySymbol(), nan.toString());
return null;
}
FixedIncomeCashFlow existFixedIncomeCashFlow = fixedIncomeCashFlowImdg.getSingleObjectByFieldValues(Map.of("securityId", securityId));
FixedIncomeCashFlow existFixedIncomeCashFlow = fixedIncomeCashFlowImdg.getFirstObjectByFieldValues(Map.of("securityId", securityId));
if (existFixedIncomeCashFlow == null)
log.trace("FixedIncomeCashFlow not found by securityId={}", securityId);
else

View file

@ -7,7 +7,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ru.clearing.classes.statics.data.instrument.issue.FixedIncomeCashFlow;
import ru.clearing.classes.statics.data.misc.Listing;
import ru.clearing.classes.statics.data.security.MoneyMarketSecurity;
import ru.spcex.clearing.imdg.IMDGDistributedNames;
@ -21,7 +20,6 @@ import ru.spcex.clearing.platform.messaging.service.RequestInfo;
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
import ru.spcex.clearing.platform.messaging.service.Status;
import ru.spcex.clearing.securities.component.ListingBuilder;
import ru.spcex.clearing.securities.errors.SecuritiesError;
import ru.spcex.clearing.securities.validation.ValidationProvider;
import ru.spcex.clearing.util.security.UserRoleVerification;
import ru.spcex.clearing.util.services.RequestHelper;
@ -222,7 +220,7 @@ public class MoneyMarketSecurityService extends QueueConsumer implements Initial
Imdg<Listing> listingTxMap = transaction.getImdg(IMDGDistributedNames.Map_Listing, Listing.class);
moneyMarketSecurityTxMap.update(mms);
Listing listing = listingTxMap.getSingleObjectByFieldValues(Map.of("securityId", mms.getId()));
Listing listing = listingTxMap.getFirstObjectByFieldValues(Map.of("securityId", mms.getId()));
if (listing == null) {
log.error("MoneyMarketSecurityUpdateRequest id {} couldn't find listing with securityId {}", req.getId(), mms.getId());
return null;
@ -270,7 +268,7 @@ public class MoneyMarketSecurityService extends QueueConsumer implements Initial
mms.setWorkflowStatus(WorkflowStatus.Blocked.getKey());
mms.setUpdated(updateTime);
moneyMarketSecurityTxMap.update(mms);
Listing listing = listingTxMap.getSingleObjectByFieldValues(Map.of("securityId", mms.getId()));
Listing listing = listingTxMap.getFirstObjectByFieldValues(Map.of("securityId", mms.getId()));
if (listing == null) {
log.error("CommonDeleteRequest id {} couldn't find listing with securityId {}", req.getId(), mms.getId());
return null;

View file

@ -7,9 +7,10 @@ import ru.clearing.platform.dictionary.CurrencyCodeDictionary;
import ru.clearing.platform.dictionary.WorkflowStatusDictionary;
import ru.spcex.clearing.imdg.IMDGDistributedNames;
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest;
import ru.spcex.clearing.platform.messaging.domain.cud.securitites.*;
import ru.spcex.clearing.util.security.SecuritySelector;
import ru.spcex.clearing.platform.messaging.domain.cud.securitites.ListingNewRequest;
import ru.spcex.clearing.platform.messaging.domain.cud.securitites.ListingUpdateRequest;
import ru.spcex.clearing.securities.errors.SecuritiesError;
import ru.spcex.clearing.util.security.SecuritySelector;
import ru.spcex.clearing.validation.common.rules.DictionaryPresentRule;
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
import ru.spcex.clearing.validation.common.rules.SpecialIdPresentRule;
@ -200,7 +201,7 @@ public class ListingValidationProvider {
String market = marketGetter.apply(validatedObject);
if (market == null) return empty();
Imdg<Listing> listingImdg = context.obtainMap(IMDGDistributedNames.Map_Listing, Listing.class);
Listing fromMap = listingImdg.getSingleObjectByFieldValues(Map.of(
Listing fromMap = listingImdg.getFirstObjectByFieldValues(Map.of(
"securityId", securityId,
"market", market,
"workflowStatus", WorkflowStatus.Active.getKey()

View file

@ -21,7 +21,7 @@ public enum CouponPeriodNewValidationRule implements IValidationRule<ImdgValidat
return of(SecuritiesError.RequiredFieldIsEmpty, "securityId");
}
Imdg<SpcexObjectBase> imdgDictionary = context.obtainMap(IMDGDistributedNames.Map_CouponPeriod, SpcexObjectBase.class);
SpcexObjectBase couponPeriod = imdgDictionary.getSingleObjectByFieldValues(Map.of(
SpcexObjectBase couponPeriod = imdgDictionary.getFirstObjectByFieldValues(Map.of(
"securityId", action.getSecurityId()));
if (couponPeriod != null) {
return of(SecuritiesError.CouponPeriodAlreadyExists, "securityId");

View file

@ -21,7 +21,7 @@ public enum CouponPeriodUpdateValidationRule implements IValidationRule<ImdgVali
return of(SecuritiesError.RequiredFieldIsEmpty, "securityId");
}
Imdg<SpcexObjectBase> imdgDictionary = context.obtainMap(IMDGDistributedNames.Map_CouponPeriod, SpcexObjectBase.class);
SpcexObjectBase currency = imdgDictionary.getSingleObjectByFieldValues(Map.of(
SpcexObjectBase currency = imdgDictionary.getFirstObjectByFieldValues(Map.of(
"securityId", action.getSecurityId()));
if (currency == null) {
return of(SecuritiesError.CouponPeriodNotFound, "securityId");

View file

@ -22,7 +22,7 @@ public enum CurrencyNewValidationRule implements IValidationRule<ImdgValidationC
return of(SecuritiesError.RequiredFieldIsEmpty, "currencyCode");
}
Imdg<SpcexObjectBase> imdgDictionary = context.obtainMap(IMDGDistributedNames.Map_Currency, SpcexObjectBase.class);
SpcexObjectBase currency = imdgDictionary.getSingleObjectByFieldValues(Map.of(
SpcexObjectBase currency = imdgDictionary.getFirstObjectByFieldValues(Map.of(
"currencyCode", action.getCurrencyCode()));
if (currency != null) {
return of(SecuritiesError.CurrencyAlreadyExists, "currencyCode");

Some files were not shown because too many files have changed in this diff Show more