Access to add and change pages is restricted. See: https://cwiki.apache.org/confluence/display/OFBIZ/Wiki+access

I use this for making Import Classes that do CRUD using services.
It works on windows. Have to figure out how to do this on linux.
got a service page like https://localhost:8443/webtools/control/availableServices
select a service https://localhost:8443/webtools/control/availableServices?sel_service_name=createProduct
highlight the In parameters area
so you can copy all the parameters
then using a editor that does not change the copy data, like PFE (old free editor)paste parameters as is
then open a blank Excel workbook
copy from the editor into excel
if everything went well you should see the columns from the service parameters in separate columns in excel
Now you can move them around and add columns to put in the strings you want
as an example

From the service in parameteres
amountUomTypeId  	True  	String  	IN  	False  	 Product   	amountUomTypeId
fixedAmount  	True  	Double  	IN  	False  	 Product   	fixedAmount

become

Modified in Excel
private String  amountUomTypeId  	String  	; <--note the semicolon
private Double  fixedAmount             Double  	;

you an use the CTRL-D to propogate the columns down for say
private
now you copy the whole list back to you editor
and do a replace of

Modifying in the text editor
String  	;<--note the semicolon to distinquish between the other "String" in the line

with

=null;

then use the replace and remove the tabs(\t) with a single space.
so you end with

code in the class
private String  amountUomTypeId  	=null;
private Double  fixedAmount             =0.0;

Now copy this into the editor(mine is eclipse) that has your class in it.
if your using eclipse or some such IDE
then you can do a format and it will adjust the code
Next, in eclipse, create the setters and getters
I do this so I am put default return for the get if the the parameter is null.

for instance here is a mapping routine I use made this way for create and update product

    public static Map<String, Object> makeproductmap() {
        Debug.logInfo("makemap", module);
        productinfo.clear();
        // productinfo.put("quantityincluded",getquantityincluded()));
        // productinfo.put("fixedamount",getfixedamount()));
        //productinfo.put("weight", getweight());
        // productinfo.put("productheight",getproductheight()));
        // productinfo.put("shippingheight",getshippingheight()));
        // productinfo.put("productwidth",getproductwidth()));
        // productinfo.put("shippingwidth",getshippingwidth()));
        // productinfo.put("productdepth",getproductdepth()));
        // productinfo.put("shippingdepth",getshippingdepth()));
        // productinfo.put("productrating",getproductrating()));
        // productinfo.put("reservmaxpersons",getreservmaxpersons()));
        // productinfo.put("reserv2ndppperc",getreserv2ndppperc()));
        // productinfo.put("reservnthppperc",getreservnthppperc()));
        // productinfo.put("introductiondate",getintroductiondate()));
        // productinfo.put("supportdiscontinuationdate",getsupportdiscontinuationdate()));
        // productinfo.put("salesdiscontinuationdate",getsalesdiscontinuationdate()));
        // productinfo.put("locale",getlocale()));
        // productinfo.put("piecesincluded",getpiecesincluded()));
        // UtilMisc.addToBigDecimalInMap(productinfo,billofmateriallevel,getbillofmateriallevel());
        productinfo.putAll(UtilMisc.toMap("userLogin", getuserlogin()));
        productinfo.putAll(UtilMisc.toMap("productId", getproductid()));
        productinfo.putAll(UtilMisc.toMap("primaryProductCategoryId",
                getprimaryproductcategoryid()));
        // productinfo.put("manufacturerpartyid",getmanufacturerpartyid()));
        // productinfo.put("facilityid",getfacilityid()));
        // productinfo.put("salesdiscwhennotavail",getsalesdiscwhennotavail()));
        // productinfo.put("brandname",getbrandname()));
        productinfo.putAll(UtilMisc.toMap("comments", getcomments()));
        // productinfo.putAll(UtilMisc.toMap("productname", getproductname()));
        productinfo.putAll(UtilMisc.toMap("description", getdescription()));
        productinfo.putAll(UtilMisc.toMap("longDescription",
                getlongdescription()));
        // productinfo.putAll(UtilMisc.toMap("pricedetailtext",
        // getpricedetailtext()));
        // productinfo.putAll(UtilMisc.toMap("smallimageurl",
        // getsmallimageurl()));
        // productinfo.putAll(UtilMisc.toMap("mediumimageurl",
        // getmediumimageurl()));
        // productinfo.putAll(UtilMisc.toMap("largeimageurl",
        // getlargeimageurl()));
        // productinfo.putAll(UtilMisc.toMap("detailimageurl",
        // getdetailimageurl()));
        // productinfo.putAll(UtilMisc.toMap("detailscreen",
        // getdetailscreen()));
        // productinfo.putAll(UtilMisc.toMap("inventorymessage",
        // getinventorymessage()));
        productinfo.putAll(UtilMisc.toMap("requireInventory",
                getrequireinventory()));
        // productinfo.putAll(UtilMisc.toMap("quantityuomid",
        // getquantityuomid()));
        // productinfo.putAll(UtilMisc.toMap("requireamount",getrequireamount()));
        // productinfo.putAll(UtilMisc.toMap("amountuomtypeid",getamountuomtypeid()));
        // productinfo.putAll(UtilMisc.toMap("weightuomid",getweightuomid()));
        // productinfo.putAll(UtilMisc.toMap("heightuomid",getheightuomid()));
        // productinfo.putAll(UtilMisc.toMap("widthuomid",getwidthuomid()));
        // productinfo.putAll(UtilMisc.toMap("depthuomid",getdepthuomid()));
        // productinfo.putAll(UtilMisc.toMap("ratingtypeenum",getratingtypeenum()));
        // productinfo.putAll(UtilMisc.toMap("returnable", getreturnable()));
        productinfo.putAll(UtilMisc.toMap("taxable", gettaxable()));
        // productinfo.putAll(UtilMisc.toMap("taxcategory", gettaxcategory()));
        // productinfo.putAll(UtilMisc.toMap("taxvatcode",gettaxvatcode()));
        // productinfo.putAll(UtilMisc.toMap("taxdutycode",gettaxdutycode()));
        productinfo.putAll(UtilMisc
                .toMap("chargeShipping", getchargeshipping()));
        productinfo.putAll(UtilMisc.toMap("autoCreateKeywords",
                getautocreatekeywords()));
        // productinfo.putAll(UtilMisc.toMap("includeinpromotions",getincludeinpromotions()));
        // productinfo.putAll(UtilMisc.toMap("isvirtual",getisvirtual()));
        // productinfo.putAll(UtilMisc.toMap("isvariant",getisvariant()));
        // productinfo.putAll(UtilMisc.toMap("origingeoid", getorigingeoid()));
        // productinfo.putAll(UtilMisc.toMap("requirementmethodenumid",getrequirementmethodenumid()));
        productinfo.putAll(UtilMisc.toMap("productTypeId", getproducttypeid()));
        productinfo.putAll(UtilMisc.toMap("internalName", getinternalname()));
        Debug.logInfo("makemap done", module);
        
        return productinfo;
    }

Note: this is a lot of extra work for inline code used in ofbiz
these classes are for importing scripts, so the major work is done you just have to write how to read the file and let the worker classes carry the load.

  • No labels

4 Comments

  1. What are the advantages over datafile OFBiz component ?

    1. Unknown User (bjfree@free-man.net)

      I have only read about the datafiles, so if I missed something let me know.
      My understanding is they take an import and convert it to ofbiz entity files.
      This is great if your doing static work.
      For instance, I have a supplier that provides updated inventory.
      I have to check if this product is already in or not and if the data needs to be updated or not.
      Also if it has to be removed or the sale price has changed
      Then have to create a task that lets the User of the back end know there needs some attention to the the import.

      the Same for an Import of an external web, the User of the backend needs to know what changes have occurred.

      Orders imported need to go through the cart process to show up in the accounting. And there is a task to show the order has been recieved from and external source and which.

      All of these have information about where they go, like the Supplier import goes to there own catalog based on the supplier, the Website data goes to particular ProductStore.

    2. Unknown User (bjfree@free-man.net)

      forgot a couple
      it speeds up the import since if nothing is changed the data is not imported.
      like with the supplier imports it check if their product is in the Productstore Catalog and will also update the pricing data and toDate, and discontinued support date if the item is discontinued.
      these also have task to notify the user of the backend that things have changed.

  2. Interesting trick indeed, thanks to share (smile)