001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS <http://nuxeo.com> and others
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Jean-Marc Orliaguet, Chalmers
011 *
012 * $Id$
013 */
014
015package org.nuxeo.theme;
016
017import java.util.HashMap;
018import java.util.Map;
019import java.util.Set;
020
021import org.nuxeo.common.xmap.annotation.XNode;
022import org.nuxeo.common.xmap.annotation.XNodeMap;
023import org.nuxeo.common.xmap.annotation.XObject;
024import org.nuxeo.runtime.api.Framework;
025import org.nuxeo.theme.types.Type;
026import org.nuxeo.theme.types.TypeFamily;
027
028@XObject("application")
029public final class ApplicationType implements Type {
030
031    private String root;
032
033    @XNode("@template-engine")
034    private String templateEngine;
035
036    @XNode("negotiation")
037    private NegotiationDef negotiation;
038
039    @XNode("resource-caching")
040    private CachingDef resourceCaching;
041
042    @XNode("style-caching")
043    private CachingDef styleCaching;
044
045    @XNodeMap(value = "view", key = "@id", type = HashMap.class, componentType = ViewDef.class)
046    private Map<String, ViewDef> viewDefs;
047
048    public TypeFamily getTypeFamily() {
049        return TypeFamily.APPLICATION;
050    }
051
052    public String getTypeName() {
053        return root;
054    }
055
056    public CachingDef getResourceCaching() {
057        return resourceCaching;
058    }
059
060    public CachingDef getStyleCaching() {
061        return styleCaching;
062    }
063
064    public Set<String> getViewIds() {
065        return viewDefs.keySet();
066    }
067
068    public ViewDef getViewById(String id) {
069        return viewDefs.get(id);
070    }
071
072    public NegotiationDef getNegotiation() {
073        return negotiation;
074    }
075
076    public String getRoot() {
077        return root;
078    }
079
080    @XNode("@root")
081    public void setRoot(final String root) {
082        this.root = Framework.expandVars(root);
083    }
084
085    public Map<String, ViewDef> getViewDefs() {
086        return viewDefs;
087    }
088
089    public void setViewDefs(final Map<String, ViewDef> viewDefs) {
090        this.viewDefs = viewDefs;
091    }
092
093    public void setNegotiation(final NegotiationDef negotiation) {
094        this.negotiation = negotiation;
095    }
096
097    public void setResourceCaching(final CachingDef resourceCaching) {
098        this.resourceCaching = resourceCaching;
099    }
100
101    public void setStyleCaching(final CachingDef styleCaching) {
102        this.styleCaching = styleCaching;
103    }
104
105    public String getTemplateEngine() {
106        return templateEngine;
107    }
108
109    public void setTemplateEngine(String templateEngine) {
110        this.templateEngine = templateEngine;
111    }
112
113}