Skip to content

Commit

Permalink
distinguish the gen interface
Browse files Browse the repository at this point in the history
  • Loading branch information
qishipengqsp committed Aug 18, 2024
1 parent 5164f26 commit 95bd5a3
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void createCompanyApplyLoan(RandomGeneratorFarm farm, long creatio
String organization = Dictionaries.loanOrganizations.getUniformDistRandomText(
farm.get(RandomGeneratorFarm.Aspect.COMPANY_APPLY_LOAN_ORGANIZATION));
String comment =
Dictionaries.randomTexts.getUniformDistRandomText(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
Dictionaries.randomTexts.getUniformDistRandomTextForComment(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
loan.setOwnerType(PersonOrCompany.COMPANY);
loan.setOwnerCompany(company);
CompanyApplyLoan companyApplyLoan =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void createCompanyGuaranteeCompany(RandomGeneratorFarm farm, Compa
Random dateRand = farm.get(RandomGeneratorFarm.Aspect.COMPANY_GUARANTEE_DATE);
long creationDate = Dictionaries.dates.randomCompanyToCompanyDate(dateRand, fromCompany, toCompany);
String comment =
Dictionaries.randomTexts.getUniformDistRandomText(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
Dictionaries.randomTexts.getUniformDistRandomTextForComment(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
CompanyGuaranteeCompany companyGuaranteeCompany = new CompanyGuaranteeCompany(fromCompany,
toCompany, creationDate, 0, false,
"business associate", comment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static CompanyInvestCompany createCompanyInvestCompany(RandomGeneratorFar
long creationDate = Dictionaries.dates.randomCompanyToCompanyDate(dateRandom, fromCompany, toCompany);
double ratio = farm.get(RandomGeneratorFarm.Aspect.INVEST_RATIO).nextDouble();
String comment =
Dictionaries.randomTexts.getUniformDistRandomText(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
Dictionaries.randomTexts.getUniformDistRandomTextForComment(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
CompanyInvestCompany companyInvestCompany =
new CompanyInvestCompany(fromCompany, toCompany, creationDate, 0, ratio, false, comment);
fromCompany.getCompanyInvestCompanies().add(companyInvestCompany);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void createCompanyOwnAccount(RandomGeneratorFarm farm, Company com
account.setOwnerType(PersonOrCompany.COMPANY);
account.setCompanyOwner(company);
String comment =
Dictionaries.randomTexts.getUniformDistRandomText(
Dictionaries.randomTexts.getUniformDistRandomTextForComment(
farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
CompanyOwnAccount companyOwnAccount =
new CompanyOwnAccount(company, account, creationDate, account.getDeletionDate(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static Deposit createDeposit(RandomGeneratorFarm farm, Loan loan, Account
Dictionaries.dates.randomLoanToAccountDate(farm.get(RandomGeneratorFarm.Aspect.LOAN_SUBEVENTS_DATE), loan,
account, account.getDeletionDate());
String comment =
Dictionaries.randomTexts.getUniformDistRandomText(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
Dictionaries.randomTexts.getUniformDistRandomTextForComment(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
Deposit deposit =
new Deposit(loan, account, amount, creationDate, account.getDeletionDate(), account.isExplicitlyDeleted(),
comment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void createPersonApplyLoan(RandomGeneratorFarm farm, long creation
String organization = Dictionaries.loanOrganizations.getUniformDistRandomText(
farm.get(RandomGeneratorFarm.Aspect.PERSON_APPLY_LOAN_ORGANIZATION));
String comment =
Dictionaries.randomTexts.getUniformDistRandomText(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
Dictionaries.randomTexts.getUniformDistRandomTextForComment(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
loan.setOwnerType(PersonOrCompany.PERSON);
loan.setOwnerPerson(person);
PersonApplyLoan personApplyLoan =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void createPersonGuaranteePerson(RandomGeneratorFarm farm, Person
String relation = Dictionaries.guaranteeRelationships.getDistributedText(
farm.get(RandomGeneratorFarm.Aspect.PERSON_GUARANTEE_RELATIONSHIP));
String comment =
Dictionaries.randomTexts.getUniformDistRandomText(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
Dictionaries.randomTexts.getUniformDistRandomTextForComment(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
PersonGuaranteePerson personGuaranteePerson =
new PersonGuaranteePerson(fromPerson, toPerson, creationDate, 0, false, relation, comment);
fromPerson.getGuaranteeSrc().add(personGuaranteePerson);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static PersonInvestCompany createPersonInvestCompany(RandomGeneratorFarm
long creationDate = Dictionaries.dates.randomPersonToCompanyDate(dateRandom, person, company);
double ratio = farm.get(RandomGeneratorFarm.Aspect.INVEST_RATIO).nextDouble();
String comment =
Dictionaries.randomTexts.getUniformDistRandomText(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
Dictionaries.randomTexts.getUniformDistRandomTextForComment(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
PersonInvestCompany personInvestCompany = new PersonInvestCompany(person, company, creationDate, 0, ratio,
false, comment);
person.getPersonInvestCompanies().add(personInvestCompany);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void createPersonOwnAccount(RandomGeneratorFarm farm, Person perso
account.setOwnerType(PersonOrCompany.PERSON);
account.setPersonOwner(person);
String comment =
Dictionaries.randomTexts.getUniformDistRandomText(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
Dictionaries.randomTexts.getUniformDistRandomTextForComment(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
PersonOwnAccount personOwnAccount = new PersonOwnAccount(person, account, creationDate,
account.getDeletionDate(),
account.isExplicitlyDeleted(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static Repay createRepay(RandomGeneratorFarm farm, Account account, Loan
Dictionaries.dates.randomAccountToLoanDate(farm.get(RandomGeneratorFarm.Aspect.LOAN_SUBEVENTS_DATE),
account, loan, account.getDeletionDate());
String comment =
Dictionaries.randomTexts.getUniformDistRandomText(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
Dictionaries.randomTexts.getUniformDistRandomTextForComment(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
Repay repay = new Repay(account, loan, amount, creationDate, account.getDeletionDate(),
account.isExplicitlyDeleted(), comment);
loan.addRepay(repay);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static SignIn createSignIn(RandomGeneratorFarm farm, int mid, Medium medi
Dictionaries.dates.randomMediumToAccountDate(farm.get(RandomGeneratorFarm.Aspect.SIGNIN_DATE), medium,
account, account.getDeletionDate());
String comment =
Dictionaries.randomTexts.getUniformDistRandomText(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
Dictionaries.randomTexts.getUniformDistRandomTextForComment(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
SignIn signIn = new SignIn(medium, account, mid, creationDate, account.getDeletionDate(),
account.isExplicitlyDeleted(), comment);
// Set country and city
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static Transfer createTransferAndReturn(RandomGeneratorFarm farm, Account

// Set comment
String comment =
Dictionaries.randomTexts.getUniformDistRandomText(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
Dictionaries.randomTexts.getUniformDistRandomTextForComment(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
transfer.setComment(comment);

// Set payType
Expand Down Expand Up @@ -83,7 +83,7 @@ public static Transfer createLoanTransferAndReturn(RandomGeneratorFarm farm, Acc

// Set comment
String comment =
Dictionaries.randomTexts.getUniformDistRandomText(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
Dictionaries.randomTexts.getUniformDistRandomTextForComment(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
transfer.setComment(comment);

// Set payType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static Withdraw createWithdraw(RandomGeneratorFarm farm, Account from, Ac
double amount =
farm.get(RandomGeneratorFarm.Aspect.WITHDRAW_AMOUNT).nextDouble() * DatagenParams.withdrawMaxAmount;
String comment =
Dictionaries.randomTexts.getUniformDistRandomText(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
Dictionaries.randomTexts.getUniformDistRandomTextForComment(farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT));
Withdraw withdraw =
new Withdraw(from, to, amount, creationDate, deleteDate, multiplicityId, willDelete, comment);
from.getWithdraws().add(withdraw);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public CommonTextDictionary(String filePath, String separator) {

try {
InputStreamReader inputStreamReader = new InputStreamReader(
Objects.requireNonNull(getClass().getResourceAsStream(filePath)), StandardCharsets.UTF_8);
Objects.requireNonNull(getClass().getResourceAsStream(filePath)), StandardCharsets.UTF_8);
BufferedReader dictionary = new BufferedReader(inputStreamReader);
String line;
long totalNum = 0;
Expand All @@ -36,4 +36,10 @@ public String getUniformDistRandomText(Random random) {
long nameIndex = random.nextInt(resources.size());
return resources.get(nameIndex);
}

public String getUniformDistRandomTextForComment(Random random) {
long index1 = random.nextInt(resources.size());
long index2 = random.nextInt(resources.size());
return resources.get(index1) + " " + resources.get(index2);
}
}

0 comments on commit 95bd5a3

Please sign in to comment.