Get the resource definition from the criteria which specifies the resource type

@param criteria
@return
437544
@Override
	public RuntimeResourceDefinition validateCriteriaAndReturnResourceDefinition(String criteria) {
		String resourceName;
		if (criteria == null || criteria.trim().isEmpty()) {
			throw new IllegalArgumentException("Criteria cannot be empty");
		}
		if (criteria.contains("?")) {
			resourceName = criteria.substring(0, criteria.indexOf("?"));
		} else {
			resourceName = criteria;
		}

		return getContext().getResourceDefinition(resourceName);
	}
1145913
@SuppressWarnings("rawtypes")
    public org.grails.datastore.mapping.query.api.Criteria inList(String propertyName, Collection values) {
        return in(propertyName, values);
    }
1324784
public long updateAll(final QueryableCriteria criteria, final Map<String, Object> properties) {
        return getHibernateTemplate().execute((GrailsHibernateTemplate.HibernateCallback<Integer>) session -> {
            JpaQueryBuilder builder = new JpaQueryBuilder(criteria);
            builder.setConversionService(getMappingContext().getConversionService());
            builder.setHibernateCompatible(true);
            PersistentEntity targetEntity = criteria.getPersistentEntity();
            PersistentProperty lastUpdated = targetEntity.getPropertyByName(GormProperties.LAST_UPDATED);
            if(lastUpdated != null && targetEntity.getMapping().getMappedForm().isAutoTimestamp()) {
                if (timestampProvider == null) {
                    timestampProvider = new DefaultTimestampProvider();
                }
                properties.put(GormProperties.LAST_UPDATED, timestampProvider.createTimestamp(lastUpdated.getType()));
            }

            JpaQueryInfo jpaQueryInfo = builder.buildUpdate(properties);

            org.hibernate.query.Query query = session.createQuery(jpaQueryInfo.getQuery());
            getHibernateTemplate().applySettings(query);
            List parameters = jpaQueryInfo.getParameters();
            if (parameters != null) {
                for (int i = 0, count = parameters.size(); i < count; i++) {
                    query.setParameter(JpaQueryBuilder.PARAMETER_NAME_PREFIX + (i+1), parameters.get(i));
                }
            }

            HibernateHqlQuery hqlQuery = new HibernateHqlQuery(HibernateSession.this, targetEntity, query);
            ApplicationEventPublisher applicationEventPublisher = datastore.getApplicationEventPublisher();
            applicationEventPublisher.publishEvent(new PreQueryEvent(datastore, hqlQuery));
            int result = query.executeUpdate();
            applicationEventPublisher.publishEvent(new PostQueryEvent(datastore, hqlQuery, Collections.singletonList(result)));
            return result;
        });
    }
1080690
public static <T> CriteriaQuery<Long> countCriteria(EntityManager em, CriteriaQuery<T> criteria) {
        CriteriaBuilder builder = em.getCriteriaBuilder();
        CriteriaQuery<Long> countCriteria = builder.createQuery(Long.class);
        copyCriteriaNoSelection(criteria, countCriteria);
        countCriteria.select(builder.count(findRoot(countCriteria, criteria.getResultType())));

        return countCriteria;
    }
904685
public Long count(Criteria<T, T> criteria) {
        SingularAttribute<? super T, PK> id = getEntityManager().getMetamodel().entity(entityClass).getId(entityKey);
        return criteria.select(Long.class, countDistinct(id))
                .getSingleResult();
    }
1112185
@Override
	public List<Criterion> getCriteria() {
		if (criteria == null) {
			criteria = new ArrayList<Criterion>();
		}
		return criteria;
	}
936280
protected function findResourceOrThrowException(array $criteria)
    {
        if (null === $resource = $this->getRepository()->findOneBy($criteria)) {
            throw new NotFoundHttpException('Resource not found.');
        }
        return $resource;
    }
413902
@Override
    public Resource getResource(String path) {
	int index = path.indexOf("://");
	if (index != -1) {
	    String scheme = path.substring(0, index).toLowerCase().trim();
	    String subPath = path.substring(index + 3);
	    for (int i = 0; i < resources.length; i++) {
		if (scheme.equalsIgnoreCase(resources[i].getScheme())) {
		    return resources[i].instance().getResource(subPath);
		}
	    }
	}
	return defaultResource.getResource(path);
    }
979616
public I_CmsPreEditorActionDefinition getPreEditorConditionDefinition(I_CmsResourceType resourceType) {

        Iterator<I_CmsPreEditorActionDefinition> i = m_preEditorConditionDefinitions.iterator();
        I_CmsPreEditorActionDefinition result = null;
        int matchResult = -1;
        while (i.hasNext()) {
            I_CmsPreEditorActionDefinition currentDefinition = i.next();
            if (resourceType.getClass().isInstance(currentDefinition.getResourceType())) {
                // now determine the match count...
                int matchDistance = 0;
                Class<?> superClass = resourceType.getClass();
                while (true) {
                    // check if a super class is present
                    if (superClass == null) {
                        break;
                    }
                    if (superClass.getName().equals(currentDefinition.getResourceType().getClass().getName())) {
                        break;
                    }
                    matchDistance += 1;
                    superClass = superClass.getSuperclass();
                }
                if (matchResult != -1) {
                    if (matchDistance < matchResult) {
                        matchResult = matchDistance;
                        result = currentDefinition;
                    }
                } else {
                    matchResult = matchDistance;
                    result = currentDefinition;
                }
            }
        }
        return result;
    }
435612
@Override
    public String getResourceId() {
        Preconditions.checkArgument(
                this.urlType == UrlType.RESOURCE,
                "UrlType must be %s but was %s",
                UrlType.RESOURCE,
                this.urlType);
        return this.resourceId;
    }
475950
public static <T> Root<T> findRoot(CriteriaQuery<T> query) {
        return findRoot(query, query.getResultType());
    }
318385
protected Criteria createDistinctRootEntityCriteria(Criterion... criterion) {
        Criteria criteria = getSession().createCriteria(entityClass);
        addCriterionsToCriteria(criteria, criterion);
        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
        criteria.setCacheable(this.useQueryCache);
        return criteria;
    }
1271092
private ResourceType getResourceType(String resourceTag) {
        if (resourceTag == null || !resourceTag.endsWith("-resource")) {
            return ResourceType.unknown;
        }

        try {
            return ResourceType.valueOf(resourceTag.substring(0, resourceTag.length() - 9));
        } catch (Exception e) {
            return ResourceType.unknown;
        }
    }
420220
public final int getAttributeResourceID(int index) {
        int resourceIndex=getAttribute(index).name;
        if (m_resourceIDs==null ||
                resourceIndex<0 || resourceIndex>=m_resourceIDs.length)
        {
            return 0;
        }
        return m_resourceIDs[resourceIndex];
    }
825478
public static @Nullable String getExistingResourceType(@NotNull ResourceResolver resourceResolver, @NotNull String @NotNull... resourceTypes) {
    for (String path : resourceTypes) {
      if (resourceResolver.getResource(path) != null) {
        return path;
      }
    }
    return null;
  }
450645
public static List getDNF(Criteria crit)
    {
        List dnf = new ArrayList();
        Enumeration e = crit.getElements();
        Criteria tmpCrit;

        while (e.hasMoreElements())
        {
            Object o = e.nextElement();
            if (o instanceof Criteria)
            {
                Criteria pc = (Criteria) o;
                switch (pc.getType())
                {
                    case (Criteria.OR):
                        {
                            dnf.addAll(getDNF(pc));
                            break;
                        }
                    case (Criteria.AND):
                        {
                            dnf = getDnfAndDnf(dnf, getDNF(pc));
                            break;
                        }
                }
            }
            else
            {
                SelectionCriteria c = (SelectionCriteria) o;
                tmpCrit = new Criteria();
                tmpCrit.getCriteria().add(c);
                if (dnf.isEmpty())
                {
                    dnf.add(tmpCrit);
                }
                else
                {
//#ifdef JDK13
					dnf = getDnfAndDnf(dnf, Collections.singletonList(tmpCrit));
//#else
/*
					Vector singletonList = new Vector(1);
					singletonList.add(tmpCrit);
					dnf = getDnfAndDnf(dnf,singletonList); 
*/

//#endif                	
                	
                    
                }
            }
        } // while

        return dnf;
    }
275922
public static <T> Set<T> subset(Set<T> set, Criteria<T> criteria) {
        Set<T> subset = new HashSet<T>();
        for(T item : set) {
            if(criteria.meetsCriteria(item)) {
                subset.add(item);
            }
        }
        return subset;
    }