1515import org .apache .ws .commons .util .NamespaceContextImpl ;
1616import org .apache .xmlrpc .XmlRpcException ;
1717
18+ import sun .reflect .generics .reflectiveObjects .NotImplementedException ;
19+
1820/**
1921 * Shotgun XML-RPC API Wrapper
2022 *
@@ -194,7 +196,97 @@ public boolean delete(DeleteRequest dr) throws XmlRpcException {
194196
195197 return (didDelete .equals (Boolean .TRUE ));
196198 }
197-
199+
200+ /**
201+ * Return the shotgun schema
202+ *
203+ * Well, it would but can't figure out how to pass no arguments through java xmlrpc
204+ * @return
205+ * @throws XmlRpcException if the request failed
206+ */
207+ public Map schema_read () throws XmlRpcException {
208+ throw new NotImplementedException ();
209+ /**
210+ Object[] params = new Object[] { this.auth, new HashMap()};
211+ Map response = (Map)this.client.execute("schema_read", params);
212+ Map results = (Map)response.get("results");
213+ return results;
214+ **/
215+ }
216+
217+ public Map schema_field_read (String entity_type , String field_name ) throws XmlRpcException {
218+ HashMap req = new HashMap ();
219+ req .put ("type" , entity_type );
220+ if (field_name != null )
221+ req .put ("field_name" , field_name );
222+ Object [] params = new Object [] { this .auth , req };
223+ Map response = (Map )this .client .execute ("schema_field_read" , params );
224+ Map results = (Map )response .get ("results" );
225+ return results ;
226+ }
227+
228+ public String schema_field_create (String entity_type , String data_type , String display_name ,
229+ Map properties ) throws XmlRpcException {
230+ if (properties == null )
231+ properties = new HashMap ();
232+ List fields = new ArrayList ();
233+
234+ HashMap rf = new HashMap ();
235+ rf .put ("property_name" , "name" );
236+ rf .put ("value" , display_name );
237+ fields .add (rf );
238+ for ( Iterator iter = properties .entrySet ().iterator (); iter .hasNext (); ) {
239+ Entry e = (Entry )iter .next ();
240+ rf = new HashMap ();
241+ String key = (String )e .getKey ();
242+ rf .put ("property_name" , key );
243+ rf .put ("value" , e .getValue ());
244+ fields .add (rf );
245+ }
246+ HashMap req = new HashMap ();
247+ req .put ("type" , entity_type );
248+ req .put ("data_type" , data_type );
249+ req .put ("properties" , fields );
250+ Object [] params = new Object [] { this .auth , req };
251+ Map response = (Map )this .client .execute ("schema_field_create" , params );
252+ String field_name = (String )response .get ("results" );
253+ return field_name ;
254+ }
255+
256+ public boolean schema_field_update (String entity_type , String field_name , Map properties ) throws XmlRpcException {
257+ if (properties == null )
258+ properties = new HashMap ();
259+ List fields = new ArrayList ();
260+
261+ HashMap rf = new HashMap ();
262+ for ( Iterator iter = properties .entrySet ().iterator (); iter .hasNext (); ) {
263+ Entry e = (Entry )iter .next ();
264+ rf = new HashMap ();
265+ String key = (String )e .getKey ();
266+ rf .put ("property_name" , key );
267+ rf .put ("value" , e .getValue ());
268+ fields .add (rf );
269+ }
270+ HashMap req = new HashMap ();
271+ req .put ("type" , entity_type );
272+ req .put ("field_name" , field_name );
273+ req .put ("properties" , fields );
274+ Object [] params = new Object [] { this .auth , req };
275+ Map response = (Map )this .client .execute ("schema_field_update" , params );
276+ Boolean didDelete = (Boolean )response .get ("results" );
277+ return (didDelete .equals (Boolean .TRUE ));
278+ }
279+
280+ public boolean schema_field_delete (String entity_type , String field_name ) throws XmlRpcException {
281+ HashMap req = new HashMap ();
282+ req .put ("type" , entity_type );
283+ req .put ("field_name" , field_name );
284+ Object [] params = new Object [] { this .auth , req };
285+ Map response = (Map )this .client .execute ("schema_field_delete" , params );
286+ Boolean didDelete = (Boolean )response .get ("results" );
287+ return (didDelete .equals (Boolean .TRUE ));
288+ }
289+
198290 class MyTypeFactory extends TypeFactoryImpl {
199291 public MyTypeFactory (XmlRpcController pController ) {
200292 super (pController );
@@ -210,4 +302,5 @@ public TypeParser getParser(XmlRpcStreamConfig pConfig,
210302 }
211303 }
212304 }
305+
213306}
0 commit comments