Returns all relation types in the given list that define relations in the content.<p>

@param relationTypes the collection of relation types to filter

@return a list of {@link CmsRelationType} objects
437229
public static List<CmsRelationType> filterDefinedInContent(Collection<CmsRelationType> relationTypes) {

        List<CmsRelationType> result = new ArrayList<CmsRelationType>(relationTypes);
        Iterator<CmsRelationType> it = result.iterator();
        while (it.hasNext()) {
            CmsRelationType type = it.next();
            if (!type.isDefinedInContent()) {
                it.remove();
            }
        }
        return result;
    }
337686
public Relation getRelations(int i) {
    if (Document_Type.featOkTst && ((Document_Type)jcasType).casFeat_relations == null)
      jcasType.jcas.throwFeatMissing("relations", "de.julielab.jules.types.ace.Document");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((Document_Type)jcasType).casFeatCode_relations), i);
    return (Relation)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((Document_Type)jcasType).casFeatCode_relations), i)));}
833170
public static Set<Fragment> inferRelationTypes(TransactionOLTP tx, Set<Fragment> allFragments) {

        Set<Fragment> inferredFragments = new HashSet<>();

        Map<Variable, Type> labelVarTypeMap = getLabelVarTypeMap(tx, allFragments);
        if (labelVarTypeMap.isEmpty()) return inferredFragments;

        Multimap<Variable, Type> instanceVarTypeMap = getInstanceVarTypeMap(allFragments, labelVarTypeMap);

        Multimap<Variable, Variable> relationRolePlayerMap = getRelationRolePlayerMap(allFragments, instanceVarTypeMap);
        if (relationRolePlayerMap.isEmpty()) return inferredFragments;

        // for each type, get all possible relation type it could be in
        Multimap<Type, RelationType> relationMap = HashMultimap.create();
        labelVarTypeMap.values().stream().distinct().forEach(
                type -> addAllPossibleRelations(relationMap, type));

        // inferred labels should be kept separately, even if they are already in allFragments set
        Map<Label, Statement> inferredLabels = new HashMap<>();
        relationRolePlayerMap.asMap().forEach((relationVar, rolePlayerVars) -> {

            Set<Type> possibleRelationTypes = rolePlayerVars.stream()
                    .filter(instanceVarTypeMap::containsKey)
                    .map(rolePlayer -> getAllPossibleRelationTypes(
                            instanceVarTypeMap.get(rolePlayer), relationMap))
                    .reduce(Sets::intersection).orElse(Collections.emptySet());

            //TODO: if possibleRelationTypes here is empty, the query will not match any data
            if (possibleRelationTypes.size() == 1) {

                Type relationType = possibleRelationTypes.iterator().next();
                Label label = relationType.label();

                // add label fragment if this label has not been inferred
                if (!inferredLabels.containsKey(label)) {
                    Statement labelVar = var();
                    inferredLabels.put(label, labelVar);
                    Fragment labelFragment = Fragments.label(new TypeProperty(label.getValue()), labelVar.var(), ImmutableSet.of(label));
                    inferredFragments.add(labelFragment);
                }

                // finally, add inferred isa fragments
                Statement labelVar = inferredLabels.get(label);
                IsaProperty isaProperty = new IsaProperty(labelVar);
                EquivalentFragmentSet isaEquivalentFragmentSet = EquivalentFragmentSets.isa(isaProperty,
                        relationVar, labelVar.var(), relationType.isImplicit());
                inferredFragments.addAll(isaEquivalentFragmentSet.fragments());
            }
        });

        return inferredFragments;
    }
108431
protected static CmsRelationType getRelationType(String typeName) {

        for (CmsRelationType relType : CmsRelationType.getAll()) {
            if (relType.getName().equalsIgnoreCase(typeName)) {
                return relType;
            }
        }
        return null;
    }
755773
public Set<Annotation> getSubTreeNodes(@NonNull Annotation node, String... childRelations) {
      Set<Annotation> children = new HashSet<>();
      Set<String> targetRel = childRelations == null ? Collections.emptySet() : Sets.asSet(
         Arrays.asList(childRelations));
      Predicate<RelationEdge> keep = edge -> targetRel.size() == 0 || targetRel.contains(edge.getRelation());

      Queue<RelationEdge> queue = new LinkedList<>(getInEdges(node).stream().filter(keep).collect(Collectors.toList()));
      while (!queue.isEmpty()) {
         RelationEdge n = queue.remove();
         if (!"relcl".equals(n.getRelation()) && !"parataxis".equals(n.getRelation())) {
            children.add(n.getFirstVertex());
            queue.addAll(getInEdges(n.getFirstVertex())
                            .stream()
                            .filter(e -> !children.contains(e.getFirstVertex()))
                            .collect(Collectors.toSet()));
         }
      }
      return children;
   }
630212
public List<CmsResourceTypeBean> getSearchTypes() {

        if (m_searchTypes != null) {
            return m_searchTypes;
        }
        m_searchTypes = Lists.newArrayList();
        for (CmsResourceTypeBean type : m_dialogBean.getTypes()) {
            if (type.getVisibility() != TypeVisibility.hidden) {
                m_searchTypes.add(type);
            }
        }
        return m_searchTypes;
    }
631222
private RelationType getRelationType(int index)
   {
      if (index < 0 || index > RELATION_TYPES.length)
      {
         index = 0;
      }

      return RELATION_TYPES[index];
   }
91838
public static List<I_CmsResourceType> getResourceTypes() {

        List<I_CmsResourceType> res = new ArrayList<I_CmsResourceType>();
        for (I_CmsResourceType type : OpenCms.getResourceManager().getResourceTypes()) {
            CmsExplorerTypeSettings typeSetting = OpenCms.getWorkplaceManager().getExplorerTypeSetting(
                type.getTypeName());
            if (typeSetting != null) {
                res.add(type);
            }
        }
        return res;
    }
76609
protected List<CmsPublishedResource> findRelatedContainerPages(
        CmsObject adminCms,
        List<CmsPublishedResource> updateResources) {

        Set<CmsResource> elementGroups = new HashSet<CmsResource>();
        Set<CmsResource> containerPages = new HashSet<CmsResource>();
        int containerPageTypeId = -1;
        try {
            containerPageTypeId = CmsResourceTypeXmlContainerPage.getContainerPageTypeId();
        } catch (CmsLoaderException e) {
            // will happen during setup, when container page type is not available yet
            LOG.info(e.getLocalizedMessage(), e);
        }
        if (containerPageTypeId != -1) {
            for (CmsPublishedResource pubRes : updateResources) {
                try {
                    if (OpenCms.getResourceManager().getResourceType(
                        pubRes.getType()) instanceof CmsResourceTypeXmlContent) {
                        CmsRelationFilter filter = CmsRelationFilter.relationsToStructureId(pubRes.getStructureId());
                        filter.filterStrong();
                        List<CmsRelation> relations = adminCms.readRelations(filter);
                        for (CmsRelation relation : relations) {
                            CmsResource res = relation.getSource(adminCms, CmsResourceFilter.ALL);
                            if (CmsResourceTypeXmlContainerPage.isContainerPage(res)) {
                                containerPages.add(res);
                                if (CmsDetailOnlyContainerUtil.isDetailContainersPage(
                                    adminCms,
                                    adminCms.getSitePath(res))) {
                                    addDetailContent(adminCms, containerPages, adminCms.getSitePath(res));
                                }
                            } else if (OpenCms.getResourceManager().getResourceType(
                                res.getTypeId()).getTypeName().equals(
                                    CmsResourceTypeXmlContainerPage.GROUP_CONTAINER_TYPE_NAME)) {
                                elementGroups.add(res);
                            }
                        }
                    }
                    if (containerPageTypeId == pubRes.getType()) {
                        addDetailContent(
                            adminCms,
                            containerPages,
                            adminCms.getRequestContext().removeSiteRoot(pubRes.getRootPath()));
                    }
                } catch (CmsException e) {
                    LOG.error(e.getLocalizedMessage(), e);
                }
            }
            for (CmsResource pubRes : elementGroups) {
                try {
                    CmsRelationFilter filter = CmsRelationFilter.relationsToStructureId(pubRes.getStructureId());
                    filter.filterStrong();
                    List<CmsRelation> relations = adminCms.readRelations(filter);
                    for (CmsRelation relation : relations) {
                        CmsResource res = relation.getSource(adminCms, CmsResourceFilter.ALL);
                        if (CmsResourceTypeXmlContainerPage.isContainerPage(res)) {
                            containerPages.add(res);
                            if (CmsDetailOnlyContainerUtil.isDetailContainersPage(
                                adminCms,
                                adminCms.getSitePath(res))) {
                                addDetailContent(adminCms, containerPages, adminCms.getSitePath(res));
                            }
                        }
                    }
                } catch (CmsException e) {
                    LOG.error(e.getLocalizedMessage(), e);
                }
            }
            // add all found container pages as published resource objects to the list
            for (CmsResource page : containerPages) {
                CmsPublishedResource pubCont = new CmsPublishedResource(page);
                if (!updateResources.contains(pubCont)) {
                    // ensure container page is added only once
                    updateResources.add(pubCont);
                }
            }
        }
        return updateResources;
    }
941640
public Map<String, Object> getRelations()
    {
        return relations != null ? Collections.unmodifiableMap(relations) : null;
    }
698265
public List<TargetRelationship> getTargetRelationships() {
        final List<TargetRelationship> relationships = new ArrayList<TargetRelationship>(levelRelationships);
        relationships.addAll(topicTargetRelationships);
        return relationships;
    }
707660
@Override
    public Set<ManagedType<?>> getManagedTypes()
    {
        Set<ManagedType<?>> managedTypeCollection = new HashSet<ManagedType<?>>();
        if (entityTypes != null)
        {
            managedTypeCollection.addAll(entityTypes.values());
        }
        if (embeddables != null)
        {
            managedTypeCollection.addAll((Collection<? extends ManagedType<?>>) embeddables.values());
        }
        if (mappedSuperClassTypes != null)
        {
            managedTypeCollection.addAll((Collection<? extends ManagedType<?>>) mappedSuperClassTypes.values());
        }
        return managedTypeCollection;
    }
497901
public void importRelation(String resourceName, String targetPath, String relationType) throws CmsException {

        createRelation(resourceName, targetPath, relationType, true);
    }
308450
private List<CmsRelation> getRelationsFromResource(CmsResource currentResource) {

        try {
            return m_cms.readRelations(CmsRelationFilter.relationsFromStructureId(currentResource.getStructureId()));
        } catch (CmsException e) {
            return Collections.emptyList();
        }
    }
890735
public CmsRelationFilter filterType(CmsRelationType type) {

        CmsRelationFilter filter = (CmsRelationFilter)clone();
        filter.m_types.add(type);
        return filter;
    }
914651
public List<CmsLink> getLinks(CmsObject cms) {

        List<CmsLink> result = new ArrayList<CmsLink>();

        @SuppressWarnings("unchecked")
        List<Element> linkElements = m_element.elements(CmsXmlPage.NODE_LINK);
        for (Element linkElement : linkElements) {
            if (linkElement == null) {
                String uri = m_element.getText();
                if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(uri)) {
                    setStringValue(cms, uri);
                }
            }
            CmsLinkUpdateUtil.updateType(linkElement, getRelationType(getPath()));
            CmsLink link = new CmsLink(linkElement);
            link.checkConsistency(cms);
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(link.getTarget())) {
                continue;
            }
            result.add(link);
        }
        return result;
    }
1315654
private void copyRelations(CmsDbContext dbc, CmsResource source, CmsResource target) throws CmsException {

        // copy relations all relations
        CmsObject cms = new CmsObject(getSecurityManager(), dbc.getRequestContext());
        Iterator<CmsRelation> itRelations = getRelationsForResource(
            dbc,
            source,
            CmsRelationFilter.TARGETS.filterNotDefinedInContent()).iterator();
        while (itRelations.hasNext()) {
            CmsRelation relation = itRelations.next();
            if (relation.getType().getCopyBehavior() == CopyBehavior.copy) {
                try {
                    CmsResource relTarget = relation.getTarget(cms, CmsResourceFilter.ALL);
                    addRelationToResource(dbc, target, relTarget, relation.getType(), true);
                } catch (CmsVfsResourceNotFoundException e) {
                    // ignore this broken relation
                    if (LOG.isWarnEnabled()) {
                        LOG.warn(e.getLocalizedMessage(), e);
                    }
                }
            }
        }
        // repair categories
        repairCategories(dbc, getProjectIdForContext(dbc), target);
    }