WEPSFallowRotation.java [src/java/services] Revision: 98ade6c2e1d776cdd72ed06bdb2817762932beb1  Date: Thu Dec 05 16:51:56 MST 2019
/*
 * $Id$
 *
 * This file is part of the Cloud Services Integration Platform (CSIP),
 * a Model-as-a-Service framework, API, and application suite.
 *
 * 2012-2019, OMSLab, Colorado State University.
 *
 * OMSLab licenses this file to you under the MIT license.
 * See the LICENSE file in the project root for more information.
 */
package services;

import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;

/**
 *
 * @author <a href="mailto:shaun.case@colostate.edu">Shaun Case</a>
 */
public class WEPSFallowRotation {
    
    private int length = Integer.MAX_VALUE;
    
    private String rotation = "{\n" +
"    \"name\": \"crlmod\",\n" +
"    \"value\": {\n" +
"        \"rotationFiles\": [{\n" +
"                \"rotation\": {\n" +
"                    \"duration\": 1,\n" +
"                    \"length\": 0,\n" +
"                    \"managements\": [{\n" +
"                            \"events\": [{\n" +
"                                    \"date\": \"2020-01-31\",\n" +
"                                    \"interval\": false,\n" +
"                                    \"operation\": {\n" +
"                                        \"add_residue\": false,\n" +
"                                        \"begin_growth\": false,\n" +
"                                        \"defaultResidueAdded\": 0,\n" +
"                                        \"id\": \"23559\",\n" +
"                                        \"kill_crop\": false,\n" +
"                                        \"name\": \"Harrow, rotary\",\n" +
"                                        \"opGroup1\": \"Tillage, surface, shallow\",\n" +
"                                        \"opNotes\": \"Tillage operation, shallow, Rotary harrow with spike tine clusters mounted on a rotating cable\\nset at slight angle, Breaks crusts, lifts and redeposits residue, levels surface,\\nlightly incorporates seed, fertilizer or chemicals.  Vegetation is killed.\",\n" +
"                                        \"row_direction\": \"0\",\n" +
"                                        \"stir\": 10.24\n" +
"                                    }\n" +
"                                }, {\n" +
"                                    \"date\": \"2020-02-28\",\n" +
"                                    \"interval\": false,\n" +
"                                    \"operation\": {\n" +
"                                        \"add_residue\": false,\n" +
"                                        \"begin_growth\": false,\n" +
"                                        \"defaultResidueAdded\": 0,\n" +
"                                        \"id\": \"23559\",\n" +
"                                        \"kill_crop\": false,\n" +
"                                        \"name\": \"Harrow, rotary\",\n" +
"                                        \"opGroup1\": \"Tillage, surface, shallow\",\n" +
"                                        \"opNotes\": \"Tillage operation, shallow, Rotary harrow with spike tine clusters mounted on a rotating cable\\nset at slight angle, Breaks crusts, lifts and redeposits residue, levels surface,\\nlightly incorporates seed, fertilizer or chemicals.  Vegetation is killed.\",\n" +
"                                        \"row_direction\": \"0\",\n" +
"                                        \"stir\": 10.24\n" +
"                                    }\n" +
"                                }, {\n" +
"                                    \"date\": \"2020-03-31\",\n" +
"                                    \"interval\": false,\n" +
"                                    \"operation\": {\n" +
"                                        \"add_residue\": false,\n" +
"                                        \"begin_growth\": false,\n" +
"                                        \"defaultResidueAdded\": 0,\n" +
"                                        \"id\": \"23559\",\n" +
"                                        \"kill_crop\": false,\n" +
"                                        \"name\": \"Harrow, rotary\",\n" +
"                                        \"opGroup1\": \"Tillage, surface, shallow\",\n" +
"                                        \"opNotes\": \"Tillage operation, shallow, Rotary harrow with spike tine clusters mounted on a rotating cable\\nset at slight angle, Breaks crusts, lifts and redeposits residue, levels surface,\\nlightly incorporates seed, fertilizer or chemicals.  Vegetation is killed.\",\n" +
"                                        \"row_direction\": \"0\",\n" +
"                                        \"stir\": 10.24\n" +
"                                    }\n" +
"                                }, {\n" +
"                                    \"date\": \"2020-04-30\",\n" +
"                                    \"interval\": false,\n" +
"                                    \"operation\": {\n" +
"                                        \"add_residue\": false,\n" +
"                                        \"begin_growth\": false,\n" +
"                                        \"defaultResidueAdded\": 0,\n" +
"                                        \"id\": \"23559\",\n" +
"                                        \"kill_crop\": false,\n" +
"                                        \"name\": \"Harrow, rotary\",\n" +
"                                        \"opGroup1\": \"Tillage, surface, shallow\",\n" +
"                                        \"opNotes\": \"Tillage operation, shallow, Rotary harrow with spike tine clusters mounted on a rotating cable\\nset at slight angle, Breaks crusts, lifts and redeposits residue, levels surface,\\nlightly incorporates seed, fertilizer or chemicals.  Vegetation is killed.\",\n" +
"                                        \"row_direction\": \"0\",\n" +
"                                        \"stir\": 10.24\n" +
"                                    }\n" +
"                                }, {\n" +
"                                    \"date\": \"2020-05-31\",\n" +
"                                    \"interval\": false,\n" +
"                                    \"operation\": {\n" +
"                                        \"add_residue\": false,\n" +
"                                        \"begin_growth\": false,\n" +
"                                        \"defaultResidueAdded\": 0,\n" +
"                                        \"id\": \"23559\",\n" +
"                                        \"kill_crop\": false,\n" +
"                                        \"name\": \"Harrow, rotary\",\n" +
"                                        \"opGroup1\": \"Tillage, surface, shallow\",\n" +
"                                        \"opNotes\": \"Tillage operation, shallow, Rotary harrow with spike tine clusters mounted on a rotating cable\\nset at slight angle, Breaks crusts, lifts and redeposits residue, levels surface,\\nlightly incorporates seed, fertilizer or chemicals.  Vegetation is killed.\",\n" +
"                                        \"row_direction\": \"0\",\n" +
"                                        \"stir\": 10.24\n" +
"                                    }\n" +
"                                }, {\n" +
"                                    \"date\": \"2020-06-30\",\n" +
"                                    \"interval\": false,\n" +
"                                    \"operation\": {\n" +
"                                        \"add_residue\": false,\n" +
"                                        \"begin_growth\": false,\n" +
"                                        \"defaultResidueAdded\": 0,\n" +
"                                        \"id\": \"23559\",\n" +
"                                        \"kill_crop\": false,\n" +
"                                        \"name\": \"Harrow, rotary\",\n" +
"                                        \"opGroup1\": \"Tillage, surface, shallow\",\n" +
"                                        \"opNotes\": \"Tillage operation, shallow, Rotary harrow with spike tine clusters mounted on a rotating cable\\nset at slight angle, Breaks crusts, lifts and redeposits residue, levels surface,\\nlightly incorporates seed, fertilizer or chemicals.  Vegetation is killed.\",\n" +
"                                        \"row_direction\": \"0\",\n" +
"                                        \"stir\": 10.24\n" +
"                                    }\n" +
"                                }, {\n" +
"                                    \"date\": \"2020-07-31\",\n" +
"                                    \"interval\": false,\n" +
"                                    \"operation\": {\n" +
"                                        \"add_residue\": false,\n" +
"                                        \"begin_growth\": false,\n" +
"                                        \"defaultResidueAdded\": 0,\n" +
"                                        \"id\": \"23559\",\n" +
"                                        \"kill_crop\": false,\n" +
"                                        \"name\": \"Harrow, rotary\",\n" +
"                                        \"opGroup1\": \"Tillage, surface, shallow\",\n" +
"                                        \"opNotes\": \"Tillage operation, shallow, Rotary harrow with spike tine clusters mounted on a rotating cable\\nset at slight angle, Breaks crusts, lifts and redeposits residue, levels surface,\\nlightly incorporates seed, fertilizer or chemicals.  Vegetation is killed.\",\n" +
"                                        \"row_direction\": \"0\",\n" +
"                                        \"stir\": 10.24\n" +
"                                    }\n" +
"                                }, {\n" +
"                                    \"date\": \"2020-08-31\",\n" +
"                                    \"interval\": false,\n" +
"                                    \"operation\": {\n" +
"                                        \"add_residue\": false,\n" +
"                                        \"begin_growth\": false,\n" +
"                                        \"defaultResidueAdded\": 0,\n" +
"                                        \"id\": \"23559\",\n" +
"                                        \"kill_crop\": false,\n" +
"                                        \"name\": \"Harrow, rotary\",\n" +
"                                        \"opGroup1\": \"Tillage, surface, shallow\",\n" +
"                                        \"opNotes\": \"Tillage operation, shallow, Rotary harrow with spike tine clusters mounted on a rotating cable\\nset at slight angle, Breaks crusts, lifts and redeposits residue, levels surface,\\nlightly incorporates seed, fertilizer or chemicals.  Vegetation is killed.\",\n" +
"                                        \"row_direction\": \"0\",\n" +
"                                        \"stir\": 10.24\n" +
"                                    }\n" +
"                                }, {\n" +
"                                    \"date\": \"2020-09-30\",\n" +
"                                    \"interval\": false,\n" +
"                                    \"operation\": {\n" +
"                                        \"add_residue\": false,\n" +
"                                        \"begin_growth\": false,\n" +
"                                        \"defaultResidueAdded\": 0,\n" +
"                                        \"id\": \"23559\",\n" +
"                                        \"kill_crop\": false,\n" +
"                                        \"name\": \"Harrow, rotary\",\n" +
"                                        \"opGroup1\": \"Tillage, surface, shallow\",\n" +
"                                        \"opNotes\": \"Tillage operation, shallow, Rotary harrow with spike tine clusters mounted on a rotating cable\\nset at slight angle, Breaks crusts, lifts and redeposits residue, levels surface,\\nlightly incorporates seed, fertilizer or chemicals.  Vegetation is killed.\",\n" +
"                                        \"row_direction\": \"0\",\n" +
"                                        \"stir\": 10.24\n" +
"                                    }\n" +
"                                }, {\n" +
"                                    \"date\": \"2020-10-31\",\n" +
"                                    \"interval\": false,\n" +
"                                    \"operation\": {\n" +
"                                        \"add_residue\": false,\n" +
"                                        \"begin_growth\": false,\n" +
"                                        \"defaultResidueAdded\": 0,\n" +
"                                        \"id\": \"23559\",\n" +
"                                        \"kill_crop\": false,\n" +
"                                        \"name\": \"Harrow, rotary\",\n" +
"                                        \"opGroup1\": \"Tillage, surface, shallow\",\n" +
"                                        \"opNotes\": \"Tillage operation, shallow, Rotary harrow with spike tine clusters mounted on a rotating cable\\nset at slight angle, Breaks crusts, lifts and redeposits residue, levels surface,\\nlightly incorporates seed, fertilizer or chemicals.  Vegetation is killed.\",\n" +
"                                        \"row_direction\": \"0\",\n" +
"                                        \"stir\": 10.24\n" +
"                                    }\n" +
"                                }, {\n" +
"                                    \"date\": \"2020-11-30\",\n" +
"                                    \"interval\": false,\n" +
"                                    \"operation\": {\n" +
"                                        \"add_residue\": false,\n" +
"                                        \"begin_growth\": false,\n" +
"                                        \"defaultResidueAdded\": 0,\n" +
"                                        \"id\": \"23559\",\n" +
"                                        \"kill_crop\": false,\n" +
"                                        \"name\": \"Harrow, rotary\",\n" +
"                                        \"opGroup1\": \"Tillage, surface, shallow\",\n" +
"                                        \"opNotes\": \"Tillage operation, shallow, Rotary harrow with spike tine clusters mounted on a rotating cable\\nset at slight angle, Breaks crusts, lifts and redeposits residue, levels surface,\\nlightly incorporates seed, fertilizer or chemicals.  Vegetation is killed.\",\n" +
"                                        \"row_direction\": \"0\",\n" +
"                                        \"stir\": 10.24\n" +
"                                    }\n" +
"                                }, {\n" +
"                                    \"date\": \"2020-12-31\",\n" +
"                                    \"interval\": false,\n" +
"                                    \"operation\": {\n" +
"                                        \"add_residue\": false,\n" +
"                                        \"begin_growth\": false,\n" +
"                                        \"defaultResidueAdded\": 0,\n" +
"                                        \"id\": \"23559\",\n" +
"                                        \"kill_crop\": false,\n" +
"                                        \"name\": \"Harrow, rotary\",\n" +
"                                        \"opGroup1\": \"Tillage, surface, shallow\",\n" +
"                                        \"opNotes\": \"Tillage operation, shallow, Rotary harrow with spike tine clusters mounted on a rotating cable\\nset at slight angle, Breaks crusts, lifts and redeposits residue, levels surface,\\nlightly incorporates seed, fertilizer or chemicals.  Vegetation is killed.\",\n" +
"                                        \"row_direction\": \"0\",\n" +
"                                        \"stir\": 10.24\n" +
"                                    }\n" +
"                                }],\n" +
"                            \"id\": null,\n" +
"                            \"name\": \"default\",\n" +
"                            \"path\": \"Edited managements\",\n" +
"                            \"stir\": 0\n" +
"                        }],\"name\": \"Fallow 12x Rotary Harrow\"\n" +
"                }\n" +
"            }]\n" +
"    }\n" +
"}";
    
    public WEPSFallowRotation(int length){
        this.length = length;
    }
    
    public JSONObject rotation() throws JSONException{
        String adjustedRotation = rotation;
        
        if (length < Integer.MAX_VALUE ){
            adjustedRotation = adjustedRotation.replace("\"length\": 0", "\"length\": " + length);
        }
        return new JSONObject(adjustedRotation);
    }
}