Search in sources :

Example 1 with AddProject

use of org.activityinfo.legacy.shared.command.AddProject in project activityinfo by bedatadriven.

the class AddProjectHandler method execute.

@Override
public CommandResult execute(AddProject cmd, User user) {
    Database db = em.find(Database.class, cmd.getDatabaseId());
    ProjectDTO from = cmd.getProjectDTO();
    Project project = new Project();
    project.setName(from.getName());
    project.setDescription(from.getDescription());
    project.setDatabase(db);
    db.setLastSchemaUpdate(new Date());
    em.persist(project);
    em.persist(db);
    db.getProjects().add(project);
    return new CreateResult(project.getId());
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) Project(org.activityinfo.server.database.hibernate.entity.Project) AddProject(org.activityinfo.legacy.shared.command.AddProject) CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) Database(org.activityinfo.server.database.hibernate.entity.Database) Date(java.util.Date)

Example 2 with AddProject

use of org.activityinfo.legacy.shared.command.AddProject in project activityinfo by bedatadriven.

the class DbProjectEditor method onAdd.

@Override
protected void onAdd() {
    final ProjectDTO newProject = new ProjectDTO();
    this.view.showAddDialog(newProject, new FormDialogCallback() {

        @Override
        public void onValidated(final FormDialogTether dlg) {
            service.execute(new AddProject(db.getId(), newProject), dlg, new AsyncCallback<CreateResult>() {

                @Override
                public void onFailure(Throwable caught) {
                    MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer(), null);
                }

                @Override
                public void onSuccess(CreateResult result) {
                    newProject.setId(result.getNewId());
                    store.add(newProject);
                    db.getProjects().add(newProject);
                    eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
                    dlg.hide();
                }
            });
        }
    });
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) FormDialogCallback(org.activityinfo.ui.client.page.common.dialog.FormDialogCallback) CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) AddProject(org.activityinfo.legacy.shared.command.AddProject) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.ui.client.page.common.dialog.FormDialogTether)

Aggregations

AddProject (org.activityinfo.legacy.shared.command.AddProject)2 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)2 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)2 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 Date (java.util.Date)1 Database (org.activityinfo.server.database.hibernate.entity.Database)1 Project (org.activityinfo.server.database.hibernate.entity.Project)1 FormDialogCallback (org.activityinfo.ui.client.page.common.dialog.FormDialogCallback)1 FormDialogTether (org.activityinfo.ui.client.page.common.dialog.FormDialogTether)1