use of io.clownfish.clownfish.dbentities.CfAssetlist in project Clownfish by rawdog71.
the class CfAssetlistDAOImpl method findByName.
@Override
public CfAssetlist findByName(String name) {
Session session = this.sessionFactory.getCurrentSession();
TypedQuery query = (TypedQuery) session.getNamedQuery("CfAssetlist.findByName");
query.setParameter("name", name);
CfAssetlist cfassetlist = (CfAssetlist) query.getSingleResult();
return cfassetlist;
}
use of io.clownfish.clownfish.dbentities.CfAssetlist in project Clownfish by rawdog71.
the class ContentUtil method setAttributValue.
public CfAttributcontent setAttributValue(CfAttributcontent selectedAttribut, String editContent) {
if (null == editContent) {
editContent = "";
}
try {
switch(selectedAttribut.getAttributref().getAttributetype().getName()) {
case "boolean":
selectedAttribut.setContentBoolean(Boolean.valueOf(editContent));
break;
case "string":
if (editContent.length() > 255) {
editContent = editContent.substring(0, 255);
}
if (selectedAttribut.getAttributref().getIdentity() == true) {
List<CfClasscontent> classcontentlist2 = cfclasscontentService.findByClassref(selectedAttribut.getClasscontentref().getClassref());
boolean found = false;
for (CfClasscontent classcontent : classcontentlist2) {
try {
CfAttributcontent attributcontent = cfattributcontentService.findByAttributrefAndClasscontentref(selectedAttribut.getAttributref(), classcontent);
if (attributcontent.getContentString().compareToIgnoreCase(editContent) == 0) {
found = true;
}
} catch (javax.persistence.NoResultException | NullPointerException ex) {
LOGGER.error(ex.getMessage());
}
}
if (!found) {
selectedAttribut.setContentString(editContent);
}
} else {
selectedAttribut.setContentString(editContent);
}
break;
case "hashstring":
String salt = PasswordUtil.getSalt(30);
selectedAttribut.setContentString(PasswordUtil.generateSecurePassword(editContent, salt));
selectedAttribut.setSalt(salt);
break;
case "integer":
selectedAttribut.setContentInteger(BigInteger.valueOf(Long.parseLong(editContent)));
break;
case "real":
selectedAttribut.setContentReal(Double.parseDouble(editContent));
break;
case "htmltext":
selectedAttribut.setContentText(editContent);
break;
case "text":
selectedAttribut.setContentText(editContent);
break;
case "markdown":
selectedAttribut.setContentText(editContent);
break;
case "datetime":
Date datum;
DateTimeFormatter fmt = DateTimeFormat.forPattern("dd.MM.yyyy").withZone(DateTimeZone.forID("Europe/Berlin"));
try {
datum = DateTime.parse(editContent, fmt).toDate();
selectedAttribut.setContentDate(datum);
} catch (IllegalArgumentException ex) {
try {
fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS").withZone(DateTimeZone.forID("Europe/Berlin"));
datum = DateTime.parse(editContent, fmt).toDate();
selectedAttribut.setContentDate(datum);
} catch (IllegalArgumentException ex2) {
fmt = DateTimeFormat.forPattern("dd.MM.yyyy HH:mm:ss").withZone(DateTimeZone.forID("Europe/Berlin"));
datum = DateTime.parse(editContent, fmt).toDate();
selectedAttribut.setContentDate(datum);
}
}
break;
case "media":
if (null != editContent) {
try {
CfAsset asset = cfassetService.findByName(editContent);
selectedAttribut.setContentInteger(BigInteger.valueOf(asset.getId()));
} catch (Exception ex) {
selectedAttribut.setContentInteger(null);
LOGGER.error("INSERTCONTENT: Media " + editContent + " not found!");
}
} else {
selectedAttribut.setContentInteger(null);
}
break;
case "classref":
if (null != editContent) {
CfList list_ref = cflistService.findById(Long.parseLong(editContent));
selectedAttribut.setClasscontentlistref(list_ref);
}
break;
case "assetref":
if (null != editContent) {
CfAssetlist assetlist_ref = cfassetlistService.findById(Long.parseLong(editContent));
selectedAttribut.setAssetcontentlistref(assetlist_ref);
}
break;
}
selectedAttribut.setIndexed(false);
return selectedAttribut;
} catch (NullPointerException ex) {
LOGGER.warn(ex.getMessage());
return selectedAttribut;
}
}
use of io.clownfish.clownfish.dbentities.CfAssetlist in project Clownfish by rawdog71.
the class SiteUtil method getSiteAssetlibrary.
public Map getSiteAssetlibrary(CfSite cfsite, Map sitecontentmap) {
List<CfSiteassetlist> siteassetlibrary = new ArrayList<>();
siteassetlibrary.addAll(cfsiteassetlistService.findBySiteref(cfsite.getId()));
HashMap<String, ArrayList> assetlibraryMap = new HashMap<>();
for (CfSiteassetlist siteassetlist : siteassetlibrary) {
CfAssetlist cfassetlist = cfassetlistService.findById(siteassetlist.getCfSiteassetlistPK().getAssetlistref());
List<CfAssetlistcontent> assetlist = new ArrayList<>();
assetlist.addAll(cfassetlistcontentService.findByAssetlistref(cfassetlist.getId()));
ArrayList<CfAsset> dummyassetlist = new ArrayList<>();
for (CfAssetlistcontent assetcontent : assetlist) {
CfAsset asset = cfassetService.findById(assetcontent.getCfAssetlistcontentPK().getAssetref());
if (null != asset) {
dummyassetlist.add(asset);
} else {
LOGGER.warn("ASSET NOT FOUND (deleted or on scrapyard): " + assetcontent.getCfAssetlistcontentPK().getAssetref());
}
}
assetlibraryMap.put(cfassetlist.getName(), dummyassetlist);
}
sitecontentmap.put("AssetLibrary", assetlibraryMap);
return sitecontentmap;
}
use of io.clownfish.clownfish.dbentities.CfAssetlist in project Clownfish by rawdog71.
the class ClassUtil method jsonImport.
public List<CfAttributcontent> jsonImport(String jsoncontent) {
ArrayList<CfAttributcontent> attributcontentlist = new ArrayList<>();
Gson gson = new Gson();
RestContentParameter contentparameter = gson.fromJson(jsoncontent, RestContentParameter.class);
CfClass clazz = cfclassService.findByName(contentparameter.getClassname());
List<CfAttribut> attributlist = cfattributService.findByClassref(clazz);
for (String key : contentparameter.getAttributmap().keySet()) {
CfAttribut attribut = getAttributFromAttributlist(attributlist, key);
CfAttributcontent attributcontent = new CfAttributcontent();
attributcontent.setAttributref(attribut);
switch(attribut.getAttributetype().getName()) {
case "boolean":
attributcontent.setContentBoolean(true);
break;
case "string":
case "hashstring":
attributcontent.setContentString(contentparameter.getAttributmap().get(key));
break;
case "integer":
attributcontent.setContentInteger(BigInteger.valueOf(Long.parseLong(contentparameter.getAttributmap().get(key))));
break;
case "real":
attributcontent.setContentReal(Double.parseDouble(contentparameter.getAttributmap().get(key)));
break;
case "htmltext":
case "text":
case "markdown":
attributcontent.setContentText(contentparameter.getAttributmap().get(key));
break;
case "datetime":
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.GERMAN);
Date date;
try {
date = formatter.parse(contentparameter.getAttributmap().get(key));
attributcontent.setContentDate(date);
} catch (ParseException ex) {
java.util.logging.Logger.getLogger(ClassUtil.class.getName()).log(Level.SEVERE, null, ex);
}
break;
case "media":
CfAsset asset = cfassetService.findByName(contentparameter.getAttributmap().get(key));
attributcontent.setContentInteger(BigInteger.valueOf(asset.getId()));
break;
case "classref":
try {
CfList list = cflistService.findByName(contentparameter.getAttributmap().get(key));
attributcontent.setClasscontentlistref(list);
} catch (Exception ex) {
attributcontent.setClasscontentlistref(null);
}
break;
case "assetref":
try {
CfAssetlist assetlist = cfassetlistService.findByName(contentparameter.getAttributmap().get(key));
attributcontent.setAssetcontentlistref(assetlist);
} catch (Exception ex) {
attributcontent.setAssetcontentlistref(null);
}
break;
}
attributcontentlist.add(attributcontent);
}
return attributcontentlist;
}
use of io.clownfish.clownfish.dbentities.CfAssetlist 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);
}
Aggregations