Commit e2411c8f authored by Romain Bioteau's avatar Romain Bioteau Committed by Romain Bioteau

BS-14360 Handle active organization / repository

* Instead of storing a global pref for active organization use a projec
scope IEclipsePreference
* Store also other organization related preference (default
user/password...etc)
parent 96b025cf
......@@ -12,7 +12,6 @@ Export-Package: org.bonitasoft.studio.actors,
org.bonitasoft.studio.actors.model.organization,
org.bonitasoft.studio.actors.model.organization.impl,
org.bonitasoft.studio.actors.model.organization.util,
org.bonitasoft.studio.actors.preference,
org.bonitasoft.studio.actors.repository,
org.bonitasoft.studio.actors.ui.wizard.page,
org.bonitasoft.studio.actors.validator
......
......@@ -5,14 +5,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.actors.action;
......@@ -25,34 +23,38 @@ import org.bonitasoft.studio.actors.repository.OrganizationRepositoryStore;
import org.bonitasoft.studio.common.extension.IEngineAction;
import org.bonitasoft.studio.common.repository.Repository;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.common.repository.core.ActiveOrganizationProvider;
import org.bonitasoft.studio.preferences.BonitaPreferenceConstants;
import org.bonitasoft.studio.preferences.BonitaStudioPreferencesPlugin;
/**
* @author Romain Bioteau
*
*/
public class PublishActiveOrganizationAction implements IEngineAction {
private final ActiveOrganizationProvider activeOrganizationProvider;
public PublishActiveOrganizationAction() {
activeOrganizationProvider = new ActiveOrganizationProvider();
}
/* (non-Javadoc)
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.extension.IEngineAction#run(org.bonitasoft.engine.session.APISession)
*/
@Override
public void run(APISession session) throws Exception {
if(BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore().getBoolean(BonitaPreferenceConstants.LOAD_ORGANIZATION)) {
String artifactId = BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore().getString(BonitaPreferenceConstants.DEFAULT_ORGANIZATION) +"."+OrganizationRepositoryStore.ORGANIZATION_EXT ;
OrganizationRepositoryStore store = RepositoryManager.getInstance().getRepositoryStore(OrganizationRepositoryStore.class);
OrganizationFileStore organizationFileStore = store.getChild(artifactId);
if(organizationFileStore == null){
throw new FileNotFoundException(artifactId);
public void run(final APISession session) throws Exception {
if (BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore().getBoolean(BonitaPreferenceConstants.LOAD_ORGANIZATION)) {
final String artifactId = activeOrganizationProvider.getActiveOrganization();
final OrganizationRepositoryStore store = RepositoryManager.getInstance().getRepositoryStore(OrganizationRepositoryStore.class);
final OrganizationFileStore organizationFileStore = store.getChild(artifactId + "." + OrganizationRepositoryStore.ORGANIZATION_EXT);
if (organizationFileStore == null) {
throw new FileNotFoundException(artifactId + "." + OrganizationRepositoryStore.ORGANIZATION_EXT);
}
PublishOrganizationOperation op = new PublishOrganizationOperation(organizationFileStore.getContent());
final PublishOrganizationOperation op = new PublishOrganizationOperation(organizationFileStore.getContent());
op.setSession(session);
op.run(Repository.NULL_PROGRESS_MONITOR);
}
}
}
}
......@@ -5,14 +5,12 @@
* it under the terMrs of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.actors.repository;
......@@ -34,200 +32,206 @@ import org.bonitasoft.studio.actors.model.organization.Role;
import org.bonitasoft.studio.actors.model.organization.Roles;
import org.bonitasoft.studio.actors.model.organization.User;
import org.bonitasoft.studio.actors.model.organization.Users;
import org.bonitasoft.studio.actors.preference.ActorsPreferenceConstants;
import org.bonitasoft.studio.common.repository.model.IFileStoreContribution;
import org.bonitasoft.studio.common.repository.model.IRepositoryFileStore;
import org.bonitasoft.studio.common.repository.model.IRepositoryStore;
import org.bonitasoft.studio.common.repository.preferences.OrganizationPreferenceConstants;
import org.eclipse.emf.common.util.EList;
/**
* @author Romain Bioteau
*
*/
public class DefaultOrganizationContribution implements IFileStoreContribution {
/* (non-Javadoc)
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.repository.model.IFileStoreContribution#appliesTo(org.bonitasoft.studio.common.repository.model.IRepositoryStore)
*/
@Override
public boolean appliesTo(IRepositoryStore<? extends IRepositoryFileStore> repository) {
public boolean appliesTo(final IRepositoryStore<? extends IRepositoryFileStore> repository) {
return repository instanceof OrganizationRepositoryStore;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.repository.model.IFileStoreContribution#execute(org.bonitasoft.studio.common.repository.model.IRepositoryStore)
*/
@Override
public void execute(IRepositoryStore<? extends IRepositoryFileStore> repository) {
Organization organization = OrganizationFactory.eINSTANCE.createOrganization() ;
organization.setName(ActorsPreferenceConstants.DEFAULT_ORGANIZATION_NAME) ;
organization.setDescription(Messages.defaultOrganizationDescription) ;
Groups groups = createGroups();
Users users = createUsers();
Roles roles = createRoles();
Memberships memberships = createMemberships();
organization.setGroups(groups) ;
organization.setUsers(users) ;
organization.setRoles(roles) ;
organization.setMemberships(memberships) ;
IRepositoryFileStore file = repository.createRepositoryFileStore(ActorsPreferenceConstants.DEFAULT_ORGANIZATION_NAME+"."+OrganizationRepositoryStore.ORGANIZATION_EXT) ;
file.save(organization) ;
public void execute(final IRepositoryStore<? extends IRepositoryFileStore> repository) {
final Organization organization = OrganizationFactory.eINSTANCE.createOrganization();
organization.setName(OrganizationPreferenceConstants.DEFAULT_ORGANIZATION_NAME);
organization.setDescription(Messages.defaultOrganizationDescription);
final Groups groups = createGroups();
final Users users = createUsers();
final Roles roles = createRoles();
final Memberships memberships = createMemberships();
organization.setGroups(groups);
organization.setUsers(users);
organization.setRoles(roles);
organization.setMemberships(memberships);
final IRepositoryFileStore file = repository
.createRepositoryFileStore(OrganizationPreferenceConstants.DEFAULT_ORGANIZATION_NAME + "." + OrganizationRepositoryStore.ORGANIZATION_EXT);
file.save(organization);
}
protected Memberships createMemberships() {
Memberships memberships = OrganizationFactory.eINSTANCE.createMemberships() ;
final Memberships memberships = OrganizationFactory.eINSTANCE.createMemberships();
final EList<Membership> membershipList = memberships.getMembership();
membershipList.add(createMembership("william.jobs",null,"acme","member")) ;
membershipList.add(createMembership("april.sanchez","/acme","hr","member")) ;
membershipList.add(createMembership("helen.kelly","/acme","hr","member")) ;
membershipList.add(createMembership("walter.bates","/acme","hr","member")) ;
membershipList.add(createMembership("william.jobs", null, "acme", "member"));
membershipList.add(createMembership("april.sanchez", "/acme", "hr", "member"));
membershipList.add(createMembership("helen.kelly", "/acme", "hr", "member"));
membershipList.add(createMembership("walter.bates", "/acme", "hr", "member"));
membershipList.add(createMembership("zachary.williamson","/acme","finance","member")) ;
membershipList.add(createMembership("patrick.gardenier","/acme","finance","member")) ;
membershipList.add(createMembership("virginie.jomphe","/acme","finance","member")) ;
membershipList.add(createMembership("thorsten.hartmann","/acme","finance","member")) ;
membershipList.add(createMembership("zachary.williamson", "/acme", "finance", "member"));
membershipList.add(createMembership("patrick.gardenier", "/acme", "finance", "member"));
membershipList.add(createMembership("virginie.jomphe", "/acme", "finance", "member"));
membershipList.add(createMembership("thorsten.hartmann", "/acme", "finance", "member"));
membershipList.add(createMembership("jan.fisher","/acme","it","member")) ;
membershipList.add(createMembership("jan.fisher", "/acme", "it", "member"));
membershipList.add(createMembership("isabel.bleasdale","/acme","marketing","member")) ;
membershipList.add(createMembership("favio.riviera","/acme","marketing","member")) ;
membershipList.add(createMembership("isabel.bleasdale", "/acme", "marketing", "member"));
membershipList.add(createMembership("favio.riviera", "/acme", "marketing", "member"));
membershipList.add(createMembership("michael.morrison","/acme","production","member")) ;
membershipList.add(createMembership("marc.marseau","/acme/production","rd","member")) ;
membershipList.add(createMembership("joseph.hovell","/acme/production","rd","member")) ;
membershipList.add(createMembership("michael.morrison", "/acme", "production", "member"));
membershipList.add(createMembership("marc.marseau", "/acme/production", "rd", "member"));
membershipList.add(createMembership("joseph.hovell", "/acme/production", "rd", "member"));
membershipList.add(createMembership("mauro.zetticci","/acme/production","services","member")) ;
membershipList.add(createMembership("thomas.wallis","/acme/production","services","member")) ;
membershipList.add(createMembership("mauro.zetticci", "/acme/production", "services", "member"));
membershipList.add(createMembership("thomas.wallis", "/acme/production", "services", "member"));
membershipList.add(createMembership("daniela.angelo","/acme/sales","europe","member")) ;
membershipList.add(createMembership("misa.kumagai","/acme/sales","asia","member")) ;
membershipList.add(createMembership("norio.yamazaki","/acme/sales","asia","member")) ;
membershipList.add(createMembership("giovanna.almeida","/acme/sales","latin_america","member")) ;
membershipList.add(createMembership("anthony.nichols","/acme/sales","north_america","member")) ;
membershipList.add(createMembership("daniela.angelo", "/acme/sales", "europe", "member"));
membershipList.add(createMembership("misa.kumagai", "/acme/sales", "asia", "member"));
membershipList.add(createMembership("norio.yamazaki", "/acme/sales", "asia", "member"));
membershipList.add(createMembership("giovanna.almeida", "/acme/sales", "latin_america", "member"));
membershipList.add(createMembership("anthony.nichols", "/acme/sales", "north_america", "member"));
return memberships;
}
protected Roles createRoles() {
Roles roles = OrganizationFactory.eINSTANCE.createRoles() ;
roles.getRole().add(createRole("member","Member","")) ;
final Roles roles = OrganizationFactory.eINSTANCE.createRoles();
roles.getRole().add(createRole("member", "Member", ""));
return roles;
}
protected Users createUsers() {
Users users = OrganizationFactory.eINSTANCE.createUsers() ;
final Users users = OrganizationFactory.eINSTANCE.createUsers();
final EList<User> userList = users.getUser();
final String mr = "Mr";
final String mrs = "Mrs";
userList.add(createUser(mr,"william.jobs","William","Jobs","bpm","WilliamJobs@acme.com",null,"Chief Executive Officer")) ;
userList.add(createUser(mrs,"april.sanchez","April","Sanchez","bpm","AprilGSanchez@acme.com","helen.kelly","Compensation specialist")) ;
userList.add(createUser(mrs,"helen.kelly","Helen","Kelly","bpm","HelenKelly@acme.com","william.jobs","Human resource manager")) ;
userList.add(createUser(mr,"walter.bates","Walter","Bates","bpm","WalterRBates@acme.com","helen.kelly","Human resources benefits")) ;
userList.add(createUser(mr,"zachary.williamson","Zachary","Williamson","bpm","ZacharyWilliamson@acme.com","william.jobs","Chief Financial Officer")) ;
userList.add(createUser(mr,"patrick.gardenier","Patrick","Gardenier","bpm","PatrickGardenier@acme.com","zachary.williamson","Financial controller")) ;
userList.add(createUser(mrs,"virginie.jomphe","Virgine","Jomphe","bpm","VirginieJomphe@acme.com","zachary.williamson","Accountant")) ;
userList.add(createUser(mr,"thorsten.hartmann","Thorsten","Hartmann","bpm","ThorstenHartmann@acme.com","zachary.williamson","Financial planning manager")) ;
userList.add(createUser(mr,"jan.fisher","Jan","Fisher","bpm","JanFisher@acme.com","favio.riviera","Infrastucture specialist")) ;
userList.add(createUser(mrs,"isabel.bleasdale","Isabel","Bleasdale","bpm","IsabelBleasdale@acme.com","favio.riviera","Product marketing manager")) ;
userList.add(createUser(mr,"favio.riviera","Favio","Riviera","bpm","FavioRiviera@acme.com","william.jobs","Vice President of Marketing")) ;
userList.add(createUser(mr,"michael.morrison","Michael","Morrison","bpm","MichaelMorrison@acme.com","william.jobs","Chief Technical Officer")) ;
userList.add(createUser(mr,"marc.marseau","Marc","Marseau","bpm","MarcMarseau@acme.com","michael.morrison","Engineer")) ;
userList.add(createUser(mr,"joseph.hovell","Joseph","Hovell","bpm","JosephHovell@acme.com","michael.morrison","Engineer")) ;
userList.add(createUser(mr,"mauro.zetticci","Mauro","Zetticci","bpm","MauroZetticci@acme.com","michael.morrison","Consultant")) ;
userList.add(createUser(mr,"thomas.wallis","Thomas","Wallis","bpm","ThomasWallis@acme.com","michael.morrison","Consultant")) ;
userList.add(createUser(mrs,"daniela.angelo","Daniela","Angelo","bpm","DanielaAngelo@acme.com","william.jobs","Vice President of Sales")) ;
userList.add(createUser(mr,"anthony.nichols","Anthony","Nichols","bpm","AnthonyNicholls@acme.com","daniela.angelo","Account manager")) ;
userList.add(createUser(mrs,"misa.kumagai","Misa","Kumagai","bpm","MisaKumagai@acme.com","daniela.angelo","Account manager")) ;
userList.add(createUser(mr,"norio.yamazaki","Norio","Yamazaki","bpm","NorioYamazaki@acme.com","daniela.angelo","Account manager")) ;
userList.add(createUser(mrs,"giovanna.almeida","Giovanna","Almeida","bpm","GiovannaRochaAlmeida@acme.com","daniela.angelo","Account manager")) ;
userList.add(createUser(mr, "william.jobs", "William", "Jobs", "bpm", "WilliamJobs@acme.com", null, "Chief Executive Officer"));
userList.add(createUser(mrs, "april.sanchez", "April", "Sanchez", "bpm", "AprilGSanchez@acme.com", "helen.kelly", "Compensation specialist"));
userList.add(createUser(mrs, "helen.kelly", "Helen", "Kelly", "bpm", "HelenKelly@acme.com", "william.jobs", "Human resource manager"));
userList.add(createUser(mr, "walter.bates", "Walter", "Bates", "bpm", "WalterRBates@acme.com", "helen.kelly", "Human resources benefits"));
userList.add(
createUser(mr, "zachary.williamson", "Zachary", "Williamson", "bpm", "ZacharyWilliamson@acme.com", "william.jobs", "Chief Financial Officer"));
userList.add(
createUser(mr, "patrick.gardenier", "Patrick", "Gardenier", "bpm", "PatrickGardenier@acme.com", "zachary.williamson", "Financial controller"));
userList.add(createUser(mrs, "virginie.jomphe", "Virgine", "Jomphe", "bpm", "VirginieJomphe@acme.com", "zachary.williamson", "Accountant"));
userList.add(createUser(mr, "thorsten.hartmann", "Thorsten", "Hartmann", "bpm", "ThorstenHartmann@acme.com", "zachary.williamson",
"Financial planning manager"));
userList.add(createUser(mr, "jan.fisher", "Jan", "Fisher", "bpm", "JanFisher@acme.com", "favio.riviera", "Infrastucture specialist"));
userList.add(
createUser(mrs, "isabel.bleasdale", "Isabel", "Bleasdale", "bpm", "IsabelBleasdale@acme.com", "favio.riviera", "Product marketing manager"));
userList.add(createUser(mr, "favio.riviera", "Favio", "Riviera", "bpm", "FavioRiviera@acme.com", "william.jobs", "Vice President of Marketing"));
userList.add(createUser(mr, "michael.morrison", "Michael", "Morrison", "bpm", "MichaelMorrison@acme.com", "william.jobs", "Chief Technical Officer"));
userList.add(createUser(mr, "marc.marseau", "Marc", "Marseau", "bpm", "MarcMarseau@acme.com", "michael.morrison", "Engineer"));
userList.add(createUser(mr, "joseph.hovell", "Joseph", "Hovell", "bpm", "JosephHovell@acme.com", "michael.morrison", "Engineer"));
userList.add(createUser(mr, "mauro.zetticci", "Mauro", "Zetticci", "bpm", "MauroZetticci@acme.com", "michael.morrison", "Consultant"));
userList.add(createUser(mr, "thomas.wallis", "Thomas", "Wallis", "bpm", "ThomasWallis@acme.com", "michael.morrison", "Consultant"));
userList.add(createUser(mrs, "daniela.angelo", "Daniela", "Angelo", "bpm", "DanielaAngelo@acme.com", "william.jobs", "Vice President of Sales"));
userList.add(createUser(mr, "anthony.nichols", "Anthony", "Nichols", "bpm", "AnthonyNicholls@acme.com", "daniela.angelo", "Account manager"));
userList.add(createUser(mrs, "misa.kumagai", "Misa", "Kumagai", "bpm", "MisaKumagai@acme.com", "daniela.angelo", "Account manager"));
userList.add(createUser(mr, "norio.yamazaki", "Norio", "Yamazaki", "bpm", "NorioYamazaki@acme.com", "daniela.angelo", "Account manager"));
userList.add(createUser(mrs, "giovanna.almeida", "Giovanna", "Almeida", "bpm", "GiovannaRochaAlmeida@acme.com", "daniela.angelo", "Account manager"));
return users;
}
protected Groups createGroups() {
Groups groups = OrganizationFactory.eINSTANCE.createGroups() ;
final Groups groups = OrganizationFactory.eINSTANCE.createGroups();
final EList<Group> groupList = groups.getGroup();
groupList.add(createGroup(null,"acme","Acme")) ;
groupList.add(createGroup("/acme","hr","Human Resources")) ;
groupList.add(createGroup("/acme","finance","Finance")) ;
groupList.add(createGroup("/acme","it","Infrastructure")) ;
groupList.add(createGroup("/acme","marketing","Marketing"));
groupList.add(createGroup("/acme","production","Production")) ;
groupList.add(createGroup("/acme","sales","Sales")) ;
groupList.add(createGroup("/acme/sales","europe","Europe")) ;
groupList.add(createGroup("/acme/sales","asia","Asia")) ;
groupList.add(createGroup("/acme/sales","latin_america","Latin America")) ;
groupList.add(createGroup("/acme/sales","north_america","North America")) ;
groupList.add(createGroup("/acme/production","rd","Research & Development")) ;
groupList.add(createGroup("/acme/production","services","Services")) ;
groupList.add(createGroup(null, "acme", "Acme"));
groupList.add(createGroup("/acme", "hr", "Human Resources"));
groupList.add(createGroup("/acme", "finance", "Finance"));
groupList.add(createGroup("/acme", "it", "Infrastructure"));
groupList.add(createGroup("/acme", "marketing", "Marketing"));
groupList.add(createGroup("/acme", "production", "Production"));
groupList.add(createGroup("/acme", "sales", "Sales"));
groupList.add(createGroup("/acme/sales", "europe", "Europe"));
groupList.add(createGroup("/acme/sales", "asia", "Asia"));
groupList.add(createGroup("/acme/sales", "latin_america", "Latin America"));
groupList.add(createGroup("/acme/sales", "north_america", "North America"));
groupList.add(createGroup("/acme/production", "rd", "Research & Development"));
groupList.add(createGroup("/acme/production", "services", "Services"));
return groups;
}
private Role createRole(String name, String displayName,String description) {
Role r = OrganizationFactory.eINSTANCE.createRole() ;
private Role createRole(final String name, final String displayName, final String description) {
final Role r = OrganizationFactory.eINSTANCE.createRole();
r.setName(name);
r.setDisplayName(displayName) ;
r.setDescription(description) ;
r.setDisplayName(displayName);
r.setDescription(description);
return r;
}
private Membership createMembership(String username,String parentGroupPath,String groupName, String roleName) {
Membership membership = OrganizationFactory.eINSTANCE.createMembership() ;
membership.setGroupParentPath(parentGroupPath) ;
membership.setGroupName(groupName) ;
membership.setUserName(username) ;
membership.setRoleName(roleName) ;
private Membership createMembership(final String username, final String parentGroupPath, final String groupName, final String roleName) {
final Membership membership = OrganizationFactory.eINSTANCE.createMembership();
membership.setGroupParentPath(parentGroupPath);
membership.setGroupName(groupName);
membership.setUserName(username);
membership.setRoleName(roleName);
return membership;
}
private Group createGroup(String parentPath, String name, String displayName) {
Group group = OrganizationFactory.eINSTANCE.createGroup() ;
group.setName(name) ;
group.setParentPath(parentPath) ;
group.setDescription("This group represents the "+displayName.toLowerCase()+ " department of the ACME organization");
group.setDisplayName(displayName) ;
private Group createGroup(final String parentPath, final String name, final String displayName) {
final Group group = OrganizationFactory.eINSTANCE.createGroup();
group.setName(name);
group.setParentPath(parentPath);
group.setDescription("This group represents the " + displayName.toLowerCase() + " department of the ACME organization");
group.setDisplayName(displayName);
return group;
}
private User createUser(String title,String username, String firstname, String lastname, String password,String email,String manager,String jobTitle) {
User user = OrganizationFactory.eINSTANCE.createUser() ;
private User createUser(final String title, final String username, final String firstname, final String lastname, final String password, final String email,
final String manager, final String jobTitle) {
final User user = OrganizationFactory.eINSTANCE.createUser();
user.setTitle(title);
user.setFirstName(firstname) ;
user.setLastName(lastname) ;
user.setUserName(username) ;
user.setPassword(createPassword(password)) ;
user.setFirstName(firstname);
user.setLastName(lastname);
user.setUserName(username);
user.setPassword(createPassword(password));
user.setManager(manager);
user.setJobTitle(jobTitle);
user.setEnabled(true);
ContactData data = OrganizationFactory.eINSTANCE.createContactData();
data.setEmail(username+"@acme.com");
final ContactData data = OrganizationFactory.eINSTANCE.createContactData();
data.setEmail(username + "@acme.com");
data.setAddress("Renwick Drive");
data.setBuilding("70");
data.setCity("Philadelphia");
Random r = new Random(System.currentTimeMillis());
NumberFormat format = NumberFormat.getIntegerInstance();
final Random r = new Random(System.currentTimeMillis());
final NumberFormat format = NumberFormat.getIntegerInstance();
format.setMaximumIntegerDigits(3);
format.setMinimumIntegerDigits(3);
String lastDigits = format.format(Math.abs(r.nextLong()));
data.setPhoneNumber("484-302-5"+lastDigits);
data.setFaxNumber("484-302-0"+lastDigits);
final String lastDigits = format.format(Math.abs(r.nextLong()));
data.setPhoneNumber("484-302-5" + lastDigits);
data.setFaxNumber("484-302-0" + lastDigits);
data.setZipCode("19108");
data.setCountry("United States");
data.setState("PA");
user.setProfessionalData(data);
MetaDatasType metadataType = OrganizationFactory.eINSTANCE.createMetaDatasType();
final MetaDatasType metadataType = OrganizationFactory.eINSTANCE.createMetaDatasType();
Metadata metadata = OrganizationFactory.eINSTANCE.createMetadata();
metadata.setName("Skype ID");
metadataType.getMetaData().add(metadata);
......@@ -242,11 +246,11 @@ public class DefaultOrganizationContribution implements IFileStoreContribution {
return user;
}
private PasswordType createPassword(String password) {
PasswordType passwordType = OrganizationFactory.eINSTANCE.createPasswordType();
passwordType.setValue(password);
passwordType.setEncrypted(false);
return passwordType;
}
private PasswordType createPassword(final String password) {
final PasswordType passwordType = OrganizationFactory.eINSTANCE.createPasswordType();
passwordType.setValue(password);
passwordType.setEncrypted(false);
return passwordType;
}
}
......@@ -20,10 +20,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bonitasoft.studio.actors.ActorsPlugin;
import org.bonitasoft.studio.actors.i18n.Messages;
import org.bonitasoft.studio.actors.model.organization.Organization;
import org.bonitasoft.studio.actors.model.organization.User;
import org.bonitasoft.studio.actors.preference.ActorsPreferenceConstants;
import org.bonitasoft.studio.actors.repository.OrganizationRepositoryStore;
import org.bonitasoft.studio.actors.ui.wizard.page.AbstractOrganizationWizardPage;
import org.bonitasoft.studio.actors.ui.wizard.page.GroupsWizardPage;
......@@ -33,16 +33,18 @@ import org.bonitasoft.studio.actors.ui.wizard.page.UsersWizardPage;
import org.bonitasoft.studio.actors.validator.OrganizationValidator;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.common.repository.core.ActiveOrganizationProvider;
import org.bonitasoft.studio.common.repository.model.IRepositoryFileStore;
import org.bonitasoft.studio.common.repository.model.ReadFileStoreException;
import org.bonitasoft.studio.common.repository.preferences.OrganizationPreferenceConstants;
import org.bonitasoft.studio.pics.Pics;
import org.bonitasoft.studio.preferences.BonitaPreferenceConstants;
import org.bonitasoft.studio.preferences.BonitaStudioPreferencesPlugin;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.Parameterization;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.util.EContentAdapter;
import org.eclipse.emf.ecore.util.EcoreUtil;
......@@ -50,7 +52,6 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.swt.widgets.Display;
......@@ -70,8 +71,10 @@ public class ManageOrganizationWizard extends Wizard {
private Organization activeOrganization;
private boolean activeOrganizationHasBeenModified = false;
String userName;
private final ActiveOrganizationProvider activeOrganizationProvider;
public ManageOrganizationWizard() {
activeOrganizationProvider = new ActiveOrganizationProvider();
organizations = new ArrayList<Organization>();
organizationsWorkingCopy = new ArrayList<Organization>();
setWindowTitle(Messages.manageOrganizationTitle);
......@@ -83,8 +86,10 @@ public class ManageOrganizationWizard extends Wizard {
BonitaStudioLog.error("Failed read organization content", e);
}
}
final String activeOrganizationName = BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore()
.getString(BonitaPreferenceConstants.DEFAULT_ORGANIZATION);
final IScopeContext projectScope = RepositoryManager.getInstance().getCurrentRepository().getScopeContext();
final IEclipsePreferences node = projectScope.getNode(ActorsPlugin.PLUGIN_ID);
final String activeOrganizationName = node.get(OrganizationPreferenceConstants.DEFAULT_ORGANIZATION,
OrganizationPreferenceConstants.DEFAULT_ORGANIZATION_NAME);
for (final Organization orga : organizations) {
final Organization copy = EcoreUtil.copy(orga);
if (activeOrganizationName.equals(orga.getName())) {
......@@ -190,12 +195,11 @@ public class ManageOrganizationWizard extends Wizard {
BonitaStudioLog.error(e);
return false;
}
final IPreferenceStore preferenceStore = BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore();
final String pref = preferenceStore.getString(ActorsPreferenceConstants.TOGGLE_STATE_FOR_PUBLISH_ORGANIZATION);
final boolean publishOrganization = preferenceStore.getBoolean(ActorsPreferenceConstants.PUBLISH_ORGANIZATION);
final String pref = activeOrganizationProvider.getPublishOrganizationState();
final boolean publishOrganization = activeOrganizationProvider.shouldPublishOrganization();
if (publishOrganization && MessageDialogWithToggle.ALWAYS.equals(pref)) {