Search in sources :

Example 1 with ConfigurationController

use of org.jbei.ice.lib.config.ConfigurationController in project ice by JBEI.

the class SequenceController method update.

/**
     * Update the {@link Sequence} in the database, with the option to rebuild the search index.
     *
     * @param userId   unique identifier for user performing action
     * @param sequence sequence to be updated
     * @return Saved Sequence.
     */
protected Sequence update(String userId, Sequence sequence) {
    authorization.expectWrite(userId, sequence.getEntry());
    Sequence result;
    Entry entry = sequence.getEntry();
    entry.setModificationTime(Calendar.getInstance().getTime());
    Sequence oldSequence = dao.getByEntry(entry);
    if (oldSequence == null) {
        result = dao.create(sequence);
    } else {
        String tmpDir = new ConfigurationController().getPropertyValue(ConfigurationKey.TEMPORARY_DIRECTORY);
        if (!StringUtils.isEmpty(tmpDir)) {
            String hash = oldSequence.getFwdHash();
            try {
                Files.deleteIfExists(Paths.get(tmpDir, hash + ".png"));
            } catch (IOException e) {
                Logger.warn(e.getMessage());
            }
        }
        oldSequence.setSequenceUser(sequence.getSequenceUser());
        oldSequence.setSequence(sequence.getSequence());
        oldSequence.setFwdHash(sequence.getFwdHash());
        oldSequence.setRevHash(sequence.getRevHash());
        result = dao.updateSequence(oldSequence, sequence.getSequenceFeatures());
    }
    BlastPlus.scheduleBlastIndexRebuildTask(true);
    return result;
}
Also used : ConfigurationController(org.jbei.ice.lib.config.ConfigurationController) HasEntry(org.jbei.ice.lib.entry.HasEntry) IOException(java.io.IOException)

Example 2 with ConfigurationController

use of org.jbei.ice.lib.config.ConfigurationController in project ice by JBEI.

the class SequenceController method deleteSequence.

public boolean deleteSequence(String requester, long partId) {
    Entry entry = DAOFactory.getEntryDAO().get(partId);
    authorization.expectWrite(requester, entry);
    Sequence sequence = dao.getByEntry(entry);
    if (sequence == null)
        return true;
    String tmpDir = new ConfigurationController().getPropertyValue(ConfigurationKey.TEMPORARY_DIRECTORY);
    dao.deleteSequence(sequence, tmpDir);
    BlastPlus.scheduleBlastIndexRebuildTask(true);
    return true;
}
Also used : ConfigurationController(org.jbei.ice.lib.config.ConfigurationController) HasEntry(org.jbei.ice.lib.entry.HasEntry)

Example 3 with ConfigurationController

use of org.jbei.ice.lib.config.ConfigurationController in project ice by JBEI.

the class Utils method getConfigValue.

public static String getConfigValue(ConfigurationKey key) {
    ConfigurationController controller = new ConfigurationController();
    String value = controller.getPropertyValue(key);
    if (value != null)
        return value;
    return key.getDefaultValue();
}
Also used : ConfigurationController(org.jbei.ice.lib.config.ConfigurationController)

Example 4 with ConfigurationController

use of org.jbei.ice.lib.config.ConfigurationController in project ice by JBEI.

the class WoRControllerTest method testIsWebEnabled.

@Test
public void testIsWebEnabled() throws Exception {
    Assert.assertFalse(controller.isWebEnabled());
    new ConfigurationController().setPropertyValue(ConfigurationKey.JOIN_WEB_OF_REGISTRIES, "yes");
    Assert.assertTrue(controller.isWebEnabled());
    new ConfigurationController().setPropertyValue(ConfigurationKey.JOIN_WEB_OF_REGISTRIES, "no");
    Assert.assertFalse(controller.isWebEnabled());
}
Also used : ConfigurationController(org.jbei.ice.lib.config.ConfigurationController) Test(org.junit.Test)

Example 5 with ConfigurationController

use of org.jbei.ice.lib.config.ConfigurationController in project ice by JBEI.

the class WoRController method setEnable.

/**
     * Runs the web of registries task for contacting the appropriate partners to enable or disable
     * web of registries functionality
     *
     * @param enable if true, enables WoR; disables it otherwise
     * @param url    the url for this ice instance
     */
public void setEnable(String userId, boolean enable, String url) {
    String thisUrl = Utils.getConfigValue(ConfigurationKey.URI_PREFIX);
    if (!thisUrl.equalsIgnoreCase(url)) {
        Logger.info("Auto updating uri to " + url);
        ConfigurationController configurationController = new ConfigurationController();
        configurationController.setPropertyValue(ConfigurationKey.URI_PREFIX, url);
    }
    WebOfRegistriesTask contactTask = new WebOfRegistriesTask(userId, url, enable);
    IceExecutorService.getInstance().runTask(contactTask);
}
Also used : ConfigurationController(org.jbei.ice.lib.config.ConfigurationController)

Aggregations

ConfigurationController (org.jbei.ice.lib.config.ConfigurationController)8 HasEntry (org.jbei.ice.lib.entry.HasEntry)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 AccountController (org.jbei.ice.lib.account.AccountController)1 AutoAnnotationBlastDbBuildTask (org.jbei.ice.lib.entry.sequence.annotation.AutoAnnotationBlastDbBuildTask)1 GroupController (org.jbei.ice.lib.group.GroupController)1