Search in sources :

Example 6 with PartnerDTO

use of org.activityinfo.shared.dto.PartnerDTO in project activityinfo by bedatadriven.

the class PartnerTest method testAddPartner.

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

Example 7 with PartnerDTO

use of org.activityinfo.shared.dto.PartnerDTO in project activityinfo by bedatadriven.

the class SiteDTOs method newSite.

public static SiteDTO newSite() {
    SiteDTO newSite = new SiteDTO();
    newSite.setId(new KeyGenerator().generateInt());
    newSite.setActivityId(1);
    newSite.setLocationId(1);
    newSite.setPartner(new PartnerDTO(1, "Foobar"));
    newSite.setReportingPeriodId(new KeyGenerator().generateInt());
    newSite.setDate1((new GregorianCalendar(2008, 12, 1)).getTime());
    newSite.setDate2((new GregorianCalendar(2009, 1, 3)).getTime());
    newSite.setIndicatorValue(1, 996.0);
    newSite.setIndicatorValue(2, null);
    newSite.setAttributeValue(1, true);
    newSite.setAttributeValue(2, false);
    newSite.setComments("huba huba");
    newSite.setProject(new ProjectDTO(1, "WoeiProject"));
    return newSite;
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) GregorianCalendar(java.util.GregorianCalendar) SiteDTO(org.activityinfo.shared.dto.SiteDTO) KeyGenerator(org.activityinfo.client.local.command.handler.KeyGenerator)

Example 8 with PartnerDTO

use of org.activityinfo.shared.dto.PartnerDTO in project activityinfo by bedatadriven.

the class UpdateUserPermissionsHandlerTest method setup.

@Before
public void setup() throws TemplateModelException {
    NRC = new Partner();
    NRC.setId(1);
    NRC.setName("NRC");
    NRC.setFullName("Norwegian Refugee Council");
    db.persist(NRC);
    IRC = new Partner();
    IRC.setId(2);
    IRC.setName("IRC");
    IRC.setFullName("International Rescue Committee");
    db.persist(IRC);
    NRC_DTO = new PartnerDTO(1, "NRC");
    TemplateModule templateModule = new TemplateModule();
    mailer = new MailSenderStub(templateModule.provideConfiguration(Providers.of(Domain.DEFAULT)));
    handler = new UpdateUserPermissionsHandler(db.getDAO(UserDatabaseDAO.class), db.getDAO(PartnerDAO.class), db.getDAO(UserDAO.class), db.getDAO(UserPermissionDAO.class), mailer);
    owner = new User();
    owner.setId(99);
    owner.setName("Alex");
    owner.setEmail("alex@bedatadriven.com");
    db.persist(owner);
    UserDatabase udb = new UserDatabase(1, "PEAR");
    udb.setOwner(owner);
    db.persist(udb);
}
Also used : MailSenderStub(org.activityinfo.server.mail.MailSenderStub) User(org.activityinfo.server.database.hibernate.entity.User) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) TemplateModule(org.activityinfo.server.util.TemplateModule) UpdateUserPermissionsHandler(org.activityinfo.server.command.handler.UpdateUserPermissionsHandler) UserDatabase(org.activityinfo.server.database.hibernate.entity.UserDatabase) Partner(org.activityinfo.server.database.hibernate.entity.Partner) Before(org.junit.Before)

Example 9 with PartnerDTO

use of org.activityinfo.shared.dto.PartnerDTO in project activityinfo by bedatadriven.

the class UpdateUserPermissionsHandlerTest method testOwnerUpdate.

/**
 * Verifies that the owner of a database can update an existing users permission
 *
 * @throws CommandException
 */
@Test
@OnDataSet("/dbunit/schema1.db.xml")
public void testOwnerUpdate() throws CommandException {
    setUser(1);
    UserPermissionDTO user = new UserPermissionDTO();
    user.setEmail("bavon@nrcdrc.org");
    user.setPartner(new PartnerDTO(1, "NRC"));
    user.setAllowView(true);
    user.setAllowViewAll(false);
    user.setAllowEdit(true);
    user.setAllowEdit(false);
    user.setAllowDesign(true);
    execute(new UpdateUserPermissions(1, user));
    UserResult result = execute(new GetUsers(1));
    UserPermissionDTO reUser = result.getData().get(0);
    Assert.assertEquals("bavon@nrcdrc.org", reUser.getEmail());
    Assert.assertTrue("design rights", user.getAllowDesign());
}
Also used : PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) UpdateUserPermissions(org.activityinfo.shared.command.UpdateUserPermissions) UserResult(org.activityinfo.shared.command.result.UserResult) GetUsers(org.activityinfo.shared.command.GetUsers) UserPermissionDTO(org.activityinfo.shared.dto.UserPermissionDTO) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 10 with PartnerDTO

use of org.activityinfo.shared.dto.PartnerDTO in project activityinfo by bedatadriven.

the class PartnerFilterPanel method applyInternalValue.

private void applyInternalValue() {
    for (PartnerDTO model : listView.getStore().getModels()) {
        listView.setChecked(model, value.getRestrictions(DimensionType.Partner).contains(model.getId()));
    }
    filterToolBar.setApplyFilterEnabled(false);
    filterToolBar.setRemoveFilterEnabled(value.isRestricted(DimensionType.Partner));
}
Also used : PartnerDTO(org.activityinfo.shared.dto.PartnerDTO)

Aggregations

PartnerDTO (org.activityinfo.shared.dto.PartnerDTO)23 CreateResult (org.activityinfo.shared.command.result.CreateResult)8 Test (org.junit.Test)8 ProjectDTO (org.activityinfo.shared.dto.ProjectDTO)6 SiteDTO (org.activityinfo.shared.dto.SiteDTO)6 AddPartner (org.activityinfo.shared.command.AddPartner)5 CreateSite (org.activityinfo.shared.command.CreateSite)4 DuplicateCreateResult (org.activityinfo.shared.command.result.DuplicateCreateResult)4 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)3 GregorianCalendar (java.util.GregorianCalendar)3 FormDialogCallback (org.activityinfo.client.page.common.dialog.FormDialogCallback)3 FormDialogTether (org.activityinfo.client.page.common.dialog.FormDialogTether)3 OnDataSet (org.activityinfo.server.database.OnDataSet)3 GetPartnersDimension (org.activityinfo.shared.command.GetPartnersDimension)3 PartnerResult (org.activityinfo.shared.command.result.PartnerResult)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 KeyGenerator (org.activityinfo.client.local.command.handler.KeyGenerator)2