/*
 * Copyright (c) 2012 Cosmin Stejerean.
 *
 * Distributed under the MIT license: http://opensource.org/licenses/MIT
 */

package com.offbytwo.jenkins.model;

public class BuildWithDetails extends Build {
    boolean building;
    int duration;
    String fullDisplayName;
    String id;
    long timestamp;
    BuildResult result;

    public boolean isBuilding() {
        return building;
    }

    public void setBuilding(boolean building) {
        this.building = building;
    }

    public int getDuration() {
        return duration;
    }

    public void setDuration(int duration) {
        this.duration = duration;
    }

    public String getFullDisplayName() {
        return fullDisplayName;
    }

    public void setFullDisplayName(String fullDisplayName) {
        this.fullDisplayName = fullDisplayName;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public BuildResult getResult() {
        return result;
    }

    public void setResult(BuildResult result) {
        this.result = result;
    }
}

@@ -154,16 +154,261 @@
 model;%0A%0A
+import com.google.common.base.Predicate;%0Aimport com.google.common.collect.Lists;%0A%0Aimport java.util.Collection;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Aimport static com.google.common.collect.Collections2.filter;%0A%0A
 public c
@@ -445,16 +445,34 @@
 Build %7B%0A
+    List actions;%0A
     bool
@@ -672,77 +672,51 @@
 lic 
-void setBuilding(boolean building) %7B%0A        this.building = building
+int getDuration() %7B%0A        return duration
 ;%0A  
@@ -727,39 +727,49 @@
 %0A    public 
+Str
 in
-t
+g
  get
-Duration
+FullDisplayName
 () %7B%0A       
@@ -772,32 +772,39 @@
      return 
-duration
+fullDisplayName
 ;%0A    %7D%0A%0A   
@@ -815,118 +815,149 @@
 lic 
-void s
+String getId() %7B%0A        r
 et
-D
 ur
-ation(int duration) %7B%0A        this.duration = duration;%0A    %7D%0A%0A    public String getFullDisplayName
+n id;%0A    %7D%0A%0A    public long getTimestamp() %7B%0A        return timestamp;%0A    %7D%0A%0A    public BuildResult getResult
 () %7B
@@ -968,39 +968,30 @@
      return 
-fullDisplayName
+result
 ;%0A    %7D%0A%0A   
@@ -1010,96 +1010,62 @@
  set
-FullDisplayName(String fullDisplayName) %7B%0A        this.fullDisplayName = fullDisplayName
+Actions(List actions) %7B%0A        this.actions = actions
 ;%0A  
@@ -1084,82 +1084,214 @@
 lic 
+Map%3C
 String
- getId() %7B%0A        return id;%0A    %7D%0A%0A    public void setId(String id
+, String%3E getParameters() %7B%0A        Collection parameters = filter(actions, new Predicate%3CMap%3CString, Object%3E%3E() %7B%0A            @Override%0A            public boolean apply(Map%3CString, Object%3E action
 ) %7B%0A
@@ -1302,138 +1302,340 @@
     
+   
-this.id = id;%0A    %7D%0A%0A    public long getTimestamp() %7B%0A        return timestamp;
+     return action.containsKey(%22parameters%22);%0A            %7D%0A        %7D);%0A%0A        Map%3CString, String%3E params = new HashMap%3CString, String%3E();%0A%0A        if (parameters != null && !parameters.isEmpty()) %7B
 %0A    
-%7D%0A%0A
+ 
     
-public void setTimestamp(long timestamp
+   for(Map%3CString, String%3E param : ((Map%3CString, List%3CMap%3CString, String%3E%3E%3E) parameters.toArray()%5B0%5D).get(%22parameters%22)
 ) %7B%0A
@@ -1646,186 +1646,185 @@
     
+  
-this.timestamp = timestamp
+      String key = param.get(%22name%22)
 ;%0A    
-%7D%0A%0A
     
-public BuildResult getResult() %7B%0A        return result;%0A
+        String value = param.get(%22value%22);%0A                params.put(key, value);%0A        
     %7D%0A
-%0A
     
-public void setResult(BuildResult result) %7B%0A        this.result = result
+    %7D%0A%0A        return params
 ;%0A  

add support for fetching build parameters