|
| 1 | +/* |
| 2 | + * Copyright © 2022 Linked Data Benchmark Council (info@ldbcouncil.org) |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package ldbc.finbench.datagen.entities.edges; |
| 18 | + |
| 19 | +import java.io.Serializable; |
| 20 | +import java.util.List; |
| 21 | +import ldbc.finbench.datagen.entities.DynamicActivity; |
| 22 | +import ldbc.finbench.datagen.entities.nodes.Account; |
| 23 | +import ldbc.finbench.datagen.entities.nodes.Company; |
| 24 | +import ldbc.finbench.datagen.entities.nodes.Loan; |
| 25 | +import ldbc.finbench.datagen.entities.nodes.Person; |
| 26 | +import ldbc.finbench.datagen.entities.nodes.PersonOrCompany; |
| 27 | +import ldbc.finbench.datagen.generation.dictionary.Dictionaries; |
| 28 | +import ldbc.finbench.datagen.util.RandomGeneratorFarm; |
| 29 | + |
| 30 | +public class ApplyLoan implements DynamicActivity, Serializable { |
| 31 | + private final long ownerId; |
| 32 | + private final PersonOrCompany ownerType; |
| 33 | + private final long loanId; |
| 34 | + private final long creationDate; |
| 35 | + private final long deletionDate; |
| 36 | + private final boolean isExplicitlyDeleted; |
| 37 | + private final String organization; |
| 38 | + private final String comment; |
| 39 | + private final double loanAmount; |
| 40 | + |
| 41 | + public ApplyLoan(long ownerId, PersonOrCompany ownerType, long loanId, long creationDate, long deletionDate, |
| 42 | + boolean isExplicitlyDeleted, String organization, String comment, double loanAmount) { |
| 43 | + this.ownerId = ownerId; |
| 44 | + this.ownerType = ownerType; |
| 45 | + this.loanId = loanId; |
| 46 | + this.creationDate = creationDate; |
| 47 | + this.deletionDate = deletionDate; |
| 48 | + this.isExplicitlyDeleted = isExplicitlyDeleted; |
| 49 | + this.organization = organization; |
| 50 | + this.comment = comment; |
| 51 | + this.loanAmount = loanAmount; |
| 52 | + } |
| 53 | + |
| 54 | + public static void createApplyLoan(RandomGeneratorFarm farm, long creationDate, Person person, Loan loan) { |
| 55 | + loan.setOwnerType(PersonOrCompany.PERSON); |
| 56 | + loan.setOwnerPersonId(person.getPersonId()); |
| 57 | + person.addLoan(loan); |
| 58 | + |
| 59 | + List<Account> poa = person.getAccount(); |
| 60 | + loan.setAccounts(poa.toArray(new Account[0])); |
| 61 | + |
| 62 | + String organization = Dictionaries.loanOrganizations.getUniformDistRandomText( |
| 63 | + farm.get(RandomGeneratorFarm.Aspect.PERSON_APPLY_LOAN_ORGANIZATION)); |
| 64 | + String comment = |
| 65 | + Dictionaries.randomTexts.getUniformDistRandomTextForComments( |
| 66 | + farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT)); |
| 67 | + |
| 68 | + ApplyLoan applyLoan = |
| 69 | + new ApplyLoan(person.getPersonId(), |
| 70 | + PersonOrCompany.PERSON, |
| 71 | + loan.getLoanId(), |
| 72 | + creationDate, |
| 73 | + 0, |
| 74 | + false, |
| 75 | + organization, |
| 76 | + comment, |
| 77 | + loan.getLoanAmount()); |
| 78 | + person.getApplyLoans().add(applyLoan); |
| 79 | + } |
| 80 | + |
| 81 | + public static void createApplyLoan(RandomGeneratorFarm farm, long creationDate, Company company, Loan loan) { |
| 82 | + loan.setOwnerType(PersonOrCompany.COMPANY); |
| 83 | + loan.setOwnerCompanyId(company.getCompanyId()); |
| 84 | + company.addLoan(loan); |
| 85 | + |
| 86 | + List<Account> coa = company.getAccount(); |
| 87 | + loan.setAccounts(coa.toArray(new Account[0])); |
| 88 | + |
| 89 | + String organization = Dictionaries.loanOrganizations.getUniformDistRandomText( |
| 90 | + farm.get(RandomGeneratorFarm.Aspect.COMPANY_APPLY_LOAN_ORGANIZATION)); |
| 91 | + String comment = |
| 92 | + Dictionaries.randomTexts.getUniformDistRandomTextForComments( |
| 93 | + farm.get(RandomGeneratorFarm.Aspect.COMMON_COMMENT)); |
| 94 | + |
| 95 | + ApplyLoan applyLoan = |
| 96 | + new ApplyLoan(company.getCompanyId(), |
| 97 | + PersonOrCompany.COMPANY, |
| 98 | + loan.getLoanId(), |
| 99 | + creationDate, |
| 100 | + 0, |
| 101 | + false, |
| 102 | + organization, |
| 103 | + comment, |
| 104 | + loan.getLoanAmount()); |
| 105 | + company.getApplyLoans().add(applyLoan); |
| 106 | + } |
| 107 | + |
| 108 | + public long getOwnerId() { |
| 109 | + return ownerId; |
| 110 | + } |
| 111 | + |
| 112 | + public PersonOrCompany getOwnerType() { |
| 113 | + return ownerType; |
| 114 | + } |
| 115 | + |
| 116 | + public long getLoanId() { |
| 117 | + return loanId; |
| 118 | + } |
| 119 | + |
| 120 | + @Override |
| 121 | + public long getCreationDate() { |
| 122 | + return creationDate; |
| 123 | + } |
| 124 | + |
| 125 | + @Override |
| 126 | + public long getDeletionDate() { |
| 127 | + return deletionDate; |
| 128 | + } |
| 129 | + |
| 130 | + @Override |
| 131 | + public boolean isExplicitlyDeleted() { |
| 132 | + return isExplicitlyDeleted; |
| 133 | + } |
| 134 | + |
| 135 | + public String getOrganization() { |
| 136 | + return organization; |
| 137 | + } |
| 138 | + |
| 139 | + public String getComment() { |
| 140 | + return comment; |
| 141 | + } |
| 142 | + |
| 143 | + public double getLoanAmount() { |
| 144 | + return loanAmount; |
| 145 | + } |
| 146 | +} |
0 commit comments