001/* 002 * (C) Copyright 2012 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 * Antoine Taillefer 018 */ 019package org.nuxeo.ecm.diff.service.impl; 020 021import java.io.Serializable; 022import java.util.ArrayList; 023import java.util.HashMap; 024import java.util.List; 025import java.util.Map; 026 027import org.nuxeo.common.xmap.annotation.XNode; 028import org.nuxeo.common.xmap.annotation.XNodeList; 029import org.nuxeo.common.xmap.annotation.XNodeMap; 030import org.nuxeo.common.xmap.annotation.XObject; 031import org.nuxeo.ecm.platform.forms.layout.api.BuiltinModes; 032import org.nuxeo.ecm.platform.forms.layout.descriptors.PropertiesDescriptor; 033import org.nuxeo.ecm.platform.forms.layout.descriptors.WidgetDescriptor; 034 035/** 036 * Diff block descriptor. 037 * 038 * @author <a href="mailto:ataillefer@nuxeo.com">Antoine Taillefer</a> 039 * @since 5.6 040 */ 041@XObject("diffBlock") 042public class DiffBlockDescriptor { 043 044 @XNode("@name") 045 public String name; 046 047 @XNodeMap(value = "templates/template", key = "@mode", type = HashMap.class, componentType = String.class) 048 Map<String, String> templates = new HashMap<String, String>(); 049 050 @XNodeList(value = "fields/field", type = ArrayList.class, componentType = DiffFieldDescriptor.class) 051 public List<DiffFieldDescriptor> fields; 052 053 @XNodeMap(value = "properties", key = "@mode", type = HashMap.class, componentType = PropertiesDescriptor.class) 054 Map<String, PropertiesDescriptor> properties = new HashMap<String, PropertiesDescriptor>(); 055 056 public String getName() { 057 return name; 058 } 059 060 public void setName(String name) { 061 this.name = name; 062 } 063 064 public String getTemplate(String mode) { 065 String template = templates.get(mode); 066 if (template == null) { 067 template = templates.get(BuiltinModes.ANY); 068 } 069 return template; 070 } 071 072 public Map<String, String> getTemplates() { 073 return templates; 074 } 075 076 public void setTemplates(Map<String, String> templates) { 077 this.templates = templates; 078 } 079 080 public List<DiffFieldDescriptor> getFields() { 081 return fields; 082 } 083 084 public void setFields(List<DiffFieldDescriptor> fields) { 085 this.fields = fields; 086 } 087 088 public Map<String, Serializable> getProperties(String layoutMode) { 089 return WidgetDescriptor.getProperties(properties, layoutMode); 090 } 091 092 public Map<String, Map<String, Serializable>> getProperties() { 093 return WidgetDescriptor.getProperties(properties); 094 } 095 096 public void setProperties(Map<String, PropertiesDescriptor> properties) { 097 this.properties = properties; 098 } 099}