Search in sources :

Example 6 with CfTemplate

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());
    }
}
Also used : ConstraintViolationException(jakarta.validation.ConstraintViolationException) FacesMessage(javax.faces.application.FacesMessage) CfTemplate(io.clownfish.clownfish.dbentities.CfTemplate)

Example 7 with CfTemplate

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;
}
Also used : TypedQuery(javax.persistence.TypedQuery) Session(org.hibernate.Session) CfTemplate(io.clownfish.clownfish.dbentities.CfTemplate)

Example 8 with 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;
}
Also used : TypedQuery(javax.persistence.TypedQuery) Session(org.hibernate.Session) CfTemplate(io.clownfish.clownfish.dbentities.CfTemplate)

Example 9 with CfTemplate

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;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) NoResultException(javax.persistence.NoResultException) CfTemplate(io.clownfish.clownfish.dbentities.CfTemplate)

Aggregations

CfTemplate (io.clownfish.clownfish.dbentities.CfTemplate)9 FacesMessage (javax.faces.application.FacesMessage)3 TypedQuery (javax.persistence.TypedQuery)3 Session (org.hibernate.Session)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Gson (com.google.gson.Gson)1 SAPConnection (de.destrukt.sapconnection.SAPConnection)1 ParseException (freemarker.core.ParseException)1 MalformedTemplateNameException (freemarker.template.MalformedTemplateNameException)1 CfDiv (io.clownfish.clownfish.datamodels.CfDiv)1 CfLayout (io.clownfish.clownfish.datamodels.CfLayout)1 TemplateDataOutput (io.clownfish.clownfish.datamodels.TemplateDataOutput)1 CfAssetlist (io.clownfish.clownfish.dbentities.CfAssetlist)1 CfClasscontent (io.clownfish.clownfish.dbentities.CfClasscontent)1 CfDatasource (io.clownfish.clownfish.dbentities.CfDatasource)1 CfJavascript (io.clownfish.clownfish.dbentities.CfJavascript)1 CfKeywordlist (io.clownfish.clownfish.dbentities.CfKeywordlist)1 CfList (io.clownfish.clownfish.dbentities.CfList)1 CfSite (io.clownfish.clownfish.dbentities.CfSite)1