Search in sources :

Example 6 with IContextManager

use of org.jaffa.session.IContextManager in project jaffa-framework by jaffa-projects.

the class FinderComponent2 method loadDefaultQuery.

public void loadDefaultQuery() throws ApplicationException {
    IContextManager contextManager = ContextManagerFactory.instance();
    QuerySaver querySaver = new QuerySaver(contextManager);
    String defaultQueryId = querySaver.getDefaultQueryId(this.getComponentDefinition().getComponentName());
    if (defaultQueryId != null) {
        setSavedQueryId(new Long(defaultQueryId));
        loadQuery();
    } else {
        throw new QueryNotFoundException("Default Query");
    }
}
Also used : IContextManager(org.jaffa.session.IContextManager)

Example 7 with IContextManager

use of org.jaffa.session.IContextManager in project jaffa-framework by jaffa-projects.

the class FinderComponent2 method retrieveQueryTypes.

/**
 * Returns a map of query ids and their export type. Is used by UI to determine if results should be opened in a new window.
 * @return Map containing export types for saved queries.
 */
public Map<String, String> retrieveQueryTypes() {
    /*
         * Read the stored queries and create map
         * this can be used to determine export type
         */
    // Get the saved Queries
    Map<String, String> queryTypes = null;
    IContextManager contextManager = ContextManagerFactory.instance();
    QuerySaver querySaver = new QuerySaver(contextManager);
    Map savedQueries = querySaver.getSavedQueryList(getComponentDefinition().getComponentName());
    if (savedQueries.size() > 0) {
        queryTypes = new HashMap<String, String>();
        Iterator savedQueriesIterator = savedQueries.keySet().iterator();
        while (savedQueriesIterator.hasNext()) {
            String element = (String) savedQueriesIterator.next();
            Map queryFields = querySaver.getSavedQueryFields(getComponentDefinition().getComponentName(), element);
            String type = (String) queryFields.get("ExportType");
            queryTypes.put(element, type);
        }
    }
    return queryTypes;
}
Also used : IContextManager(org.jaffa.session.IContextManager)

Example 8 with IContextManager

use of org.jaffa.session.IContextManager in project jaffa-framework by jaffa-projects.

the class FinderComponent2 method deleteQuery.

/**
 * deleteQuery
 *
 * @throws ApplicationException
 *
 * Deletes the currntly selected saved query
 */
public void deleteQuery() throws ApplicationException {
    if (getSavedQueryId() != null) {
        IContextManager contextManager = ContextManagerFactory.instance();
        QuerySaver querySaver = new QuerySaver(contextManager);
        try {
            querySaver.removeSavedQuery(getComponentDefinition().getComponentName(), getSavedQueryId().toString());
        } catch (IOException e) {
            log.error("IOError removing Queries ", e);
            throw new GetQueryDataException(e);
        }
    }
    initializeSavedQueries();
    getUserSession().getWidgetCache(getComponentId()).clear();
}
Also used : IOException(java.io.IOException) GetQueryDataException(org.jaffa.exceptions.GetQueryDataException) IContextManager(org.jaffa.session.IContextManager)

Example 9 with IContextManager

use of org.jaffa.session.IContextManager in project jaffa-framework by jaffa-projects.

the class FinderComponent2 method saveQuery.

/**
 * saveQuery
 * @throws ApplicationException
 *
 * Saves the current query
 */
public void saveQuery() throws ApplicationException {
    Map queryData = null;
    queryData = getQueryData();
    queryData.putAll(getCommonQueryData());
    try {
        IContextManager contextManager = ContextManagerFactory.instance();
        QuerySaver querySaver = new QuerySaver(contextManager);
        querySaver.saveQuery(getNewQueryName(), this.getComponentDefinition().getComponentName(), queryData, getDefaultQueryYn().booleanValue(), getQueryHasShortcutYn().booleanValue());
    } catch (IOException e) {
        log.error("IOError saving Queries ", e);
        throw new GetQueryDataException(e);
    }
    initializeSavedQueries();
    getUserSession().getWidgetCache(getComponentId()).clear();
}
Also used : IOException(java.io.IOException) GetQueryDataException(org.jaffa.exceptions.GetQueryDataException) IContextManager(org.jaffa.session.IContextManager)

Example 10 with IContextManager

use of org.jaffa.session.IContextManager in project jaffa-framework by jaffa-projects.

the class QuerySaver method removeShortcutFlag.

public static void removeShortcutFlag(String componentName, String savedQueryId) throws IOException {
    IContextManager contextManager = ContextManagerFactory.instance();
    QuerySaver qs = new QuerySaver(contextManager);
    qs.removeSavedQueryShortcut(componentName, savedQueryId);
}
Also used : IContextManager(org.jaffa.session.IContextManager)

Aggregations

IContextManager (org.jaffa.session.IContextManager)13 IOException (java.io.IOException)2 GetQueryDataException (org.jaffa.exceptions.GetQueryDataException)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 CodeHelperOutCodeDto (org.jaffa.components.codehelper.dto.CodeHelperOutCodeDto)1 CodeHelperOutElementDto (org.jaffa.components.codehelper.dto.CodeHelperOutElementDto)1 ApplicationRulesManager (org.jaffa.loader.config.ApplicationRulesManager)1 UserSession (org.jaffa.presentation.portlet.session.UserSession)1 Test (org.junit.Test)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpSession (org.springframework.mock.web.MockHttpSession)1