1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567
|
package com.mtsa.ebonus.core.business.action;
import java.util.*;
import com.mtsa.common.control.ErrorController;
import com.mtsa.common.error.ErrorLevel;
import com.mtsa.ebonus.core.business.*;
import com.mtsa.ebonus.core.business.Currency;
import com.mtsa.ebonus.core.business.product.*;
import com.mtsa.ebonus.core.db.*;
import com.mtsa.ebonus.core.db.action.*;
import com.mtsa.ebonus.core.db.product.*;
public class Action extends MultiLanguageEntity {
/* Logs and errors */
private static ErrorController ec = ErrorController.getErrorController(Action.class.getName(), ErrorLevel.DEBUG);
private static final String ERR_CLONE = "BUE1010";
private static final String ERR_CONVERT = "BUE1020";
private static final String ERR_EQUALS = "BUE1030";
/* Db entity */
public ActionDb dbEntity;
// ------------------- CONSTRUCTOR(S) -----------------------------//
Action(MessageService messageService) {
this(messageService, null, null);
}
/**
* Constructor NEEDS a message service (can't be NULL)
* The dbEntity of the super must be "overwritten" with specific dbEntity
* If selectedLanguageId is NULL, default language is used
*
* @param messageService
* @param dbEntity
* @param selectedLanguageId
*/
Action(MessageService messageService, ActionDb dbEntity) {
this(messageService, dbEntity, null);
}
/**
* Constructor NEEDS a message service (can't be NULL)
* The dbEntity of the super must be "overwritten" with specific dbEntity
* If selectedLanguageId is NULL, default language is used
*
* @param messageService
* @param dbEntity
* @param selectedLanguageId
*/
Action(MessageService messageService, ActionDb dbEntity, Integer selectedLanguageId) {
super(messageService, dbEntity, selectedLanguageId);
ec.log("Begin - CONSTRUCTOR");
if (dbEntity != null) {
this.setDbEntity(dbEntity);
} else {
this.setDbEntity(new ActionDb());
}
ec.log("End - CONSTRUCTOR");
}
// ------------- ATTRIBUTE for MULTI_LANGUAGE entity -----------------//
public ActionDb getDbEntity() {
return this.dbEntity;
}
public void setDbEntity(ActionDb dbEntity) {
this.dbEntity = dbEntity;
// to add manually
super.setDbEntity(dbEntity);
}
@Override
protected Integer getRefDescription() {
return this.getDbEntity().getRefDescription();
}
@Override
protected void setRefDescription(Integer refMessage) {
this.getDbEntity().setRefDescription(refMessage);
}
// --------------------- BASIC JAVA METHODS -----------------------//
/**
* This method is especially used for logging (to avoid "null pointer" exception)
*/
public String toString() {
String result = "marketId=" + this.getMarketId();
result += " / actionTypeId=" + this.getActionTypeId();
result += " / actionId=" + this.getActionId();
result += " / refDescription=" + this.getRefDescription();
return result;
}
/**
* Compare following values between "this" and the param Entity:
* - Market ID
* - Action Type ID
* - Action ID
*
* @param buEntity
*
* @return boolean ("false" if this.getID or buEntity is NULL)
*/
public boolean equals(Action buEntity) {
ec.log("Begin - equals(), buEntity: " + buEntity);
boolean result = false;
try {
if (buEntity != null) {
result = this.getMarketId().equals(buEntity.getMarketId());
result = result && this.getActionTypeId().equals(buEntity.getActionTypeId());
result = result && this.getActionId().equals(buEntity.getActionId());
}
} catch (RuntimeException ex) {
ec.handleError(ERR_EQUALS, ex);
}
ec.log("End - equals(), result: " + result);
return result;
}
/**
* Create a new Action with same parameters
*
* @param message
* source Message
*
* @return Message resulted from the copy
*/
public Action clone() {
ec.log("Begin - clone()");
Action result = null;
try {
result = new Action(this.getMessageService());
result.setMarketId(this.getMarketId());
result.setActionTypeId(this.getActionTypeId());
result.setActionId(this.getActionId());
// copying messages
List<Message> messages = this.getMessageService().getCopyMessages(this.getMessages());
result.setMessages(messages);
// TODO add copy all other business informations
} catch (RuntimeException ex) {
ec.handleError(ERR_CLONE, ex);
}
ec.log("End - clone(), result: " + result);
return result;
}
// -------------- CONVERSIONS ----------------------//
/**
* Convert a list of DB entities to a list of BU entities (use default language)
*
* @param dbEntities
* @param messageService
*
* @return (can be EMPTY, not null)
*/
public static List<Action> convertFromDbEntites(Collection<ActionDb> dbEntities, MessageService messageService) {
return convertFromDbEntites(dbEntities, messageService, null);
}
/**
* Convert a list of DB Entities to a list of BU Entities
*
* @param dbEntities
* @param messageService
* @param languageId
*
* @return (can be EMPTY, not null)
*/
public static List<Action> convertFromDbEntites(Collection<ActionDb> dbEntities, MessageService messageService,
Integer languageId) {
ec.log("Begin - convertFromDbEntites, dbEntities: " + dbEntities);
List<Action> result = new ArrayList<Action>();
if (dbEntities != null && dbEntities.size() > 0) {
for (ActionDb dbEntity : dbEntities) {
Action myBuEntity = convertFromDbEntity(dbEntity, messageService, languageId);
result.add(myBuEntity);
}
}
ec.log("End - convertFromDbEntites, buEntites size: " + result.size());
return result;
}
/**
* Convert a DB Entity to a BU Entity (use default language)
*
* @param dbEntity
* @param messageService
*
* @return (can be NULL)
*/
public static Action convertFromDbEntity(ActionDb dbEntity, MessageService messageService) {
return convertFromDbEntity(dbEntity, messageService, null);
}
/**
* Convert a DB Entity to a BU Entity
*
* @param dbEntity
* @param messageService
* @param languageId
*
* @return (can be NULL)
*/
public static Action convertFromDbEntity(ActionDb dbEntity, MessageService messageService, Integer languageId) {
ec.log("Begin - convertFromDbEntity, dbEntity: " + dbEntity);
Action result = null;
if (dbEntity != null) {
try {
result = new Action(messageService, dbEntity, languageId);
} catch (RuntimeException ex) {
ec.handleError(ERR_CONVERT, ex);
}
}
ec.log("End - convertFromDbEntity, result: " + result);
return result;
}
// ---------------------- DELEGATION -----------------------------//
public void setIds(String marketId, String actionTypeId, String actionId) {
this.setMarketId(marketId);
this.setActionTypeId(actionTypeId);
this.setActionId(actionId);
}
public String getMarketId() {
if (dbEntity.getId() == null)
dbEntity.setId(new ActionDbId());
return this.dbEntity.getId().getIdMarket();
}
public String getActionTypeId() {
if (dbEntity.getId() == null)
dbEntity.setId(new ActionDbId());
return this.dbEntity.getId().getIdActionType();
}
public String getActionId() {
if (dbEntity.getId() == null)
dbEntity.setId(new ActionDbId());
return this.dbEntity.getId().getActionId();
}
public void setMarketId(String marketId) {
if (dbEntity.getId() == null)
dbEntity.setId(new ActionDbId());
this.dbEntity.getId().setIdMarket(marketId);
}
public void setActionTypeId(String actionTypeId) {
if (dbEntity.getId() == null)
dbEntity.setId(new ActionDbId());
this.dbEntity.getId().setIdActionType(actionTypeId);
}
public void setActionId(String actionId) {
if (dbEntity.getId() == null)
dbEntity.setId(new ActionDbId());
this.dbEntity.getId().setActionId(actionId);
}
public String getActionExcel() {
return dbEntity.getActionExcel();
}
public String getActionPdf() {
return dbEntity.getActionPdf();
}
public Set getActionPeriods() {
return dbEntity.getActionPeriods();
}
public ActionState getActionState() {
return ActionState.convertFromDbEntity(dbEntity.getActionState(), this.getMessageService());
}
public ActionType getActionType() {
return ActionType.convertFromDbEntity(dbEntity.getActionType(), this.getMessageService());
}
public void setActionState(ActionState actionState) {
dbEntity.setActionState(actionState.getDbEntity());
}
public void setActionType(ActionType actionType) {
dbEntity.setActionType(actionType.getDbEntity());
}
public Integer getDayLimit() {
return dbEntity.getDayLimit();
}
public Set getActionProducts() {
return dbEntity.getActionProducts();
}
public String getActionUrl() {
return dbEntity.getActionUrl();
}
public String getActionWord() {
return dbEntity.getActionWord();
}
public String getAnalyticCode() {
return dbEntity.getAnalyticCode();
}
public Integer getBeneficiary() {
return dbEntity.getBeneficiary();
}
public String getCommessa() {
return dbEntity.getCommessa();
}
public String getCostCenter() {
return dbEntity.getCostCenter();
}
public String getFiscalYear() {
return dbEntity.getFiscalYear();
}
public Date getInputDelay() {
return dbEntity.getInputDelay();
}
public Boolean getIsBlocked() {
return dbEntity.getIsBlocked();
}
public Boolean getIsDeleted() {
return dbEntity.getIsDeleted();
}
public Boolean getIsExceptStandard() {
return dbEntity.getIsExceptStandard();
}
public Boolean getIsMinimumObjective() {
return dbEntity.getIsMinimumObjective();
}
public Boolean getIsPaymentCancelled() {
return dbEntity.getIsPaymentCancelled();
}
public Boolean getIsStepsRollup() {
return dbEntity.getIsStepsRollup();
}
public Boolean getIsVisibleAmount() {
return dbEntity.getIsVisibleAmount();
}
public Double getLimitAmount() {
return dbEntity.getLimitAmount();
}
public String getNatureCode() {
return dbEntity.getNatureCode();
}
public Integer getOperationalMode() {
return dbEntity.getOperationalMode();
}
public Integer getPriorityMode() {
return dbEntity.getPriorityMode();
}
public Integer getActionStateId() {
return dbEntity.getActionStateId();
}
public Integer getElementId() {
return dbEntity.getElementId();
}
public String getObjectiveSetId() {
return dbEntity.getObjectiveSetId();
}
public String getProductFamilyId() {
return dbEntity.getProductFamilyId();
}
public String getCurrencyId() {
return dbEntity.getCurrencyId();
}
public void setFromDate(Date fromDate) {
dbEntity.setFromDate(fromDate);
}
public Integer getSettlement() {
return dbEntity.getSettlement();
}
public Date getToDate() {
return dbEntity.getToDate();
}
public Date getFromDate() {
return dbEntity.getFromDate();
}
public void setActionExcel(String actionExcel) {
dbEntity.setActionExcel(actionExcel);
}
public void setActionPdf(String actionPdf) {
dbEntity.setActionPdf(actionPdf);
}
public void setActionPeriods(Set actionPeriods) {
dbEntity.setActionPeriods(actionPeriods);
}
public void setActionProducts(Set actionProducts) {
dbEntity.setActionProducts(actionProducts);
}
public void setActionUrl(String actionUrl) {
dbEntity.setActionUrl(actionUrl);
}
public ObjectiveSet getObjectiveSet() {
return ObjectiveSet.convertFromDbEntity(dbEntity.getObjectiveSet(), this.getMessageService(), null);
}
public void setObjectiveSet(ObjectiveSet objectiveSet) {
dbEntity.setObjectiveSet(objectiveSet.getDbEntity());
}
public void setActionWord(String actionWord) {
dbEntity.setActionWord(actionWord);
}
public void setAnalyticCode(String analyticCode) {
dbEntity.setAnalyticCode(analyticCode);
}
public void setBeneficiary(Integer beneficiary) {
dbEntity.setBeneficiary(beneficiary);
}
public void setCommessa(String commessa) {
dbEntity.setCommessa(commessa);
}
public void setCostCenter(String costCenter) {
dbEntity.setCostCenter(costCenter);
}
public void setDayLimit(Integer dayLimit) {
dbEntity.setDayLimit(dayLimit);
}
public void setFiscalYear(String fiscalYear) {
dbEntity.setFiscalYear(fiscalYear);
}
public void setInputDelay(Date inputDelay) {
dbEntity.setInputDelay(inputDelay);
}
public void setIsBlocked(Boolean isBlocked) {
dbEntity.setIsBlocked(isBlocked);
}
public void setIsDeleted(Boolean isDeleted) {
dbEntity.setIsDeleted(isDeleted);
}
public void setIsExceptStandard(Boolean isExceptStandard) {
dbEntity.setIsExceptStandard(isExceptStandard);
}
public void setIsMinimumObjective(Boolean isMinimumObjective) {
dbEntity.setIsMinimumObjective(isMinimumObjective);
}
public void setIsPaymentCancelled(Boolean isPaymentCancelled) {
dbEntity.setIsPaymentCancelled(isPaymentCancelled);
}
public void setIsStepsRollup(Boolean isStepsRollup) {
dbEntity.setIsStepsRollup(isStepsRollup);
}
public void setIsVisibleAmount(Boolean isVisibleAmount) {
dbEntity.setIsVisibleAmount(isVisibleAmount);
}
public void setLimitAmount(Double limitAmount) {
dbEntity.setLimitAmount(limitAmount);
}
public void setNatureCode(String natureCode) {
dbEntity.setNatureCode(natureCode);
}
public void setOperationalMode(Integer operationalMode) {
dbEntity.setOperationalMode(operationalMode);
}
public void setPriorityMode(Integer priorityMode) {
dbEntity.setPriorityMode(priorityMode);
}
public void setSettlement(Integer settlement) {
dbEntity.setSettlement(settlement);
}
public void setToDate(Date toDate) {
dbEntity.setToDate(toDate);
}
public ProductFamily getProductFamily() {
return ProductFamily.convertFromDbEntity(dbEntity.getProductFamily(), this.getMessageService());
}
public void setProductFamily(ProductFamily productFamily) {
dbEntity.setProductFamily(productFamily.getDbEntity());
}
public Currency getCurrency() {
return Currency.convertFromDbEntity(dbEntity.getCurrency());
}
public Element getElement() {
return Element.convertFromDbEntity(dbEntity.getElement(), this.getMessageService());
}
public void setCurrency(Currency currency) {
dbEntity.setCurrency(currency.getDbEntity());
}
public void setElement(Element element) {
dbEntity.setElement(element.getDbEntity());
}
public void setActionStateId(Integer actionStateId) {
dbEntity.setActionStateId(actionStateId);
}
public void setCurrencyId(String currencyId) {
dbEntity.setCurrencyId(currencyId);
}
public void setElementId(Integer elementId) {
dbEntity.setElementId(elementId);
}
public void setObjectiveSetId(String objectiveSetId) {
dbEntity.setObjectiveSetId(objectiveSetId);
}
public void setProductFamilyId(String productFamilyId) {
dbEntity.setProductFamilyId(productFamilyId);
}
} |
Partager