use of io.clownfish.clownfish.dbentities.CfTemplate in project Clownfish by rawdog71.
the class TemplateList method onCreate.
@Override
public void onCreate(ActionEvent actionEvent) {
try {
if (!templateName.isBlank()) {
CfTemplate newtemplate = new CfTemplate();
newtemplate.setName(templateName);
newtemplate.setContent("//" + templateName);
newtemplate.setScriptlanguage(templateScriptLanguage);
newtemplate.setLayout(layout);
cftemplateService.create(newtemplate);
templateListe = cftemplateService.findAll();
templateName = "";
selectedTemplate = newtemplate;
refresh();
onSelect(null);
onCheckOut(null);
} else {
FacesMessage message = new FacesMessage("Please enter template name");
FacesContext.getCurrentInstance().addMessage(null, message);
}
} catch (ConstraintViolationException ex) {
LOGGER.error(ex.getMessage());
}
}
use of io.clownfish.clownfish.dbentities.CfTemplate in project Clownfish by rawdog71.
the class CfTemplateDAOImpl method findByName.
@Override
public CfTemplate findByName(String name) {
Session session = this.sessionFactory.getCurrentSession();
TypedQuery query = (TypedQuery) session.getNamedQuery("CfTemplate.findByName");
query.setParameter("name", name);
CfTemplate cftemplate = (CfTemplate) query.getSingleResult();
return cftemplate;
}
use of io.clownfish.clownfish.dbentities.CfTemplate in project Clownfish by rawdog71.
the class CfTemplateDAOImpl method findAll.
@Override
public List<CfTemplate> findAll() {
Session session = this.sessionFactory.getCurrentSession();
TypedQuery query = (TypedQuery) session.getNamedQuery("CfTemplate.findAll");
List<CfTemplate> cftempaltelist = query.getResultList();
return cftempaltelist;
}
use of io.clownfish.clownfish.dbentities.CfTemplate in project Clownfish by rawdog71.
the class TemplateUtil method fetchIncludes.
public String fetchIncludes(String content, ClownfishConst.ViewModus modus) {
Pattern pattern = Pattern.compile("(\\[\\[\\*).+(\\*\\]\\])");
Matcher matcher = pattern.matcher(content);
while (matcher.find()) {
String templatename = content.substring((matcher.start() + 3), (matcher.end() - 3));
String lastmatch = content.substring(matcher.start(), matcher.end());
try {
// Hole das Template über den Namen
CfTemplate cftemplate = cftemplateService.findByName(templatename);
if (DEVELOPMENT == modus) {
content = content.replace(lastmatch, cftemplate.getContent());
} else {
long currentTemplateVersion;
try {
currentTemplateVersion = (long) cftemplateversionService.findMaxVersion(cftemplate.getId());
} catch (NullPointerException ex) {
currentTemplateVersion = 0;
}
content = content.replace(lastmatch, getVersion(cftemplate.getId(), currentTemplateVersion));
}
matcher = pattern.matcher(content);
} catch (NoResultException ex) {
content = matcher.replaceFirst("");
}
}
return content;
}
Aggregations