Searches for a collection name by provided entity name in a cached entity metadata.
The returned collection name can be null.

@param {string} entityName - entity name
@returns {string} - a collection name
186856
function findCollectionName(entityName) {
    var xrmInternal = Utility.getXrmInternal();
    if (!Utility.isNull(xrmInternal)) {
        return xrmInternal.getEntitySetName(entityName) || entityName;
    }

    var collectionName = null;

    if (!Utility.isNull(_entityNames)) {
        collectionName = _entityNames[entityName];
        if (Utility.isNull(collectionName)) {
            for (var key in _entityNames) {
                if (_entityNames[key] == entityName) {
                    return entityName;
                }
            }
        }
    }

    return collectionName;
}
1127915
protected function getEntityName($entityClassName)
    {
        preg_match_all('/\\\([a-zA-Z]+)/', $entityClassName, $matches);
        if (!empty($matches[1])) {
            return $matches[1][count($matches[1]) - 1];
        }
        return $entityClassName;
    }
981685
@Override
    public String lookupEntityName(JsonEntityBean entity) {
        if (entity == null) {
            throw new IllegalArgumentException("Parameter cannot be null.");
        }
        EntityEnum entityEnum = entity.getEntityType();
        if (entityEnum == null) {
            throw new IllegalArgumentException(
                    String.format(
                            "Parameter's entityType has an unknown value of [%s]",
                            entity.getEntityType()));
        }
        IEntityNameFinder finder;
        if (entityEnum.isGroup()) {
            finder = EntityNameFinderService.instance().getNameFinder(IEntityGroup.class);
        } else {
            finder = EntityNameFinderService.instance().getNameFinder(entityEnum.getClazz());
        }

        try {
            return finder.getName(entity.getId());
        } catch (Exception e) {
            /* An exception here isn't the end of the world.  Just log it
            and return null. */
            log.warn("Couldn't find name for entity " + entity.getId(), e);
            return null;
        }
    }
234720
function makeMongooseModelName(collectionName) {
    if (collectionName !== collectionName.toLowerCase()) {
        throw new Error('expect lowercase, was ' + collectionName);
    }
    if (collectionName.charAt(collectionName.length - 1) === 's') {
        return collectionName.substring(0, collectionName.length - 1);
    }
    throw new Error('expected name with trailing s');
}
110409
function collection(id) {
    if(!this.resource) {
      throw new Error('This Entity does not have a Resource.');
    }

    var path = this.resource.path + '/collections';

    return Resource.constructorFactory(path, EVT.Entity.Collection)
      .call(this.resource.scope, id);
  }
459128
@Override
    public Object find(Class entityClass, Object key)
    {
        EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClass);
        GetResponse get = null;

        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata()
                .getMetamodel(metadata.getPersistenceUnit());

        EntityType entityType = metaModel.entity(metadata.getEntityClazz());

        String keyAsString = getKeyAsString(key, metadata, metaModel);
        try
        {
            get = txClient.prepareGet(metadata.getSchema().toLowerCase(), metadata.getTableName(), keyAsString)
                    .setOperationThreaded(false).execute().get();
        }
        catch (InterruptedException iex)
        {
            logger.error("Error while find record of {}, Caused by :.", entityClass.getSimpleName(), iex);
            throw new PersistenceException(iex);
        }
        catch (ExecutionException eex)
        {
            logger.error("Error while find record of {}, Caused by :.", entityClass.getSimpleName(), eex);
            throw new PersistenceException(eex);
        }

        Map<String, Object> results = get.getSource();

        Object result = null;

        if (get.isExists())
        {
            result = KunderaCoreUtils.createNewInstance(entityClass);
            PropertyAccessorHelper.setId(result, metadata, key);
            result = esResponseReader.wrapFindResult(results, entityType, result, metadata, true);
        }

        return result;
    }
1313035
public Map<String, Object> getDocument(String collectionName, String docId) {
        Map<String, Map<String,Object>> docs = DDPStateSingleton.getInstance()
                .getCollection(collectionName);
        if (docs != null) {
            return docs.get(docId);
        }
        return null;
    }
1078388
public static synchronized List getPropertyNames(String entityTypeName) {
        if (propertyNames != null) {
            return propertyNames;
        } else {
            {
                List names = new ArrayList();
                names.add(PROP_CN);
                names.add(PROP_MEMBERS);
                names.add(PROP_DISPLAY_NAME);
                names.add(PROP_DESCRIPTION);
                names.add(PROP_BUSINESS_CATEGORY);
                names.add(PROP_SEE_ALSO);
                if (extendedPropertiesDataType != null && extendedPropertiesDataType.keySet().size() > 0)
                    names.addAll(extendedPropertiesDataType.keySet());
                names.addAll(Party.getPropertyNames("Party"));
                propertyNames = Collections.unmodifiableList(names);
                return propertyNames;
            }
        }
    }
663509
public Entity getEntityWithKey(String keyName) {
    // [START getEntityWithKey]
    Key key = datastore.newKeyFactory().setKind("MyKind").newKey(keyName);
    Entity entity = datastore.get(key);
    // Do something with the entity
    // [END getEntityWithKey]
    return entity;
  }
534322
@Override
  public <T> T findById(Object id, Class<T> entityClass) {
    return findById(id, Util.determineCollectionName(entityClass));
  }
559415
public function findByCollectionNameIterator($collectionName)
    {
        /** @var QueryBuilder $queryBuilder */
        $queryBuilder = $this->entityManager->createQueryBuilder();
        return $queryBuilder
            ->select('PersistentResource')
            ->from($this->getEntityClassName(), 'PersistentResource')
            ->where('PersistentResource.collectionName = :collectionName')
            ->setParameter(':collectionName', $collectionName)
            ->getQuery()->iterate();
    }
1350447
private String getEntityName() throws ODataUnmarshallingException {
        String odataType = odataValues.get(JsonConstants.TYPE);
        if (isNullOrEmpty(odataType)) {
            TargetType targetType = getTargetType();
            if (targetType == null) {
                throw new ODataUnmarshallingException("Could not find entity name");
            }
            return targetType.typeName();
        } else {
            if (odataType.startsWith("#")) {
                odataType = odataType.substring(1);
            }
            return odataType;
        }
    }
736458
@SuppressWarnings("unchecked")
  @Override
  public <T> List<T> find(String jxQuery, String collectionName) {
    CollectionMetaData cmd = cmdMap.get(collectionName);
    Map<Object, T> collection = (Map<Object, T>) collectionsRef.get().get(collectionName);
    if((null == cmd) || (null == collection)) {
      throw new InvalidJsonDbApiUsageException("Collection by name '" + collectionName + "' not found. Create collection first.");
    }
    cmd.getCollectionLock().readLock().lock();
    try {
      JXPathContext context = contextsRef.get().get(collectionName);
      Iterator<T> resultItr = context.iterate(jxQuery);
      List<T> newCollection = new ArrayList<T>();
      while (resultItr.hasNext()) {
        T document = resultItr.next();
        Object obj = Util.deepCopy(document);
        if(encrypted && cmd.hasSecret() && null != obj) {
          CryptoUtil.decryptFields(obj, cmd, dbConfig.getCipher());
        }
        newCollection.add((T) obj);
      }
      return newCollection;
    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
      logger.error("Error when decrypting value for a @Secret annotated field for entity: " + collectionName, e);
      throw new JsonDBException("Error when decrypting value for a @Secret annotated field for entity: " + collectionName, e);
    } finally {
      cmd.getCollectionLock().readLock().unlock();
    }
  }
1238237
public E findImmutablePropertyByName(String name) {
		String lcName = name.toLowerCase();
		for (E item : immutableCollection) {
			if (item.getName().toLowerCase().equals(lcName)) {
				return item;
			}
		}

		return null;
	}
1118015
String getCollectionName(String url) {
        final String SEPARATOR = "\\";
        String cell = null;
        String node = null;
        String serverName = null;
        int index = -1;

        if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_WAS.entering(methodClassName, methodNames[GET_COLLECTION_NAME], "url: " + url);
        }

        //lets look to see if we can use the url.  This most likely means the native driver
        if (url != null && url.indexOf("jdbc:db2") != -1) {
            String collection = url;

            index = collection.indexOf(";");
            if (index != -1) {
                collection = collection.substring(0, index);
            }
            index = collection.indexOf("//");
            if (index != -1) {
                collection = collection.substring(index + 2);
            }
            index = collection.indexOf("/");
            if (index != -1) {
                collection = collection.substring(index + 1).trim();
                if (collection.length() != 0) {
                    as400_collection = collection;
                }
            }
        } else {
            //using toolbox driver

            //            try {
            //            	/*
            //                String unformatted = com.ibm.websphere.runtime.ServerName.getFullName();
            //
            //                if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled()&&LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
            //                    LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[GET_COLLECTION_NAME], "Full server name retrieved: " + unformatted);
            //                }
            //
            //                //we need everything or nothing, so do no checking here until we're done.
            //                //if we something winds up null, then we're toast anyway, so take the exception
            //                //and use the defaults in the catch below.
            //                index = unformatted.indexOf(SEPARATOR);
            //                cell = unformatted.substring(0, index);
            //                unformatted = unformatted.substring(index + SEPARATOR.length());
            //
            //                index = unformatted.indexOf(SEPARATOR);
            //                node = unformatted.substring(0, index);
            //
            //                serverName = unformatted.substring(index + SEPARATOR.length());
            //
            //                if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled()&&LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
            //                    LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[GET_COLLECTION_NAME], "Using cell name: " + cell);
            //                    LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[GET_COLLECTION_NAME], "Using node name: " + node);
            //                    LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[GET_COLLECTION_NAME], "Using server name: " + serverName);
            //                }
            //
            //                if ((cell == null) || (node == null) || (serverName == null))
            //                    throw new Exception("Unable to retrieve cell, node, or serverName.");
            //
            //                com.ibm.ws.runtime.service.Repository repository = com.ibm.ws.runtime.service.RepositoryFactory.createRepository(System.getProperty("user.install.root") + "/config", cell, node, serverName);
            //
            //                  */
            //                // com.ibm.ws.runtime.service.Repository repository = com.ibm.ws.runtime.service.RepositoryFactory.createRepository(System.getProperty("user.install.root") + "/config", cell, node, serverName);
            //                // PK78174 this instanceof com.ibm.wsspi.runtime.component.WsComponent
            //                Repository repository = (Repository) WsServiceRegistry.getService(this, Repository.class);
            //
            //                if (repository == null)
            //                    throw new Exception("Unable to acquire a reference to the repository.");
            //
            //                String jndiDSName = _smc.getJNDIDataSourceName();
            //                if ((as400_collection = retrieveDBSessionCollection(repository, com.ibm.ws.runtime.service.ConfigRoot.SERVER, jndiDSName)) == null) {
            //                    if ((as400_collection = retrieveDBSessionCollection(repository, com.ibm.ws.runtime.service.ConfigRoot.NODE, jndiDSName)) == null) {
            //                        if ((as400_collection = retrieveDBSessionCollection(repository, com.ibm.ws.runtime.service.ConfigRoot.CELL, jndiDSName)) == null) {
            //                        	if ((as400_collection = retrieveDBSessionCollection(repository, com.ibm.ws.runtime.service.ConfigRoot.CLUSTER, jndiDSName)) == null) {
            //                        		throw new Exception("DataSource not configured with JNDI name: " + jndiDSName);
            //                        	}
            //                        }
            //                    }
            //                }
            //            } catch (Exception ex) {
            //                LoggingUtil.SESSION_LOGGER_WAS.logp(Level.WARNING, methodClassName, methodNames[GET_COLLECTION_NAME], "CommonMessage.exception", ex);
            //            }
        }

        if (as400_collection == null) {
            String installLibrary = System.getProperty("was.install.library");
            if (installLibrary == null) {
                LoggingUtil.SESSION_LOGGER_WAS.logp(Level.WARNING, methodClassName, methodNames[GET_COLLECTION_NAME], "CommonMessage.miscData",
                                                    "was.install.library not set.  Using collection QEJBASSN for session persistance.");
                as400_collection = "QEJBASSN";
            } else {
                LoggingUtil.SESSION_LOGGER_WAS.logp(Level.WARNING, methodClassName, methodNames[GET_COLLECTION_NAME], "CommonMessage.miscData",
                                                    "using was.install.library to derive collection name for session persistance.");
                as400_collection = installLibrary + "SN";
                if (as400_collection.length() > 10) {
                    as400_collection = as400_collection.substring(0, 10);
                }
            }
        }
        if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
            LoggingUtil.SESSION_LOGGER_WAS.exiting(methodClassName, methodNames[GET_COLLECTION_NAME], "Session Persistance will use the collection: " + as400_collection);
        }
        return as400_collection;
    }
91875
public Entity getEntityByName(String entityName) {
        Entity entity = currentEntitiesByName.get(entityName.toUpperCase());
        Assert.notNull(entity, "You must be sure that an entity is present. Entity name=" + entityName);
        return entity;
    }
56346
function getMongoModelForEntity(entity) {
	
	const entityName = entity.setEntityName();
	
	if(!models.hasOwnProperty(entity.setEntityName()))
	{
		models[entityName] = convertPAIEntityToMongoSchema(entity);
		
		PAILogger.info("MongoDB Model just created: " + entityName);
	}
	
	return models[entityName];
}