Search in sources :

Example 16 with PartnerDTO

use of org.activityinfo.legacy.shared.model.PartnerDTO in project activityinfo by bedatadriven.

the class LocalSiteCreateTest method siteRemovePartnerConflict.

@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void siteRemovePartnerConflict() {
    // FIRST U1 adds a new partner
    int databaseId = 1;
    PartnerDTO iom = new PartnerDTO();
    iom.setName("IOM");
    CreateResult result = executeRemotely(new UpdatePartner(databaseId, iom));
    iom.setId(result.getNewId());
    // Now U2 synchronizes, and adds a new site with this partner
    synchronize();
    SiteDTO site = new SiteDTO();
    site.setId(3343234);
    site.setActivityId(1);
    site.setPartner(iom);
    site.setDate1(new Date());
    site.setDate2(new Date());
    site.setLocationId(1);
    executeLocally(new CreateSite(site));
    // At T+3, U2 thinks better, removes IOM
    executeRemotely(new RemovePartner(databaseId, iom.getId()));
    // At T+4, U1 synchronizes, and IOM is removed, but site remains
    synchronize();
    // Verify that there is still a label for this partner
    SiteResult sites = executeLocally(GetSites.byId(site.getId()));
    assertThat(sites.getTotalLength(), equalTo(1));
    assertThat(sites.getData().get(0).getName(), equalTo(site.getName()));
}
Also used : PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) SiteResult(org.activityinfo.legacy.shared.command.result.SiteResult) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) Date(java.util.Date) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 17 with PartnerDTO

use of org.activityinfo.legacy.shared.model.PartnerDTO in project activityinfo by bedatadriven.

the class PartnerTest method testAddPartner.

@Test
public void testAddPartner() {
    PartnerDTO newPartner = new PartnerDTO();
    newPartner.setName("Solidarites");
    CreateResult cr = execute(new UpdatePartner(PEAR_PLUS_DB_ID, newPartner));
    assertThat(cr.getNewId(), not(equalTo(SOL_ID)));
    SchemaDTO schema = execute(new GetSchema());
    PartnerDTO partner = schema.getDatabaseById(PEAR_PLUS_DB_ID).getPartnerById(cr.getNewId());
    Assert.assertNotNull(partner);
    Assert.assertEquals(newPartner.getName(), partner.getName());
}
Also used : PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) DuplicateCreateResult(org.activityinfo.legacy.shared.command.result.DuplicateCreateResult) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) UpdatePartner(org.activityinfo.legacy.shared.command.UpdatePartner) Test(org.junit.Test)

Example 18 with PartnerDTO

use of org.activityinfo.legacy.shared.model.PartnerDTO in project activityinfo by bedatadriven.

the class PartnerDimBinding method extractFieldData.

@Override
public BaseModelData[] extractFieldData(BaseModelData[] dataArray, ColumnSet columnSet) {
    ColumnView id = columnSet.getColumnView(PARTNER_ID_COLUMN);
    ColumnView label = columnSet.getColumnView(PARTNER_LABEL_COLUMN);
    for (int i = 0; i < columnSet.getNumRows(); i++) {
        String partnerId = id.getString(i);
        String partnerLabel = label.getString(i);
        if (partnerId != null && !Strings.isNullOrEmpty(partnerLabel)) {
            PartnerDTO partner = new PartnerDTO(CuidAdapter.getLegacyIdFromCuid(partnerId), partnerLabel);
            dataArray[i].set(PARTNER_FIELD, partner);
        }
    }
    return dataArray;
}
Also used : PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) ColumnView(org.activityinfo.model.query.ColumnView)

Example 19 with PartnerDTO

use of org.activityinfo.legacy.shared.model.PartnerDTO in project activityinfo by bedatadriven.

the class UserDatabasePolicy method addDefaultPartner.

private void addDefaultPartner(int databaseId, User user) {
    PartnerDTO partner = new PartnerDTO();
    partner.setName(PartnerDTO.DEFAULT_PARTNER_NAME);
    UpdatePartner command = new UpdatePartner(databaseId, partner);
    new UpdatePartnerHandler(em).execute(command, user);
}
Also used : PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) UpdatePartnerHandler(org.activityinfo.server.command.handler.UpdatePartnerHandler) UpdatePartner(org.activityinfo.legacy.shared.command.UpdatePartner)

Example 20 with PartnerDTO

use of org.activityinfo.legacy.shared.model.PartnerDTO in project activityinfo by bedatadriven.

the class UpdateUserPermissionsHandlerTest method testAuthorizedCreate.

/**
 * Verifies that a user with the manageUsers permission can add another user to the UserDatabase
 */
@Test
@OnDataSet("/dbunit/schema1.db.xml")
public void testAuthorizedCreate() throws CommandException {
    setUser(2);
    UserPermissionDTO user = new UserPermissionDTO();
    user.setEmail("ralph@lauren.com");
    user.setName("Ralph");
    user.setPartner(new PartnerDTO(1, "NRC"));
    user.setAllowView(true);
    user.setAllowEdit(true);
    UpdateUserPermissions cmd = new UpdateUserPermissions(1, user);
    execute(cmd);
    UserResult result = execute(new GetUsers(1));
    assertThat(result.getTotalLength(), equalTo(1));
    UserPermissionDTO ralph = result.getData().get(0);
    assertThat(ralph.getEmail(), equalTo("ralph@lauren.com"));
    assertThat(ralph.getAllowEdit(), equalTo(true));
    assertThat(ralph.hasFolderLimitation(), equalTo(false));
}
Also used : PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) UpdateUserPermissions(org.activityinfo.legacy.shared.command.UpdateUserPermissions) UserResult(org.activityinfo.legacy.shared.command.result.UserResult) GetUsers(org.activityinfo.legacy.shared.command.GetUsers) UserPermissionDTO(org.activityinfo.legacy.shared.model.UserPermissionDTO) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Aggregations

PartnerDTO (org.activityinfo.legacy.shared.model.PartnerDTO)23 Test (org.junit.Test)6 UpdatePartner (org.activityinfo.legacy.shared.command.UpdatePartner)5 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)5 UserResult (org.activityinfo.legacy.shared.command.result.UserResult)4 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)4 UserPermissionDTO (org.activityinfo.legacy.shared.model.UserPermissionDTO)4 OnDataSet (org.activityinfo.server.database.OnDataSet)4 ArrayList (java.util.ArrayList)3 Filter (org.activityinfo.legacy.shared.command.Filter)3 GetPartnersDimension (org.activityinfo.legacy.shared.command.GetPartnersDimension)3 GetUsers (org.activityinfo.legacy.shared.command.GetUsers)3 UpdateUserPermissions (org.activityinfo.legacy.shared.command.UpdateUserPermissions)3 DuplicateCreateResult (org.activityinfo.legacy.shared.command.result.DuplicateCreateResult)3 PartnerResult (org.activityinfo.legacy.shared.command.result.PartnerResult)3 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)2 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)2 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)2 FormDialogCallback (org.activityinfo.ui.client.page.common.dialog.FormDialogCallback)2