001/* 002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Jean-Marc Orliaguet, Chalmers 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.theme.rendering; 023 024import java.net.URL; 025 026import org.nuxeo.theme.Manager; 027import org.nuxeo.theme.elements.Element; 028import org.nuxeo.theme.elements.ThemeElement; 029import org.nuxeo.theme.engines.EngineType; 030import org.nuxeo.theme.formats.Format; 031import org.nuxeo.theme.models.Info; 032import org.nuxeo.theme.models.Model; 033import org.nuxeo.theme.templates.TemplateEngineType; 034import org.nuxeo.theme.themes.ThemeManager; 035import org.nuxeo.theme.uids.Identifiable; 036 037public class RenderingInfo implements Info, Identifiable { 038 039 private String markup = ""; 040 041 private Model model; 042 043 private Element element; 044 045 private Format format; 046 047 private Integer uid; 048 049 private String name; 050 051 private URL themeUrl; 052 053 private boolean dirty = false; 054 055 public RenderingInfo() { 056 } 057 058 public RenderingInfo(Element element, URL themeUrl) { 059 this.element = element; 060 this.themeUrl = themeUrl; 061 uid = element.getUid(); 062 } 063 064 public RenderingInfo createCopy() { 065 RenderingInfo clone = new RenderingInfo(element, themeUrl); 066 clone.setDirty(dirty); 067 return clone; 068 } 069 070 public Model getModel() { 071 return model; 072 } 073 074 public void setModel(Model model) { 075 this.model = model; 076 } 077 078 public String getMarkup() { 079 return markup; 080 } 081 082 public void setMarkup(String markup) { 083 this.markup = markup; 084 } 085 086 public Integer getUid() { 087 return uid; 088 } 089 090 public void setUid(Integer uid) { 091 this.uid = uid; 092 } 093 094 public EngineType getEngine() { 095 return ThemeManager.getEngineByUrl(themeUrl); 096 } 097 098 public String getViewMode() { 099 return ThemeManager.getViewModeByUrl(themeUrl); 100 } 101 102 public String getCollection() { 103 return ThemeManager.getCollectionNameByUrl(themeUrl); 104 } 105 106 public URL getThemeUrl() { 107 return themeUrl; 108 } 109 110 public Element getElement() { 111 return element; 112 } 113 114 public void setFormat(Format format) { 115 this.format = format; 116 } 117 118 public Format getFormat() { 119 return format; 120 } 121 122 public boolean isDirty() { 123 return dirty; 124 } 125 126 public void setDirty(boolean dirty) { 127 this.dirty = dirty; 128 } 129 130 public String getName() { 131 return name; 132 } 133 134 public void setName(String name) { 135 this.name = name; 136 } 137 138 public ThemeElement getTheme() { 139 return Manager.getThemeManager().getThemeByUrl(themeUrl); 140 } 141 142 public TemplateEngineType getTemplateEngine() { 143 return ThemeManager.getTemplateEngineByUrl(themeUrl); 144 } 145 146 public boolean isRenderingPostponed(boolean cache) { 147 return cache && isDirty(); 148 } 149 150}