1 13 package org.jahia.services.fields; 14 15 import org.jahia.data.ConnectionTypes; 16 import org.jahia.exceptions.JahiaException; 17 import org.jahia.params.ParamBean; 18 import org.jahia.services.version.ActivationTestResults; 19 import org.jahia.services.version.ContentObjectEntryState; 20 import org.jahia.services.version.EntrySaveRequest; 21 import org.jahia.services.version.StateModificationContext; 22 import org.jahia.utils.xml.XMLSerializationOptions; 23 import org.jahia.utils.xml.XmlWriter; 24 25 import java.util.Hashtable ; 26 import java.util.Set ; 27 import java.util.Vector ; 28 29 public class ContentBooleanField extends ContentField implements ContentSimpleField { 30 private static org.apache.log4j.Logger logger 31 = org.apache.log4j.Logger.getLogger (ContentBooleanField.class); 32 33 protected ContentBooleanField (Integer ID, 35 Integer jahiaID, 36 Integer pageID, 37 Integer ctnid, 38 Integer fieldDefID, 39 Integer fieldType, 40 Integer connectType, 41 Integer aclID, 42 Vector activeAndStagingEntryStates, 43 Hashtable activeAndStagedDBValues) { 44 super (ID.intValue (), jahiaID.intValue (), pageID.intValue (), 45 ctnid.intValue (), fieldDefID.intValue (), fieldType.intValue (), 46 connectType.intValue (), aclID.intValue (), 47 activeAndStagingEntryStates, activeAndStagedDBValues); 48 } 49 50 public static synchronized ContentBooleanField 52 createBoolean (int siteID, 53 int pageID, 54 int containerID, 55 int fieldDefID, 56 int parentAclID, int aclID, 57 boolean value, 58 ParamBean jParams) 59 throws JahiaException { 60 ContentBooleanField result = 61 (ContentBooleanField) 62 ContentField.createField (siteID, pageID, containerID, 63 fieldDefID, ContentFieldTypes.BOOLEAN, 64 ConnectionTypes.LOCAL, parentAclID, 65 aclID); 66 67 EntrySaveRequest saveRequest = 68 new EntrySaveRequest (jParams.getUser (), 69 ContentField.SHARED_LANGUAGE); 70 71 result.setValue (value, saveRequest); 72 return result; 73 } 74 75 83 public String getValue (ParamBean jParams, 84 ContentObjectEntryState entryState) 85 throws JahiaException { 86 return getDBValue (entryState); 88 } 89 90 95 public void setValue (boolean value, 96 EntrySaveRequest saveRequest) 97 throws JahiaException { 98 99 preSet ((value) ? "true" : "false", saveRequest); 100 101 } 102 103 112 public String getValueForSearch (ParamBean jParams, 113 ContentObjectEntryState entryState) 114 throws JahiaException { 115 return getDBValue (entryState); 117 } 118 119 136 public ActivationTestResults changeEntryState (ContentObjectEntryState fromEntryState, 137 ContentObjectEntryState toEntryState, 138 ParamBean jParams, 139 StateModificationContext stateModifContext) 140 throws JahiaException { 141 return new ActivationTestResults (); 142 } 143 144 protected ActivationTestResults isContentValidForActivation ( 146 Set languageCodes, 147 ParamBean jParams, 148 StateModificationContext stateModifContext) 149 throws JahiaException { 150 151 return new ActivationTestResults (); 152 } 153 154 159 public boolean isShared () { 160 return true; 161 } 162 163 184 protected void serializeContentToXML (XmlWriter xmlWriter, 185 XMLSerializationOptions 186 xmlSerializationOptions, 187 ContentObjectEntryState entryState, 188 ParamBean paramBean) 189 throws java.io.IOException { 190 try { 191 String result = getDBValue (entryState); 193 xmlWriter.writeText (result); 194 } catch (JahiaException je) { 195 logger.debug ("Error while serializing small text field to XML : ", je); 196 } 197 } 198 199 200 } 201 | Popular Tags |