001/* 002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Antoine Taillefer 016 */ 017package org.nuxeo.ecm.diff.service.impl; 018 019import java.io.Serializable; 020import java.util.ArrayList; 021import java.util.HashMap; 022import java.util.List; 023import java.util.Map; 024 025import org.nuxeo.common.xmap.annotation.XNode; 026import org.nuxeo.common.xmap.annotation.XNodeList; 027import org.nuxeo.common.xmap.annotation.XNodeMap; 028import org.nuxeo.common.xmap.annotation.XObject; 029import org.nuxeo.ecm.platform.forms.layout.api.BuiltinModes; 030import org.nuxeo.ecm.platform.forms.layout.descriptors.PropertiesDescriptor; 031import org.nuxeo.ecm.platform.forms.layout.descriptors.WidgetDescriptor; 032 033/** 034 * Diff block descriptor. 035 * 036 * @author <a href="mailto:ataillefer@nuxeo.com">Antoine Taillefer</a> 037 * @since 5.6 038 */ 039@XObject("diffBlock") 040public class DiffBlockDescriptor { 041 042 @XNode("@name") 043 public String name; 044 045 @XNodeMap(value = "templates/template", key = "@mode", type = HashMap.class, componentType = String.class) 046 Map<String, String> templates = new HashMap<String, String>(); 047 048 @XNodeList(value = "fields/field", type = ArrayList.class, componentType = DiffFieldDescriptor.class) 049 public List<DiffFieldDescriptor> fields; 050 051 @XNodeMap(value = "properties", key = "@mode", type = HashMap.class, componentType = PropertiesDescriptor.class) 052 Map<String, PropertiesDescriptor> properties = new HashMap<String, PropertiesDescriptor>(); 053 054 public String getName() { 055 return name; 056 } 057 058 public void setName(String name) { 059 this.name = name; 060 } 061 062 public String getTemplate(String mode) { 063 String template = templates.get(mode); 064 if (template == null) { 065 template = templates.get(BuiltinModes.ANY); 066 } 067 return template; 068 } 069 070 public Map<String, String> getTemplates() { 071 return templates; 072 } 073 074 public void setTemplates(Map<String, String> templates) { 075 this.templates = templates; 076 } 077 078 public List<DiffFieldDescriptor> getFields() { 079 return fields; 080 } 081 082 public void setFields(List<DiffFieldDescriptor> fields) { 083 this.fields = fields; 084 } 085 086 public Map<String, Serializable> getProperties(String layoutMode) { 087 return WidgetDescriptor.getProperties(properties, layoutMode); 088 } 089 090 public Map<String, Map<String, Serializable>> getProperties() { 091 return WidgetDescriptor.getProperties(properties); 092 } 093 094 public void setProperties(Map<String, PropertiesDescriptor> properties) { 095 this.properties = properties; 096 } 097}