Search in sources :

Example 26 with CfClasscontent

use of io.clownfish.clownfish.dbentities.CfClasscontent in project Clownfish by rawdog71.

the class SiteTreeBean method onSelect.

public void onSelect(NodeSelectEvent event) {
    selectedNode = event.getTreeNode();
    selectedSite = (CfSite) selectedNode.getData();
    classcontentlist = cfclasscontentService.findByMaintenance(true);
    if (null != selectedSite.getTemplateref()) {
        CfTemplate template = cftemplateService.findById(selectedSite.getTemplateref().longValue());
        int idx = templatelist.getTemplateListe().indexOf(template);
        selectedTemplate = templatelist.getTemplateListe().get(idx);
        iframeurl = selectedSite.getName() + "?preview=true";
        selectedDiv = null;
        showContent = false;
        showDatalist = false;
        showAsset = false;
        showAssetLibrary = false;
        showKeywordLibrary = false;
        if (template.isLayout()) {
            contenteditable = true;
            FacesMessage message = new FacesMessage("LAYOUT TEMPLATE");
            FacesContext.getCurrentInstance().addMessage(null, message);
            // List<CfLayoutcontent> layoutcontent = cflayoutcontentService.findBySiteref(selectedSite.getId());
            layout = new CfLayout(template.getName());
            Document doc = Jsoup.parse(template.getContent());
            Elements divs = doc.getElementsByAttribute("template");
            for (Element div : divs) {
                String contents = div.attr("contents");
                String datalists = div.attr("datalists");
                String assets = div.attr("assets");
                String assetlists = div.attr("assetlists");
                String keywordlists = div.attr("keywordlists");
                CfDiv cfdiv = new CfDiv();
                cfdiv.setId(div.attr("id"));
                cfdiv.setName(div.attr("template"));
                if (!contents.isEmpty()) {
                    cfdiv.getContentArray().addAll(ClownfishUtil.toList(contents.split(",")));
                }
                if (!datalists.isEmpty()) {
                    cfdiv.getContentlistArray().addAll(ClownfishUtil.toList(datalists.split(",")));
                }
                if (!assets.isEmpty()) {
                    cfdiv.getAssetArray().addAll(ClownfishUtil.toList(assets.split(",")));
                }
                if (!assetlists.isEmpty()) {
                    cfdiv.getAssetlistArray().addAll(ClownfishUtil.toList(assetlists.split(",")));
                }
                if (!keywordlists.isEmpty()) {
                    cfdiv.getKeywordlistArray().addAll(ClownfishUtil.toList(keywordlists.split(",")));
                }
                layout.getDivArray().put(div.attr("id"), cfdiv);
            }
        } else {
            contenteditable = false;
            selected_contentclass = null;
            selected_datalisttclass = null;
            selected_asset = null;
            selected_assetlist = null;
            selected_keywordlist = null;
        }
    } else {
        selectedTemplate = null;
    }
    if (null != selectedSite.getStylesheetref()) {
        CfStylesheet styleshet = cfstylesheetService.findById(selectedSite.getStylesheetref().longValue());
        int idx = stylesheetlist.getStylesheetListe().indexOf(styleshet);
        selectedStylesheet = stylesheetlist.getStylesheetListe().get(idx);
    } else {
        selectedStylesheet = null;
    }
    if (null != selectedSite.getJavascriptref()) {
        CfJavascript javascript = cfjavascriptService.findById(selectedSite.getJavascriptref().longValue());
        int idx = javascriptlist.getJavascriptListe().indexOf(javascript);
        selectedJavascript = javascriptlist.getJavascriptListe().get(idx);
    } else {
        selectedJavascript = null;
    }
    selectedDatasources.clear();
    List<CfSitedatasource> selectedSiteDatasources = cfsitedatasourceService.findBySiteref(selectedSite.getId());
    for (CfSitedatasource sitedatasource : selectedSiteDatasources) {
        CfDatasource ds = cfdatasourceService.findById(sitedatasource.getCfSitedatasourcePK().getDatasourceref());
        selectedDatasources.add(ds);
    }
    selectedContentlist.clear();
    List<CfSitelist> selectedSitecontentlist = cfsitelistService.findBySiteref(selectedSite.getId());
    for (CfSitelist sitelist : selectedSitecontentlist) {
        CfList cl = cflistService.findById(sitelist.getCfSitelistPK().getListref());
        selectedContentlist.add(cl);
    }
    selectedClasscontentlist.clear();
    List<CfSitecontent> selectedClasscontentliste = cfsitecontentService.findBySiteref(selectedSite.getId());
    for (CfSitecontent sitecontent : selectedClasscontentliste) {
        CfClasscontent cc = cfclasscontentService.findById(sitecontent.getCfSitecontentPK().getClasscontentref());
        selectedClasscontentlist.add(cc);
    }
    selectedAssetlist.clear();
    List<CfSiteassetlist> selectedAssetliste = cfsiteassetlistService.findBySiteref(selectedSite.getId());
    for (CfSiteassetlist siteassetlist : selectedAssetliste) {
        CfAssetlist csa = cfassetlistService.findById(siteassetlist.getCfSiteassetlistPK().getAssetlistref());
        selectedAssetlist.add(csa);
    }
    selectedKeywordlist.clear();
    List<CfSitekeywordlist> selectedKeywordliste = cfsitekeywordlistService.findBySiteref(selectedSite.getId());
    for (CfSitekeywordlist sitekeywordlist : selectedKeywordliste) {
        CfKeywordlist kwl = cfkeywordlistService.findById(sitekeywordlist.getCfSitekeywordlistPK().getKeywordlistref());
        selectedKeywordlist.add(kwl);
    }
    siteName = selectedSite.getName();
    siteTitle = selectedSite.getTitle();
    siteDescription = selectedSite.getDescription();
    sitejob = selectedSite.isJob();
    sitesearchrelevant = selectedSite.isSearchrelevant();
    sitemap = selectedSite.isSitemap();
    sitestatic = selectedSite.isStaticsite();
    aliaspath = selectedSite.getAliaspath();
    sitehtmlcompression = selectedSite.getHtmlcompression();
    characterEncoding = selectedSite.getCharacterencoding();
    contentType = selectedSite.getContenttype();
    locale = selectedSite.getLocale();
    saprfclist = cfsitesaprfcService.findBySiteref(selectedSite.getId());
    newButtonDisabled = true;
    FacesMessage message = new FacesMessage("Selected " + selectedSite.getName());
    FacesContext.getCurrentInstance().addMessage(null, message);
}
Also used : CfSitedatasource(io.clownfish.clownfish.dbentities.CfSitedatasource) Element(org.jsoup.nodes.Element) CfDatasource(io.clownfish.clownfish.dbentities.CfDatasource) CfSiteassetlist(io.clownfish.clownfish.dbentities.CfSiteassetlist) CfAssetlist(io.clownfish.clownfish.dbentities.CfAssetlist) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements) CfClasscontent(io.clownfish.clownfish.dbentities.CfClasscontent) CfTemplate(io.clownfish.clownfish.dbentities.CfTemplate) CfDiv(io.clownfish.clownfish.datamodels.CfDiv) CfSitekeywordlist(io.clownfish.clownfish.dbentities.CfSitekeywordlist) CfList(io.clownfish.clownfish.dbentities.CfList) CfJavascript(io.clownfish.clownfish.dbentities.CfJavascript) CfKeywordlist(io.clownfish.clownfish.dbentities.CfKeywordlist) CfLayout(io.clownfish.clownfish.datamodels.CfLayout) CfSitecontent(io.clownfish.clownfish.dbentities.CfSitecontent) CfSitelist(io.clownfish.clownfish.dbentities.CfSitelist) CfStylesheet(io.clownfish.clownfish.dbentities.CfStylesheet) FacesMessage(javax.faces.application.FacesMessage)

Example 27 with CfClasscontent

use of io.clownfish.clownfish.dbentities.CfClasscontent in project Clownfish by rawdog71.

the class SiteTreeBean method onChange.

public void onChange(ActionEvent actionEvent) {
    if (null != selectedSite) {
        if (null != selectedStylesheet) {
            selectedSite.setStylesheetref(BigInteger.valueOf(selectedStylesheet.getId().intValue()));
        } else {
            selectedSite.setStylesheetref(null);
        }
        if (null != selectedTemplate) {
            selectedSite.setTemplateref(BigInteger.valueOf(selectedTemplate.getId().intValue()));
        } else {
            selectedSite.setTemplateref(null);
        }
        if (null != selectedJavascript) {
            selectedSite.setJavascriptref(BigInteger.valueOf(selectedJavascript.getId().intValue()));
        } else {
            selectedSite.setJavascriptref(null);
        }
        // Delete siteresources first
        List<CfSitedatasource> sitedatasourceList = cfsitedatasourceService.findBySiteref(selectedSite.getId());
        for (CfSitedatasource sitedatasource : sitedatasourceList) {
            cfsitedatasourceService.delete(sitedatasource);
        }
        // Add selected siteresources
        if (!selectedDatasources.isEmpty()) {
            for (CfDatasource datasource : selectedDatasources) {
                CfSitedatasource sitedatasource = new CfSitedatasource();
                CfSitedatasourcePK cfsitedatasourcePK = new CfSitedatasourcePK();
                cfsitedatasourcePK.setSiteref(selectedSite.getId());
                cfsitedatasourcePK.setDatasourceref(datasource.getId());
                sitedatasource.setCfSitedatasourcePK(cfsitedatasourcePK);
                cfsitedatasourceService.create(sitedatasource);
            }
        }
        // Delete sitelists first
        List<CfSitelist> sitelists = cfsitelistService.findBySiteref(selectedSite.getId());
        for (CfSitelist sitelist : sitelists) {
            cfsitelistService.delete(sitelist);
        }
        // Add selected sitelists
        if (!selectedContentlist.isEmpty()) {
            for (CfList contentList : selectedContentlist) {
                CfSitelist sitelist = new CfSitelist();
                CfSitelistPK cfsitelistPK = new CfSitelistPK();
                cfsitelistPK.setSiteref(selectedSite.getId());
                cfsitelistPK.setListref(contentList.getId());
                sitelist.setCfSitelistPK(cfsitelistPK);
                cfsitelistService.create(sitelist);
            }
        }
        // Delete sitecontent first
        List<CfSitecontent> contentlists = cfsitecontentService.findBySiteref(selectedSite.getId());
        for (CfSitecontent content : contentlists) {
            cfsitecontentService.delete(content);
        }
        // Add selected sitecontent
        if (!selectedClasscontentlist.isEmpty()) {
            for (CfClasscontent content : selectedClasscontentlist) {
                CfSitecontent sitecontent = new CfSitecontent();
                CfSitecontentPK cfsitecontentPK = new CfSitecontentPK();
                cfsitecontentPK.setSiteref(selectedSite.getId());
                cfsitecontentPK.setClasscontentref(content.getId());
                sitecontent.setCfSitecontentPK(cfsitecontentPK);
                cfsitecontentService.create(sitecontent);
            }
        }
        // Delete siteassetlist first
        List<CfSiteassetlist> siteassetlists = cfsiteassetlistService.findBySiteref(selectedSite.getId());
        for (CfSiteassetlist assetList : siteassetlists) {
            cfsiteassetlistService.delete(assetList);
        }
        // Add selected sitecontent
        if (!selectedAssetlist.isEmpty()) {
            for (CfAssetlist content : selectedAssetlist) {
                CfSiteassetlist siteassetlist = new CfSiteassetlist();
                CfSiteassetlistPK cfsitecontentPK = new CfSiteassetlistPK();
                cfsitecontentPK.setSiteref(selectedSite.getId());
                cfsitecontentPK.setAssetlistref(content.getId());
                siteassetlist.setCfSiteassetlistPK(cfsitecontentPK);
                cfsiteassetlistService.create(siteassetlist);
            }
        }
        // Delete sitekeywordlist first
        List<CfSitekeywordlist> sitekeywordlists = cfsitekeywordlistService.findBySiteref(selectedSite.getId());
        for (CfSitekeywordlist keywordList : sitekeywordlists) {
            cfsitekeywordlistService.delete(keywordList);
        }
        // Add selected sitecontent
        if (!selectedKeywordlist.isEmpty()) {
            for (CfKeywordlist content : selectedKeywordlist) {
                CfSitekeywordlist sitekeywordlist = new CfSitekeywordlist();
                CfSitekeywordlistPK cfsitecontentPK = new CfSitekeywordlistPK();
                cfsitecontentPK.setSiteref(selectedSite.getId());
                cfsitecontentPK.setKeywordlistref(content.getId());
                sitekeywordlist.setCfSitekeywordlistPK(cfsitecontentPK);
                cfsitekeywordlistService.create(sitekeywordlist);
            }
        }
        selectedSite.setName(siteName);
        selectedSite.setHtmlcompression(sitehtmlcompression);
        selectedSite.setCharacterencoding(characterEncoding);
        selectedSite.setContenttype(contentType);
        selectedSite.setLocale(locale);
        selectedSite.setAliaspath(aliaspath);
        selectedSite.setTitle(siteTitle);
        selectedSite.setDescription(siteDescription);
        selectedSite.setJob(sitejob);
        selectedSite.setSearchrelevant(sitesearchrelevant);
        selectedSite.setSitemap(sitemap);
        selectedSite.setStaticsite(sitestatic);
        cfsiteService.edit(selectedSite);
        loadTree();
        FacesMessage message = new FacesMessage("Changed " + selectedSite.getName());
        FacesContext.getCurrentInstance().addMessage(null, message);
    }
}
Also used : CfSitedatasource(io.clownfish.clownfish.dbentities.CfSitedatasource) CfKeywordlist(io.clownfish.clownfish.dbentities.CfKeywordlist) CfSitedatasourcePK(io.clownfish.clownfish.dbentities.CfSitedatasourcePK) CfSitelistPK(io.clownfish.clownfish.dbentities.CfSitelistPK) CfSiteassetlistPK(io.clownfish.clownfish.dbentities.CfSiteassetlistPK) CfSitecontent(io.clownfish.clownfish.dbentities.CfSitecontent) CfSitelist(io.clownfish.clownfish.dbentities.CfSitelist) CfDatasource(io.clownfish.clownfish.dbentities.CfDatasource) CfSiteassetlist(io.clownfish.clownfish.dbentities.CfSiteassetlist) CfAssetlist(io.clownfish.clownfish.dbentities.CfAssetlist) CfClasscontent(io.clownfish.clownfish.dbentities.CfClasscontent) CfSitecontentPK(io.clownfish.clownfish.dbentities.CfSitecontentPK) CfSitekeywordlistPK(io.clownfish.clownfish.dbentities.CfSitekeywordlistPK) CfSitekeywordlist(io.clownfish.clownfish.dbentities.CfSitekeywordlist) CfList(io.clownfish.clownfish.dbentities.CfList) FacesMessage(javax.faces.application.FacesMessage)

Example 28 with CfClasscontent

use of io.clownfish.clownfish.dbentities.CfClasscontent in project Clownfish by rawdog71.

the class CfClasscontentDAOImpl method findByClassref.

@Override
public List<CfClasscontent> findByClassref(CfClass classref) {
    Session session = this.sessionFactory.getCurrentSession();
    TypedQuery query = (TypedQuery) session.getNamedQuery("CfClasscontent.findByClassref");
    query.setParameter("classref", classref);
    List<CfClasscontent> cfclasscontentlist = query.getResultList();
    return cfclasscontentlist;
}
Also used : TypedQuery(javax.persistence.TypedQuery) CfClasscontent(io.clownfish.clownfish.dbentities.CfClasscontent) Session(org.hibernate.Session)

Example 29 with CfClasscontent

use of io.clownfish.clownfish.dbentities.CfClasscontent in project Clownfish by rawdog71.

the class ClassUtil method getattributmap.

public Map getattributmap(CfClasscontent classcontent) {
    List<CfAttributcontent> attributcontentlist = new ArrayList<>();
    attributcontentlist.addAll(cfattributcontentService.findByClasscontentref(classcontent));
    Map attributcontentmap = new LinkedHashMap();
    for (CfAttributcontent attributcontent : attributcontentlist) {
        CfAttribut cfattribut = cfattributService.findById(attributcontent.getAttributref().getId());
        CfAttributetype cfattributtype = cfattributetypeService.findById(cfattribut.getAttributetype().getId());
        switch(cfattributtype.getName()) {
            case "boolean":
                attributcontentmap.put(cfattribut.getName(), attributcontent.getContentBoolean());
                break;
            case "string":
                attributcontentmap.put(cfattribut.getName(), attributcontent.getContentString());
                break;
            case "hashstring":
                attributcontentmap.put(cfattribut.getName(), attributcontent.getContentString());
                break;
            case "integer":
                attributcontentmap.put(cfattribut.getName(), attributcontent.getContentInteger());
                break;
            case "real":
                attributcontentmap.put(cfattribut.getName(), attributcontent.getContentReal());
                break;
            case "htmltext":
                attributcontentmap.put(cfattribut.getName(), attributcontent.getContentText());
                break;
            case "datetime":
                attributcontentmap.put(cfattribut.getName(), attributcontent.getContentDate());
                break;
            case "media":
                attributcontentmap.put(cfattribut.getName(), attributcontent.getContentInteger());
                break;
            case "text":
                attributcontentmap.put(cfattribut.getName(), attributcontent.getContentText());
                break;
            case "markdown":
                markdownUtil.initOptions();
                if (null != attributcontent.getContentText()) {
                    attributcontentmap.put(cfattribut.getName(), markdownUtil.parseMarkdown(attributcontent.getContentText(), markdownUtil.getMarkdownOptions()));
                } else {
                    attributcontentmap.put(cfattribut.getName(), markdownUtil.parseMarkdown("", markdownUtil.getMarkdownOptions()));
                }
                break;
            case "classref":
                if (null != attributcontent.getClasscontentlistref()) {
                    Map listcontentmap = new LinkedHashMap();
                    List<CfListcontent> selectedcontent = cflistcontentService.findByListref(attributcontent.getClasscontentlistref().getId());
                    List<CfClasscontent> selectedListcontent = new ArrayList<>();
                    selectedListcontent.clear();
                    if (!selectedcontent.isEmpty()) {
                        selectedcontent.stream().map((listcontent) -> cfclasscontentService.findById(listcontent.getCfListcontentPK().getClasscontentref())).forEach((selectedContent) -> {
                            if (null != selectedContent) {
                                selectedListcontent.add(selectedContent);
                            }
                        });
                    }
                    selectedListcontent.stream().forEach((cc) -> {
                        Map dummy_attributcontentmap = new LinkedHashMap();
                        dummy_attributcontentmap = getattributmap(cc);
                        listcontentmap.put(cc.getName(), dummy_attributcontentmap);
                    });
                    attributcontentmap.put(attributcontent.getAttributref().getName(), listcontentmap);
                }
                break;
            case "assetref":
                if (null != attributcontent.getAssetcontentlistref()) {
                    Map assetlistcontentmap = new LinkedHashMap();
                    List<CfAssetlistcontent> selectedlistassets = cfassetlistcontentService.findByAssetlistref(attributcontent.getAssetcontentlistref().getId());
                    List<CfAsset> selectedAssets = new ArrayList<>();
                    selectedAssets.clear();
                    if (!selectedlistassets.isEmpty()) {
                        selectedlistassets.stream().map((listcontent) -> cfassetService.findById(listcontent.getCfAssetlistcontentPK().getAssetref())).forEach((selectedContent) -> {
                            if (null != selectedContent) {
                                selectedAssets.add(selectedContent);
                            }
                        });
                    }
                    selectedAssets.stream().forEach((asset) -> {
                        assetlistcontentmap.put(asset.getName(), asset);
                    });
                    attributcontentmap.put(attributcontent.getAttributref().getName(), assetlistcontentmap);
                }
                break;
        }
    }
    /* add keywords  */
    List<CfClasscontentkeyword> contentkeywordlist;
    contentkeywordlist = cfclasscontentkeywordService.findByClassContentRef(classcontent.getId());
    if (!contentkeywordlist.isEmpty()) {
        ArrayList listcontentmap = new ArrayList();
        contentkeywordlist.stream().forEach((contentkeyword) -> {
            listcontentmap.add(cfkeywordService.findById(contentkeyword.getCfClasscontentkeywordPK().getKeywordref()));
        });
        attributcontentmap.put("keywords", listcontentmap);
    }
    return attributcontentmap;
}
Also used : CfAssetlistcontentService(io.clownfish.clownfish.serviceinterface.CfAssetlistcontentService) CfKeywordService(io.clownfish.clownfish.serviceinterface.CfKeywordService) CfListService(io.clownfish.clownfish.serviceinterface.CfListService) CfAttributetype(io.clownfish.clownfish.dbentities.CfAttributetype) Date(java.util.Date) JavaList(io.clownfish.clownfish.beans.JavaList) CfJavaService(io.clownfish.clownfish.serviceinterface.CfJavaService) LoggerFactory(org.slf4j.LoggerFactory) SimpleDateFormat(java.text.SimpleDateFormat) Autowired(org.springframework.beans.factory.annotation.Autowired) CfClasscontent(io.clownfish.clownfish.dbentities.CfClasscontent) CfAsset(io.clownfish.clownfish.dbentities.CfAsset) Scope(org.springframework.context.annotation.Scope) RestContentParameter(io.clownfish.clownfish.datamodels.RestContentParameter) CfClass(io.clownfish.clownfish.dbentities.CfClass) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) LinkedHashMap(java.util.LinkedHashMap) CfJavaversionService(io.clownfish.clownfish.serviceinterface.CfJavaversionService) CfClassService(io.clownfish.clownfish.serviceinterface.CfClassService) CfAttributcontentService(io.clownfish.clownfish.serviceinterface.CfAttributcontentService) Gson(com.google.gson.Gson) Locale(java.util.Locale) Map(java.util.Map) CfClasscontentKeywordService(io.clownfish.clownfish.serviceinterface.CfClasscontentKeywordService) BigInteger(java.math.BigInteger) ParseException(java.text.ParseException) CfAssetlist(io.clownfish.clownfish.dbentities.CfAssetlist) CfAttributService(io.clownfish.clownfish.serviceinterface.CfAttributService) CfListcontentService(io.clownfish.clownfish.serviceinterface.CfListcontentService) CfClasscontentService(io.clownfish.clownfish.serviceinterface.CfClasscontentService) Logger(org.slf4j.Logger) CfAttribut(io.clownfish.clownfish.dbentities.CfAttribut) CfAttributetypeService(io.clownfish.clownfish.serviceinterface.CfAttributetypeService) CfAssetlistService(io.clownfish.clownfish.serviceinterface.CfAssetlistService) IOException(java.io.IOException) CfListcontent(io.clownfish.clownfish.dbentities.CfListcontent) CfAssetlistcontent(io.clownfish.clownfish.dbentities.CfAssetlistcontent) StandardCharsets(java.nio.charset.StandardCharsets) Serializable(java.io.Serializable) CfJava(io.clownfish.clownfish.dbentities.CfJava) List(java.util.List) Component(org.springframework.stereotype.Component) JVMLanguages(io.clownfish.clownfish.compiler.JVMLanguages) CfClasscontentkeyword(io.clownfish.clownfish.dbentities.CfClasscontentkeyword) CfAssetService(io.clownfish.clownfish.serviceinterface.CfAssetService) CfAttributcontent(io.clownfish.clownfish.dbentities.CfAttributcontent) CfList(io.clownfish.clownfish.dbentities.CfList) CfClasscontentkeyword(io.clownfish.clownfish.dbentities.CfClasscontentkeyword) ArrayList(java.util.ArrayList) CfAttribut(io.clownfish.clownfish.dbentities.CfAttribut) CfAttributetype(io.clownfish.clownfish.dbentities.CfAttributetype) CfListcontent(io.clownfish.clownfish.dbentities.CfListcontent) CfClasscontent(io.clownfish.clownfish.dbentities.CfClasscontent) CfAssetlistcontent(io.clownfish.clownfish.dbentities.CfAssetlistcontent) LinkedHashMap(java.util.LinkedHashMap) CfAsset(io.clownfish.clownfish.dbentities.CfAsset) CfAttributcontent(io.clownfish.clownfish.dbentities.CfAttributcontent) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 30 with CfClasscontent

use of io.clownfish.clownfish.dbentities.CfClasscontent in project Clownfish by rawdog71.

the class ConsistencyUtil method checkConsistency.

public void checkConsistency() {
    LOGGER.info("CONSISTENCY CHECK ListContent - START");
    List<CfListcontent> listcontentList = cflistcontentservice.findAll();
    for (CfListcontent listcontent : listcontentList) {
        // Check Classcontent
        try {
            CfClasscontent cc = cfclasscontentservice.findById(listcontent.getCfListcontentPK().getClasscontentref());
        } catch (Exception ex) {
            LOGGER.warn("Classcontent does not exist: " + listcontent.getCfListcontentPK().getClasscontentref());
            cflistcontentservice.delete(listcontent);
        }
        // Check List
        try {
            CfList l = cflistservice.findById(listcontent.getCfListcontentPK().getListref());
        } catch (Exception ex) {
            LOGGER.warn("List does not exist: " + listcontent.getCfListcontentPK().getListref());
            cflistcontentservice.delete(listcontent);
        }
    }
    LOGGER.info("CONSISTENCY CHECK ListContent - END");
    LOGGER.info("CONSISTENCY CHECK AttributContent - START");
    List<CfClasscontent> classcontentlist = cfclasscontentservice.findAll();
    if (!classcontentlist.isEmpty()) {
        long lastId = classcontentlist.get(classcontentlist.size() - 1).getId();
        for (long i = 0; i <= lastId; i++) {
            try {
                CfClasscontent cc = cfclasscontentservice.findById(i);
            } catch (Exception ex) {
                CfClasscontent cc = new CfClasscontent();
                cc.setId(i);
                // System.out.println(i);
                try {
                    List<CfAttributcontent> aclist = cfattributcontentservice.findByClasscontentref(cc);
                } catch (Exception ex2) {
                    cfattributcontentservice.delete(i);
                }
            }
        }
    }
    List<CfList> list = cflistservice.findAll();
    if (!list.isEmpty()) {
        long lastlistId = list.get(list.size() - 1).getId();
        for (long i = 0; i <= lastlistId; i++) {
            try {
                CfList l = cflistservice.findById(i);
            } catch (Exception ex) {
                CfList cl = new CfList();
                cl.setId(i);
                // System.out.println(i);
                try {
                    List<CfAttributcontent> aclist = cfattributcontentservice.findByContentclassRef(cl);
                } catch (Exception ex2) {
                    // System.out.println(i);
                    cfattributcontentservice.updateContentref(i);
                }
            }
        }
    }
    LOGGER.info("CONSISTENCY CHECK AttributContent - END");
}
Also used : CfList(io.clownfish.clownfish.dbentities.CfList) List(java.util.List) CfList(io.clownfish.clownfish.dbentities.CfList) CfListcontent(io.clownfish.clownfish.dbentities.CfListcontent) CfClasscontent(io.clownfish.clownfish.dbentities.CfClasscontent)

Aggregations

CfClasscontent (io.clownfish.clownfish.dbentities.CfClasscontent)45 CfAttributcontent (io.clownfish.clownfish.dbentities.CfAttributcontent)24 CfListcontent (io.clownfish.clownfish.dbentities.CfListcontent)22 CfList (io.clownfish.clownfish.dbentities.CfList)21 Map (java.util.Map)16 ArrayList (java.util.ArrayList)15 HashMap (java.util.HashMap)15 Gson (com.google.gson.Gson)13 CfClass (io.clownfish.clownfish.dbentities.CfClass)13 IOException (java.io.IOException)13 List (java.util.List)12 CfAttributService (io.clownfish.clownfish.serviceinterface.CfAttributService)9 CfAttributcontentService (io.clownfish.clownfish.serviceinterface.CfAttributcontentService)9 CfClassService (io.clownfish.clownfish.serviceinterface.CfClassService)9 CfClasscontentService (io.clownfish.clownfish.serviceinterface.CfClasscontentService)9 Autowired (org.springframework.beans.factory.annotation.Autowired)9 CfAttributetypeService (io.clownfish.clownfish.serviceinterface.CfAttributetypeService)8 CfListService (io.clownfish.clownfish.serviceinterface.CfListService)8 Session (org.hibernate.Session)8 Logger (org.slf4j.Logger)8