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()));
}
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());
}
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;
}
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);
}
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));
}
Aggregations