1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.model.support;
14
15 import java.util.Collection;
16 import java.util.List;
17 import java.util.Map;
18 import java.util.Set;
19
20 import org.apache.log4j.Logger;
21
22 import com.eviware.soapui.SoapUI;
23 import com.eviware.soapui.config.PropertiesTypeConfig;
24 import com.eviware.soapui.impl.wsdl.MutableTestPropertyHolder;
25 import com.eviware.soapui.impl.wsdl.support.XmlBeansPropertiesTestPropertyHolder;
26 import com.eviware.soapui.impl.wsdl.support.XmlBeansPropertiesTestPropertyHolder.PropertiesStepProperty;
27 import com.eviware.soapui.model.ModelItem;
28 import com.eviware.soapui.model.settings.Settings;
29 import com.eviware.soapui.model.testsuite.TestProperty;
30 import com.eviware.soapui.model.testsuite.TestPropertyListener;
31 import com.eviware.soapui.settings.GlobalPropertySettings;
32 import com.eviware.soapui.support.StringUtils;
33
34 public class SettingsTestPropertyHolder implements MutableTestPropertyHolder, Map<String, TestProperty>
35 {
36 public final static Logger log = Logger.getLogger( SettingsTestPropertyHolder.class );
37 private XmlBeansPropertiesTestPropertyHolder propertyHolderSupport;
38 private PropertiesTypeConfig config;
39 private final ModelItem modelItem;
40 private String propertiesLabel = "Test Properties";
41
42 public SettingsTestPropertyHolder( Settings settings, ModelItem modelItem )
43 {
44 this.modelItem = modelItem;
45 config = PropertiesTypeConfig.Factory.newInstance();
46 try
47 {
48 String str = settings.getString( GlobalPropertySettings.PROPERTIES, null );
49 if( StringUtils.hasContent( str ) )
50 config = PropertiesTypeConfig.Factory.parse( str );
51 }
52 catch( Exception e )
53 {
54 SoapUI.logError( e );
55 }
56
57 propertyHolderSupport = new XmlBeansPropertiesTestPropertyHolder( null, config );
58 }
59
60 public TestProperty addProperty( String name )
61 {
62 return propertyHolderSupport.addProperty( name );
63 }
64
65 public void addTestPropertyListener( TestPropertyListener listener )
66 {
67 propertyHolderSupport.addTestPropertyListener( listener );
68 }
69
70 public Map<String, TestProperty> getProperties()
71 {
72 return propertyHolderSupport.getProperties();
73 }
74
75 public PropertiesStepProperty getProperty( String name )
76 {
77 return propertyHolderSupport.getProperty( name );
78 }
79
80 public String[] getPropertyNames()
81 {
82 return propertyHolderSupport.getPropertyNames();
83 }
84
85 public String getPropertyValue( String name )
86 {
87 return propertyHolderSupport.getPropertyValue( name );
88 }
89
90 public boolean hasProperty( String name )
91 {
92 return propertyHolderSupport.hasProperty( name );
93 }
94
95 public TestProperty removeProperty( String propertyName )
96 {
97 return propertyHolderSupport.removeProperty( propertyName );
98 }
99
100 public void removeTestPropertyListener( TestPropertyListener listener )
101 {
102 propertyHolderSupport.removeTestPropertyListener( listener );
103 }
104
105 public boolean renameProperty( String name, String newName )
106 {
107 return propertyHolderSupport.renameProperty( name, newName );
108 }
109
110 public void saveTo( Settings settings )
111 {
112 settings.setString( GlobalPropertySettings.PROPERTIES, config.toString() );
113 }
114
115 public void setPropertyValue( String name, String value )
116 {
117 propertyHolderSupport.setPropertyValue( name, value );
118 }
119
120 public int addPropertiesFromFile( String propFile )
121 {
122 return propertyHolderSupport.addPropertiesFromFile( propFile );
123 }
124
125 public ModelItem getModelItem()
126 {
127 return modelItem;
128 }
129
130 public void moveProperty( String propertyName, int targetIndex )
131 {
132 propertyHolderSupport.moveProperty( propertyName, targetIndex );
133 }
134
135 public TestProperty getPropertyAt( int index )
136 {
137 return propertyHolderSupport.getPropertyAt( index );
138 }
139
140 public int getPropertyCount()
141 {
142 return propertyHolderSupport.getPropertyCount();
143 }
144
145 public void clear()
146 {
147 propertyHolderSupport.clear();
148 }
149
150 public boolean containsKey( Object key )
151 {
152 return propertyHolderSupport.containsKey( key );
153 }
154
155 public boolean containsValue( Object value )
156 {
157 return propertyHolderSupport.containsValue( value );
158 }
159
160 public Set<java.util.Map.Entry<String, TestProperty>> entrySet()
161 {
162 return propertyHolderSupport.entrySet();
163 }
164
165 public TestProperty get( Object key )
166 {
167 return propertyHolderSupport.get( key );
168 }
169
170 public boolean isEmpty()
171 {
172 return propertyHolderSupport.isEmpty();
173 }
174
175 public Set<String> keySet()
176 {
177 return propertyHolderSupport.keySet();
178 }
179
180 public TestProperty put( String key, TestProperty value )
181 {
182 return propertyHolderSupport.put( key, value );
183 }
184
185 public void putAll( Map<? extends String, ? extends TestProperty> m )
186 {
187 propertyHolderSupport.putAll( m );
188 }
189
190 public TestProperty remove( Object key )
191 {
192 return propertyHolderSupport.remove( key );
193 }
194
195 public int size()
196 {
197 return propertyHolderSupport.size();
198 }
199
200 public Collection<TestProperty> values()
201 {
202 return propertyHolderSupport.values();
203 }
204
205 public String getPropertiesLabel()
206 {
207 return propertiesLabel;
208 }
209
210 public void setPropertiesLabel( String propertiesLabel )
211 {
212 this.propertiesLabel = propertiesLabel;
213 }
214
215 public List<TestProperty> getPropertyList()
216 {
217 return propertyHolderSupport.getPropertyList();
218 }
219 }