use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class GroupControllerTest method testRetrieveGroupMembers.
@Test
public void testRetrieveGroupMembers() throws Exception {
Account a1 = AccountCreator.createTestAccount("testRetrieveGroupMembers1", false);
AccountCreator.createTestAccount("testRetrieveGroupMembers2", false);
AccountCreator.createTestAccount("testRetrieveGroupMembers3", false);
UserGroup user = new UserGroup();
user.setDescription("desc");
user.setLabel("label");
user.setType(GroupType.PRIVATE);
// create group
user = controller.createGroup(a1.getEmail(), user);
Assert.assertNotNull(user);
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class FolderAuthorization method canRead.
public boolean canRead(String userId, Folder folder) {
if (controller.isPublicVisible(folder))
return true;
Account account = getAccount(userId);
if (account == null)
return false;
if (folder.getType() == FolderType.PUBLIC)
return true;
if (super.canRead(userId, folder))
return true;
// now check actual permissions
Set<Folder> folders = new HashSet<>();
folders.add(folder);
if (controller.groupHasReadPermission(new ArrayList<>(account.getGroups()), folders) || controller.groupHasWritePermission(new ArrayList<>(account.getGroups()), folders))
return true;
return controller.accountHasReadPermission(account, folders) || controller.accountHasWritePermission(account, folders);
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class PartDefaults method get.
/**
* Retrieves and sets the default values for the entry. Some of these values (e.g. PI, and Funding Source)
* are set by individual users as part of their personal preferences
*
* @param type entry type
* @return PartData object with the retrieve part defaults
*/
public PartData get(EntryType type) {
PartData partData = new PartData(type);
PreferencesController preferencesController = new PreferencesController();
// pi defaults
String value = preferencesController.getPreferenceValue(userId, PreferenceKey.PRINCIPAL_INVESTIGATOR.name());
if (value != null) {
Account piAccount = this.accountDAO.getByEmail(value);
if (piAccount == null) {
partData.setPrincipalInvestigator(value);
} else {
partData.setPrincipalInvestigator(piAccount.getFullName());
partData.setPrincipalInvestigatorEmail(piAccount.getEmail());
partData.setPrincipalInvestigatorId(piAccount.getId());
}
}
// funding source defaults
value = preferencesController.getPreferenceValue(userId, PreferenceKey.FUNDING_SOURCE.name());
if (value != null) {
partData.setFundingSource(value);
}
// owner and creator details
Account account = this.accountDAO.getByEmail(userId);
if (account != null) {
partData.setOwner(account.getFullName());
partData.setOwnerEmail(account.getEmail());
partData.setCreator(partData.getOwner());
partData.setCreatorEmail(partData.getOwnerEmail());
}
// set the entry type defaults
return EntryUtil.setPartDefaults(partData);
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class EntryPermissionTask method addPermissions.
protected void addPermissions(Entry entry) {
for (AccessPermission access : permissions) {
// account or group
Account account = null;
Group group = null;
switch(access.getArticle()) {
case ACCOUNT:
default:
account = accountDAO.get(access.getArticleId());
break;
case GROUP:
group = groupDAO.get(access.getArticleId());
break;
}
// does the permissions already exists
if (permissionDAO.hasPermission(entry, null, null, account, group, access.isCanRead(), access.isCanWrite()))
return;
// add the permission if not
Permission permission = new Permission();
permission.setEntry(entry);
entry.getPermissions().add(permission);
permission.setGroup(group);
permission.setFolder(null);
permission.setUpload(null);
permission.setAccount(account);
permission.setCanRead(access.isCanRead());
permission.setCanWrite(access.isCanWrite());
permissionDAO.create(permission);
}
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class SBOLParser method createNewEntry.
protected long createNewEntry(TopLevel moduleDefinition, SBOLDocument document) {
String identity = moduleDefinition.getIdentity().toString();
String description = moduleDefinition.getDescription();
String name = moduleDefinition.getName();
Part part = new Part();
part.setOwner(partData.getOwner());
part.setOwnerEmail(partData.getOwnerEmail());
part.setCreator(partData.getCreator());
part.setCreatorEmail(partData.getCreatorEmail());
part.setPrincipalInvestigator(partData.getPrincipalInvestigator());
part.setPrincipalInvestigatorEmail(partData.getPrincipalInvestigatorEmail());
part.setBioSafetyLevel(partData.getBioSafetyLevel());
part.setStatus(partData.getStatus());
description = StringUtils.isEmpty(description) ? partData.getShortDescription() : description;
name = StringUtils.isEmpty(name) ? moduleDefinition.getDisplayId() : name;
part.setShortDescription(description);
part.setName(name);
EntryCreator entryCreator = new EntryCreator();
Account account = DAOFactory.getAccountDAO().getByEmail(part.getCreatorEmail());
Entry entry = entryCreator.createEntry(account, part, null);
parseToGenBank(document, entry.getName(), entry, moduleDefinition.getIdentity().toString());
identityEntryMap.put(identity, entry.getId());
return entry.getId();
}
Aggregations