Groovy web console

subscribe to the feed Subscribe
to this
site
task generation (via #groovywebconsole)
tweet this snippet Tweet
this
script

task generation

Published 6 months ago by mypaben
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
private static String shuffle(String sentence) {     
String[] words = sentence.split("\\s+");     
StringBuilder builder = new StringBuilder();     
for (String word : words) {         
List<Character> letters = new ArrayList<Character>();         
for (char letter : word.toCharArray()) {             letters.add(letter);         }         
if (letters.size() > 2) {             Collections.shuffle(letters.subList(1, letters.size() - 1));         }         
for (char letter : letters) {             builder.append(letter);         }        
builder.append(" ");     }    
return builder.toString(); }

def myIntRange = 0..49
def firstnames = ["Dania","Maria","Letisha","Eliana","Mohammad","Kitty","Darcel","Waldo","Carolann","Dalton","Brook","Concepcion","Kristal","Eveline","Nery","Lenora","Bernard","Pauletta","Rosina","Salvatore","Leia","Gaston","Ali","Sina","Arlena","Erika","Evelia","Vincenzo","Sulema","Jeanmarie","Ghislaine","Lowell","Latasha","Dollie","Rubie","Blair","Sherril","Bula","Shirleen","Christine","Keenan","Darlene","Gracia","Erma","Joshua","Ava","Shu","Misha","Donnie","Clifford"]
def lastnames = ["Black", "White", "Brown", "Carter", "Boyle", "Cannon", "Montmorency", "Mantha", "Jock", "Dylan", "Rourke", "O'Connell", "Briskol", "Carpenter", "Kadinski", "Micheal", "Black", "White", "Brown", "Carter", "Boyle", "Cannon", "Montmorency", "Mantha", "Jock", "Dylan", "Rourke", "O'Connell", "Briskol", "Carpenter", "Kadinski", "Micheal", "Black", "White", "Brown", "Carter", "Boyle", "Cannon", "Montmorency", "Mantha", "Jock", "Dylan", "Rourke", "O'Connell", "Briskol", "Carpenter", "Kadinski", "Micheal", "Black", "White", "Brown", "Carter", "Boyle", "Cannon", "Montmorency", "Mantha", "Jock", "Dylan", "Rourke", "O'Connell", "Briskol", "Carpenter", "Kadinski", "Micheal"]

for (n in myIntRange) {  
def birth = Math.abs(new Random().nextInt() % 5600) + 1
def joined = Math.abs(new Random().nextInt() % 25000) + 10001
println """{  
  "campaignId": "grouping-employee",
  "currentState": "New",
  "arbitration": null,
  "type": "GROUPING",
  "record": null,
  "sourceRecords": [
    {
      "creationDate": 0,
      "lastUpdateDate": 0,
      "source": "unknown-1",
      "record": {
        "EmployeeId": "N/A",
        "FirstName": "${firstnames[n]}",
        "LastName": "${lastnames[n]}",
        "BirthDate": $birth,
        "Position": "Engineer",
        "Joined": $joined,
        "Experience": "senior",
        "Salary": "60000"
      }
    },
    {
      "creationDate": 0,
      "lastUpdateDate": 0,
      "source": "unknown-2",
      "record": {
        "EmployeeId": "N/A",
        "FirstName": "${shuffle(firstnames[n])}",
        "LastName": "${shuffle(lastnames[n])}",
        "BirthDate": $birth,
        "Position": "Engineer",
        "Joined": $joined,
        "Experience": "senior",
        "Salary": "60000"
      }
    }
  ]
},"""}