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;
023
024import java.util.HashMap;
025import java.util.Map;
026import java.util.Set;
027
028import org.nuxeo.common.xmap.annotation.XNode;
029import org.nuxeo.common.xmap.annotation.XNodeMap;
030import org.nuxeo.common.xmap.annotation.XObject;
031import org.nuxeo.runtime.api.Framework;
032import org.nuxeo.theme.types.Type;
033import org.nuxeo.theme.types.TypeFamily;
034
035@XObject("application")
036public final class ApplicationType implements Type {
037
038    private String root;
039
040    @XNode("@template-engine")
041    private String templateEngine;
042
043    @XNode("negotiation")
044    private NegotiationDef negotiation;
045
046    @XNode("resource-caching")
047    private CachingDef resourceCaching;
048
049    @XNode("style-caching")
050    private CachingDef styleCaching;
051
052    @XNodeMap(value = "view", key = "@id", type = HashMap.class, componentType = ViewDef.class)
053    private Map<String, ViewDef> viewDefs;
054
055    public TypeFamily getTypeFamily() {
056        return TypeFamily.APPLICATION;
057    }
058
059    public String getTypeName() {
060        return root;
061    }
062
063    public CachingDef getResourceCaching() {
064        return resourceCaching;
065    }
066
067    public CachingDef getStyleCaching() {
068        return styleCaching;
069    }
070
071    public Set<String> getViewIds() {
072        return viewDefs.keySet();
073    }
074
075    public ViewDef getViewById(String id) {
076        return viewDefs.get(id);
077    }
078
079    public NegotiationDef getNegotiation() {
080        return negotiation;
081    }
082
083    public String getRoot() {
084        return root;
085    }
086
087    @XNode("@root")
088    public void setRoot(final String root) {
089        this.root = Framework.expandVars(root);
090    }
091
092    public Map<String, ViewDef> getViewDefs() {
093        return viewDefs;
094    }
095
096    public void setViewDefs(final Map<String, ViewDef> viewDefs) {
097        this.viewDefs = viewDefs;
098    }
099
100    public void setNegotiation(final NegotiationDef negotiation) {
101        this.negotiation = negotiation;
102    }
103
104    public void setResourceCaching(final CachingDef resourceCaching) {
105        this.resourceCaching = resourceCaching;
106    }
107
108    public void setStyleCaching(final CachingDef styleCaching) {
109        this.styleCaching = styleCaching;
110    }
111
112    public String getTemplateEngine() {
113        return templateEngine;
114    }
115
116    public void setTemplateEngine(String templateEngine) {
117        this.templateEngine = templateEngine;
118    }
119
120}