Search in sources :

Example 1 with RebuildBlastIndexTask

use of org.jbei.ice.lib.search.blast.RebuildBlastIndexTask in project ice by JBEI.

the class PartSequence method scheduleBlastIndexRebuildTask.

private void scheduleBlastIndexRebuildTask(Action action, String partId) {
    RebuildBlastIndexTask task = new RebuildBlastIndexTask(action, partId);
    IceExecutorService.getInstance().runTask(task);
}
Also used : RebuildBlastIndexTask(org.jbei.ice.lib.search.blast.RebuildBlastIndexTask)

Example 2 with RebuildBlastIndexTask

use of org.jbei.ice.lib.search.blast.RebuildBlastIndexTask in project ice by JBEI.

the class Entries method createEntry.

/**
 * Create an entry in the database.
 * <p/>
 * Generates a new Part Number, the record id (UUID), version id, and timestamps.
 * Optionally set the record globally visible or schedule an index rebuild.
 *
 * @param account           account of user creating entry
 * @param entry             entry record being created
 * @param accessPermissions list of permissions to associate with created entry
 * @return entry that was saved in the database.
 */
private Entry createEntry(Account account, Entry entry, ArrayList<AccessPermission> accessPermissions) {
    if (entry.getRecordId() == null) {
        entry.setRecordId(Utils.generateUUID());
        entry.setVersionId(entry.getRecordId());
    }
    entry.setCreationTime(Calendar.getInstance().getTime());
    entry.setModificationTime(entry.getCreationTime());
    if (StringUtils.isEmpty(entry.getOwner()))
        entry.setOwner(account.getFullName());
    if (StringUtils.isEmpty(entry.getOwnerEmail()))
        entry.setOwnerEmail(account.getEmail());
    if (entry.getSelectionMarkers() != null) {
        for (SelectionMarker selectionMarker : entry.getSelectionMarkers()) {
            selectionMarker.setEntry(entry);
        }
    }
    if (entry.getLinks() != null) {
        for (Link link : entry.getLinks()) {
            link.setEntry(entry);
        }
    }
    if (entry.getStatus() == null)
        entry.setStatus("");
    if (entry.getBioSafetyLevel() == null)
        entry.setBioSafetyLevel(0);
    entry = dao.create(entry);
    EntryPermissions permissions = new EntryPermissions(entry.getRecordId(), userId);
    // check for pi
    String piEmail = entry.getPrincipalInvestigatorEmail();
    if (StringUtils.isNotEmpty(piEmail)) {
        permissions.addAccount(piEmail, true);
    }
    // add write permissions for owner
    permissions.addAccount(account.getEmail(), true);
    // add read permission for all public groups
    ArrayList<Group> groups = new GroupController().getAllPublicGroupsForAccount(account);
    for (Group group : groups) {
        permissions.addGroup(group.getId(), false);
    }
    if (accessPermissions != null) {
        for (AccessPermission accessPermission : accessPermissions) {
            permissions.addAccount(accessPermission);
        }
    }
    // rebuild blast database
    if (sequenceDAO.hasSequence(entry.getId())) {
        RebuildBlastIndexTask task = new RebuildBlastIndexTask(Action.CREATE, entry.getPartNumber());
        IceExecutorService.getInstance().runTask(task);
    }
    return entry;
}
Also used : GroupController(org.jbei.ice.lib.group.GroupController) AccessPermission(org.jbei.ice.lib.dto.access.AccessPermission) RebuildBlastIndexTask(org.jbei.ice.lib.search.blast.RebuildBlastIndexTask)

Example 3 with RebuildBlastIndexTask

use of org.jbei.ice.lib.search.blast.RebuildBlastIndexTask in project ice by JBEI.

the class ApplicationInitialize method startUp.

/**
 * Responsible for initializing the system and checking for the existence of needed
 * data (such as settings) and creating as needed
 */
public static void startUp() {
    IceExecutorService.getInstance().startService();
    // check for and create public group
    GroupController groupController = new GroupController();
    groupController.createOrRetrievePublicGroup();
    // check for and create admin account
    AccountController accountController = new AccountController();
    accountController.createAdminAccount();
    // check for and create default settings
    ConfigurationSettings settings = new ConfigurationSettings();
    settings.initPropertyValues();
    try {
        // check blast database exists and build if it doesn't
        RebuildBlastIndexTask task = new RebuildBlastIndexTask();
        IceExecutorService.getInstance().runTask(task);
        AutoAnnotationBlastDbBuildTask autoAnnotationBlastDbBuildTask = new AutoAnnotationBlastDbBuildTask();
        IceExecutorService.getInstance().runTask(autoAnnotationBlastDbBuildTask);
    } catch (Exception e) {
        Logger.error(e);
    }
}
Also used : GroupController(org.jbei.ice.lib.group.GroupController) ConfigurationSettings(org.jbei.ice.lib.config.ConfigurationSettings) RebuildBlastIndexTask(org.jbei.ice.lib.search.blast.RebuildBlastIndexTask) AutoAnnotationBlastDbBuildTask(org.jbei.ice.lib.entry.sequence.annotation.AutoAnnotationBlastDbBuildTask) AccountController(org.jbei.ice.lib.account.AccountController)

Aggregations

RebuildBlastIndexTask (org.jbei.ice.lib.search.blast.RebuildBlastIndexTask)3 GroupController (org.jbei.ice.lib.group.GroupController)2 AccountController (org.jbei.ice.lib.account.AccountController)1 ConfigurationSettings (org.jbei.ice.lib.config.ConfigurationSettings)1 AccessPermission (org.jbei.ice.lib.dto.access.AccessPermission)1 AutoAnnotationBlastDbBuildTask (org.jbei.ice.lib.entry.sequence.annotation.AutoAnnotationBlastDbBuildTask)1