Search in sources :

Example 1 with AddressDescription

use of org.eclipse.persistence.testing.models.aggregate.AddressDescription in project eclipselink by eclipse-ee4j.

the class CheckForNullUnitOfWorkTest method changeUnitOfWorkWorkingCopy.

protected void changeUnitOfWorkWorkingCopy() {
    Employee employee = (Employee) this.unitOfWorkWorkingCopy;
    AddressDescription addressDescription = employee.getAddressDescription();
    ProjectDescription projectDescription = employee.getProjectDescription();
    Language language;
    Vector languages;
    // Root object changed
    employee.setFirstName(null);
    employee.setLastName(null);
    // Third level aggregate object changed
    addressDescription.setPeriodDescription(null);
    // 1 to 1 mapped object changed
    projectDescription.getComputer().setValue(null);
    // 1 level aggregate's 1:M mapping
    projectDescription.getResponsibilities().setValue(null);
    languages = (Vector) projectDescription.getLanguages().getValue();
    language = (Language) languages.firstElement();
    language.setLanguage(null);
// 1 level aggregate's M:M mapping, adding a new element
// languages.addElement(null);
}
Also used : Employee(org.eclipse.persistence.testing.models.aggregate.Employee) Language(org.eclipse.persistence.testing.models.aggregate.Language) AddressDescription(org.eclipse.persistence.testing.models.aggregate.AddressDescription) ProjectDescription(org.eclipse.persistence.testing.models.aggregate.ProjectDescription)

Example 2 with AddressDescription

use of org.eclipse.persistence.testing.models.aggregate.AddressDescription in project eclipselink by eclipse-ee4j.

the class UnitOfWorkTest method changeUnitOfWorkWorkingCopy.

protected void changeUnitOfWorkWorkingCopy() {
    Employee employee = (Employee) this.unitOfWorkWorkingCopy;
    AddressDescription addressDescription = employee.getAddressDescription();
    ProjectDescription projectDescription = employee.getProjectDescription();
    Responsibility responsibility = Responsibility.example6(employee);
    Vector responsibilities;
    Vector languages;
    Language language;
    // Root object changed
    employee.setFirstName("ChangedFirstName");
    employee.setLastName("ChangedLastName");
    // First lever aggregate object changed
    projectDescription.setDescription("ProjectDescription's Description changed");
    // Third level aggregate object changed
    addressDescription.getPeriodDescription().getPeriod().setEndDate(Helper.dateFromYearMonthDate(1995, 2, 1));
    // 1 to 1 mapped object changed
    projectDescription.getComputer().setValue(null);
    // 1 level aggregate's 1:M mapping, removing an element
    responsibility.setResponsibility("Changed Reponsibility");
    responsibilities = (Vector) projectDescription.getResponsibilities().getValue();
    responsibilities.removeElement(responsibilities.firstElement());
    // 1 level aggregate's 1:M mapping, adding a new element
    responsibilities.addElement(responsibility);
    // 1 level aggregate's M:M mapping, removing an element
    languages = (Vector) projectDescription.getLanguages().getValue();
    languages.removeElement(languages.firstElement());
    // 1 level aggregate's M:M mapping, modifying an element
    language = (Language) languages.firstElement();
    language.setLanguage("ModifiedLanguage");
    // 1 level aggregate's M:M mapping, adding a new element
    languages.addElement(Language.example7());
}
Also used : Employee(org.eclipse.persistence.testing.models.aggregate.Employee) Language(org.eclipse.persistence.testing.models.aggregate.Language) AddressDescription(org.eclipse.persistence.testing.models.aggregate.AddressDescription) Responsibility(org.eclipse.persistence.testing.models.aggregate.Responsibility) ProjectDescription(org.eclipse.persistence.testing.models.aggregate.ProjectDescription)

Example 3 with AddressDescription

use of org.eclipse.persistence.testing.models.aggregate.AddressDescription in project eclipselink by eclipse-ee4j.

the class UnitOfWorkCommitResumeTest method changeUnitOfWorkWorkingCopy.

/**
 * Change the working copy of the object. Add a suffix to the changes.
 *    Make sure the suffix is so long that it will be longer that the size of
 *    the field in the database.
 */
protected void changeUnitOfWorkWorkingCopy() {
    Employee employee = (Employee) this.unitOfWorkWorkingCopy;
    AddressDescription addressDescription = employee.getAddressDescription();
    ProjectDescription projectDescription = employee.getProjectDescription();
    Responsibility responsibility = Responsibility.example6(employee);
    Vector responsibilities;
    Vector languages;
    Language language;
    String suffix = (Integer.valueOf(changeVersion)).toString();
    // Root object changed
    employee.setFirstName("First " + suffix);
    employee.setLastName("Last " + suffix);
    // First level aggregate object changed
    projectDescription.setDescription("ProjectDescription's Description changed" + suffix);
    // Third level aggregate object changed
    addressDescription.getPeriodDescription().getPeriod().setEndDate(Helper.dateFromYearMonthDate(1900 + ((changeVersion + 1975) % 2500), (changeVersion % 12) + 1, (changeVersion % 28) + 1));
    addressDescription.getAddress().getValue().setAddress(suffix + " Any Street");
    // 1 to 1 mapped object changed
    projectDescription.getComputer().getValue().setDescription("Vic 20");
    // 1 level aggregate's 1:M mapping, removing an element
    responsibility.setResponsibility("Changed Reponsibility" + suffix);
    responsibilities = (Vector) projectDescription.getResponsibilities().getValue();
    responsibilities.removeElement(responsibilities.firstElement());
    // 1 level aggregate's 1:M mapping, adding a new element
    responsibilities.addElement(responsibility);
    // 1 level aggregate's M:M mapping, removing an element
    languages = (Vector) projectDescription.getLanguages().getValue();
    languages.removeElement(languages.firstElement());
    // 1 level aggregate's M:M mapping, modifying an element
    language = (Language) languages.firstElement();
    language.setLanguage("ModifiedLanguage" + suffix);
    // 1 level aggregate's M:M mapping, adding a new element
    languages.addElement(Language.example7());
    // Update the change version.
    changeVersion++;
}
Also used : Employee(org.eclipse.persistence.testing.models.aggregate.Employee) Language(org.eclipse.persistence.testing.models.aggregate.Language) AddressDescription(org.eclipse.persistence.testing.models.aggregate.AddressDescription) Responsibility(org.eclipse.persistence.testing.models.aggregate.Responsibility) ProjectDescription(org.eclipse.persistence.testing.models.aggregate.ProjectDescription)

Aggregations

AddressDescription (org.eclipse.persistence.testing.models.aggregate.AddressDescription)3 Employee (org.eclipse.persistence.testing.models.aggregate.Employee)3 Language (org.eclipse.persistence.testing.models.aggregate.Language)3 ProjectDescription (org.eclipse.persistence.testing.models.aggregate.ProjectDescription)3 Responsibility (org.eclipse.persistence.testing.models.aggregate.Responsibility)2