Search in sources :

Example 1 with DeleteDependencyConfigTO

use of org.craftercms.studio.api.v1.to.DeleteDependencyConfigTO in project studio by craftercms.

the class ContentTypesConfigImpl method loadDeleteDependencies.

/**
 * load delete dependencies mapping
 *
 * @param contentTypeConfig
 * @param nodes
 */
protected void loadDeleteDependencies(ContentTypeConfigTO contentTypeConfig, List<Node> nodes) {
    List<DeleteDependencyConfigTO> deleteConfigs = new ArrayList<>();
    if (nodes != null) {
        for (Node node : nodes) {
            Node patternNode = node.selectSingleNode("pattern");
            Node removeFolderNode = node.selectSingleNode("remove-empty-folder");
            if (patternNode != null) {
                String pattern = patternNode.getText();
                String removeEmptyFolder = removeFolderNode.getText();
                boolean isRemoveEmptyFolder = false;
                if (removeEmptyFolder != null) {
                    isRemoveEmptyFolder = Boolean.valueOf(removeEmptyFolder);
                }
                if (StringUtils.isNotEmpty(pattern)) {
                    DeleteDependencyConfigTO deleteConfigTO = new DeleteDependencyConfigTO(pattern, isRemoveEmptyFolder);
                    deleteConfigs.add(deleteConfigTO);
                }
            }
        }
        contentTypeConfig.setDeleteDependencies(deleteConfigs);
    }
}
Also used : Node(org.dom4j.Node) ArrayList(java.util.ArrayList) DeleteDependencyConfigTO(org.craftercms.studio.api.v1.to.DeleteDependencyConfigTO)

Example 2 with DeleteDependencyConfigTO

use of org.craftercms.studio.api.v1.to.DeleteDependencyConfigTO in project studio by craftercms.

the class DependencyServiceImpl method getContentTypeFilteredDeleteDependencies.

private Set<String> getContentTypeFilteredDeleteDependencies(String site, Set<String> paths) {
    Set<String> toRet = new HashSet<String>();
    List<String> deps = getItemDependenciesFromDB(site, paths);
    for (String dep : deps) {
        ContentItemTO item = contentService.getContentItem(site, dep, 0);
        List<DeleteDependencyConfigTO> deleteDependencyConfigList = servicesConfig.getDeleteDependencyPatterns(site, item.getContentType());
        if (CollectionUtils.isNotEmpty(deleteDependencyConfigList)) {
            for (DeleteDependencyConfigTO deleteDependencyConfig : deleteDependencyConfigList) {
                if (dep.matches(deleteDependencyConfig.getPattern())) {
                    toRet.add(dep);
                    break;
                }
            }
        }
    }
    return toRet;
}
Also used : ContentItemTO(org.craftercms.studio.api.v1.to.ContentItemTO) DeleteDependencyConfigTO(org.craftercms.studio.api.v1.to.DeleteDependencyConfigTO) HashSet(java.util.HashSet)

Example 3 with DeleteDependencyConfigTO

use of org.craftercms.studio.api.v1.to.DeleteDependencyConfigTO in project studio by craftercms.

the class ContentServiceImpl method getDeletePatternConfig.

protected List<DeleteDependencyConfigTO> getDeletePatternConfig(String site, String relativePath, boolean isInLiveRepo) throws ServiceLayerException {
    List<DeleteDependencyConfigTO> deleteAssociations = new ArrayList<DeleteDependencyConfigTO>();
    ContentItemTO dependencyItem = getContentItem(site, relativePath, 0);
    String contentType = dependencyItem.getContentType();
    deleteAssociations = servicesConfig.getDeleteDependencyPatterns(site, contentType);
    return deleteAssociations;
}
Also used : ContentItemTO(org.craftercms.studio.api.v1.to.ContentItemTO) ArrayList(java.util.ArrayList) DeleteDependencyConfigTO(org.craftercms.studio.api.v1.to.DeleteDependencyConfigTO)

Aggregations

DeleteDependencyConfigTO (org.craftercms.studio.api.v1.to.DeleteDependencyConfigTO)3 ArrayList (java.util.ArrayList)2 ContentItemTO (org.craftercms.studio.api.v1.to.ContentItemTO)2 HashSet (java.util.HashSet)1 Node (org.dom4j.Node)1