Example usage for java.util Collections EMPTY_MAP

List of usage examples for java.util Collections EMPTY_MAP

Introduction

In this page you can find the example usage for java.util Collections EMPTY_MAP.

Prototype

Map EMPTY_MAP

To view the source code for java.util Collections EMPTY_MAP.

Click Source Link

Document

The empty map (immutable).

Usage

From source file:org.apache.atlas.web.resources.EntityJerseyResourceIT.java

@Test
//API should accept single entity (or jsonarray of entities)
public void testSubmitSingleEntity() throws Exception {
    Referenceable databaseInstance = new Referenceable(DATABASE_TYPE_BUILTIN);
    String dbName = randomString();
    databaseInstance.set("name", dbName);
    databaseInstance.set(QUALIFIED_NAME, dbName);
    databaseInstance.set("clusterName", randomString());
    databaseInstance.set("description", randomString());
    databaseInstance.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, dbName);
    databaseInstance.set("owner", "user1");
    databaseInstance.set("clusterName", "cl1");
    databaseInstance.set("parameters", Collections.EMPTY_MAP);
    databaseInstance.set("location", "/tmp");

    JSONObject response = atlasClientV1.callAPIWithBody(AtlasClient.API.CREATE_ENTITY,
            InstanceSerialization.toJson(databaseInstance, true));
    assertNotNull(response);//  w ww .j  a v a  2 s. co  m
    Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));

    AtlasClient.EntityResult entityResult = AtlasClient.EntityResult.fromString(response.toString());
    assertEquals(entityResult.getCreatedEntities().size(), 1);
    assertNotNull(entityResult.getCreatedEntities().get(0));
}

From source file:com.nextep.datadesigner.vcs.impl.SelfControlVersionable.java

public Map<IReference, IReferenceable> getReferenceMap() {
    return Collections.EMPTY_MAP;
}

From source file:com.redhat.rhn.common.db.datasource.test.AdvDataSourceTest.java

public void testStressedElaboration() throws Exception {
    int startId = 1000;
    int endId = startId + 1500;

    for (int i = startId; i < endId; i++) {
        insert("foobar" + TestUtils.randomString(), i);
    }//from w  ww .j  a  va 2 s  .c  o  m
    SelectMode m = ModeFactory.getMode("test_queries", "find_all_in_table");
    DataResult<AdvDataSourceDto> dr = m.execute(Collections.EMPTY_MAP);
    dr.elaborate();
    for (AdvDataSourceDto row : dr) {
        assertNotNull(row.getTestColumn());
        assertNotNull(row.getPin());
        assertNotNull(row.getFoobar());
    }
}

From source file:com.redhat.rhn.manager.kickstart.KickstartLister.java

/**
 * Get the list of Activation Keys//from  w  w  w.ja v  a2  s .  c  o m
 * @param orgIn Org
 * @param pc to filter
 * @return DataResult list.
 */
public DataResult<ActivationKeyDto> getActivationKeysInOrg(Org orgIn, PageControl pc) {
    if (logger.isDebugEnabled()) {
        logger.debug("activationKeysForKickstartProfile(Org orgIn=" + orgIn + ", PageControl pc=" + pc
                + ") - start");
    }

    SelectMode m = ModeFactory.getMode("General_queries", "activation_keys_for_org");
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("org_id", orgIn.getId());
    DataResult<ActivationKeyDto> returnDataResult = makeDataResult(params, Collections.EMPTY_MAP, pc, m);

    if (logger.isDebugEnabled()) {
        logger.debug("activationKeysForKickstartProfile(Org, PageControl) - " + "end - return value="
                + returnDataResult);
    }
    return returnDataResult;
}

From source file:org.apache.cayenne.access.DataDomainQueryAction.java

/**
 * @since 3.0/*ww w .ja  v  a 2  s  . c o m*/
 */
private boolean interceptRefreshQuery() {

    if (query instanceof RefreshQuery) {
        RefreshQuery refreshQuery = (RefreshQuery) query;

        if (refreshQuery.isRefreshAll()) {

            // not sending any events - peer contexts will not get refreshed
            if (domain.getSharedSnapshotCache() != null) {
                domain.getSharedSnapshotCache().clear();
            }
            context.getQueryCache().clear();

            GenericResponse response = new GenericResponse();
            response.addUpdateCount(1);
            this.response = response;
            return DONE;
        }

        Collection<Persistent> objects = (Collection<Persistent>) refreshQuery.getObjects();
        if (objects != null && !objects.isEmpty()) {

            Collection<ObjectId> ids = new ArrayList<ObjectId>(objects.size());
            for (final Persistent object : objects) {
                ids.add(object.getObjectId());
            }

            if (domain.getSharedSnapshotCache() != null) {
                // send an event for removed snapshots
                domain.getSharedSnapshotCache().processSnapshotChanges(context.getObjectStore(),
                        Collections.EMPTY_MAP, Collections.EMPTY_LIST, ids, Collections.EMPTY_LIST);
            }

            GenericResponse response = new GenericResponse();
            response.addUpdateCount(1);
            this.response = response;
            return DONE;
        }

        // 3. refresh query - this shouldn't normally happen as child datacontext
        // usually does a cascading refresh
        if (refreshQuery.getQuery() != null) {
            Query cachedQuery = refreshQuery.getQuery();

            String cacheKey = cachedQuery.getMetaData(context.getEntityResolver()).getCacheKey();
            context.getQueryCache().remove(cacheKey);

            this.response = domain.onQuery(context, cachedQuery);
            return DONE;
        }

        // 4. refresh groups...
        if (refreshQuery.getGroupKeys() != null && refreshQuery.getGroupKeys().length > 0) {

            String[] groups = refreshQuery.getGroupKeys();
            for (String group : groups) {
                domain.getQueryCache().removeGroup(group);
            }

            GenericResponse response = new GenericResponse();
            response.addUpdateCount(1);
            this.response = response;
            return DONE;
        }
    }

    return !DONE;
}

From source file:org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingsHolder.java

@Override
public UrlCreator getReverseMapping(String controller, String action, String namespace, String pluginName,
        String httpMethod, String version, Map params) {
    if (params == null)
        params = Collections.EMPTY_MAP;

    if (urlCreatorCache != null) {
        UrlCreatorCache.ReverseMappingKey key = urlCreatorCache.createKey(controller, action, namespace,
                pluginName, httpMethod, params);
        UrlCreator creator = urlCreatorCache.lookup(key);
        if (creator == null) {
            creator = resolveUrlCreator(controller, action, namespace, pluginName, httpMethod, version, params,
                    true);/*from   ww  w.  jav  a2s  .co m*/
            creator = urlCreatorCache.putAndDecorate(key, creator);
        }
        // preserve previous side-effect, remove mappingName from params
        params.remove("mappingName");
        return creator;
    }
    // cache is disabled
    return resolveUrlCreator(controller, action, namespace, pluginName, httpMethod, version, params, true);
}

From source file:com.lakeside.data.sqldb.PageBaseDao.java

protected String getCountSql(String originalHql) {
    QueryTranslatorImpl queryTranslator = new QueryTranslatorImpl(originalHql, originalHql,
            Collections.EMPTY_MAP, (SessionFactoryImplementor) sessionFactory);

    queryTranslator.compile(Collections.EMPTY_MAP, false);
    String fromHql = StringUtils.substringBeforeLast(queryTranslator.getSQLString(), "order by");
    return "select count(*) from (" + fromHql + ") totalcount";
}

From source file:org.apereo.portal.layout.dlm.remoting.UpdatePreferencesServlet.java

/**
 * Remove an element from the layout./*from   w ww. j  a v a  2  s .  c  o m*/
 *
 * @param request
 * @param response
 * @return
 * @throws IOException
 */
@RequestMapping(method = RequestMethod.POST, params = "action=removeElement")
public ModelAndView removeElement(HttpServletRequest request, HttpServletResponse response) throws IOException {

    IUserInstance ui = userInstanceManager.getUserInstance(request);
    IPerson per = getPerson(ui, response);

    UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
    IUserLayoutManager ulm = upm.getUserLayoutManager();

    try {

        // if the element ID starts with the fragment prefix and is a folder,
        // attempt first to treat it as a pulled fragment subscription
        String elementId = request.getParameter("elementID");
        if (elementId != null && elementId.startsWith(Constants.FRAGMENT_ID_USER_PREFIX) && ulm
                .getNode(elementId) instanceof org.apereo.portal.layout.node.UserLayoutFolderDescription) {

            removeSubscription(per, elementId, ulm);

        } else {
            // Delete the requested element node.  This code is the same for
            // all node types, so we can just have a generic action.
            if (!ulm.deleteNode(elementId)) {
                logger.info(
                        "Failed to remove element ID {} from layout root folder ID {}, delete node returned false",
                        elementId, ulm.getRootFolderId());
                response.sendError(HttpServletResponse.SC_FORBIDDEN);
                return new ModelAndView("jsonView",
                        Collections.singletonMap("error", getMessage("error.element.update",
                                "Unable to update element", RequestContextUtils.getLocale(request))));
            }
        }

        ulm.saveUserLayout();

        return new ModelAndView("jsonView", Collections.EMPTY_MAP);

    } catch (PortalException e) {
        return handlePersistError(request, response, e);
    }
}

From source file:com.redhat.rhn.common.db.datasource.test.AdvDataSourceTest.java

public void testDoubleElaboration() throws Exception {
    SelectMode m = ModeFactory.getMode("test_queries", "withClass");
    DataResult<TableData> dr = m.execute(Collections.EMPTY_MAP);
    assertTrue(dr.size() >= 1);/*from   w  w  w  .  ja  v  a2s. com*/
    dr.elaborate();
    TableData rowA = dr.get(0);
    String tableNameA = rowA.getTableName();
    String columnNameA = StringUtils.join(rowA.getColumnName().iterator(), ",");
    // Elaborate 2nd time
    dr.elaborate();
    TableData rowB = dr.get(0);
    String tableNameB = rowB.getTableName();
    String columnNameB = StringUtils.join(rowB.getColumnName().iterator(), ",");

    assertEquals(tableNameA, tableNameB);
    assertEquals(columnNameA, columnNameB);
}

From source file:fr.inria.atlanmod.neoemf.map.datastore.MapPersistenceBackendFactoryTest.java

@Test
public void testCreatePersistentEStoreCachedManyOption() throws InvalidDataStoreException, NoSuchFieldException,
        SecurityException, IllegalArgumentException, IllegalAccessException {
    storeOptions.add(MapResourceOptions.EStoreMapOption.CACHED_MANY);
    PersistenceBackend persistentBackend = persistenceBackendFactory.createPersistentBackend(testFile,
            Collections.EMPTY_MAP);
    SearcheableResourceEStore eStore = persistenceBackendFactory.createPersistentEStore(null, persistentBackend,
            options);//from w  w  w .  jav  a  2s.c om
    assert eStore instanceof CachedManyDirectWriteMapResourceEStoreImpl : "Invalid EStore created";
    PersistenceBackend innerBackend = getInnerBackend((DirectWriteMapResourceEStoreImpl) eStore);
    assert innerBackend == persistentBackend : "The backend in the EStore is not the created one";
}