Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package hudson.plugins.dbcharts;
  
  import hudson.Extension;
 
 import java.util.List;
 
 
 
 
 public class DbChartPublisher  extends Recorder
 {
     static final Logger logger=Logger.getLoggerDbChartPublisher.class.getCanonicalName() );
     private final List<Chartcharts;
     
     public DbChartPublisher()
     {
         =new LinkedList<Chart>();
     }
     
     public DbChartPublisher(List<Chartcharts)
     {
         this.=charts;
     }
     
     public List<ChartgetCharts()
     {
         return ;
     }
     
     @SuppressWarnings("unchecked")
     @Override
     public Action getProjectActionAbstractProject project )
     {
         .info("DbChartPublisher.getProjectAction called");
         return new DbChartAction(project,this);
     }
     
     {
         return .;
     }    
     
     @Override
     public DescriptorImpl getDescriptor()
     {
         .info("DbChartPublisher.getDescriptor() called");
         return (DescriptorImpl)super.getDescriptor();
     }   
     
     @Extension
     public static final class DescriptorImpl extends BuildStepDescriptor<Publisher>{
         private static final Logger logger=Logger.getLoggerDescriptorImpl.class.getCanonicalName() );
         public List<JDBCConnectionconnections;
 
         public DescriptorImpl()
         {
             .info"DescriptorImpl constructed");
             load();
         }
         
         public List<JDBCConnectiongetConnections()
         {
             return ;
         }
 
        
         public List<StringgetDrivers(){
                         Enumeration<Drivere=DriverManager.getDrivers();
             List<Stringres=new LinkedList<String>();
             while(e.hasMoreElements()){
                 res.adde.nextElement().getClass().getCanonicalName() );
            }
            .info"DescriptorImpl.getDrivers returned:"+Arrays.toStringres.toArray()) );
            return res;
        }
        
        
        @SuppressWarnings("unchecked")
        @Override
        public boolean isApplicableClass<? extends AbstractProjectjobType )
        {         
            return true;
        }
        @Override
        public String getDisplayName()
        {
            return "dbCharts configuration";
        }
       
        public boolean configureStaplerRequest reqJSONObject json )
            throws hudson.model.Descriptor.FormException
        {
            .info"DescriptorImpl.configure:"+json );
             = new LinkedList<JDBCConnection>();
            Object ob=json.get"connections"  );
            try{
                if (ob instanceof JSONArray)
                {
                    for(Object o:(JSONArray)ob){
                        JDBCConnection c=(JDBCConnection)Class.forName( ((JSONObject)o).getString("stapler-class"))
                            .getConstructorJSONObject.class )
                            .newInstance(o);
                        .addc);
                    }
                }else{
                    JDBCConnection c=(JDBCConnection)Class.forName( ((JSONObject)ob).getString("stapler-class"))
                        .getConstructorJSONObject.class )
                        .newInstance(ob);
                    .addc);                
                }
            }catch(Exception e){
                throw new FormExceptione"connections" );
            }
            save();
            return super.configurereqjson );
        }
                
        
        public FormValidation doCheckName(@QueryParameter String valuethrows IOExceptionServletException {
            if(value.length()==0)
                return FormValidation.error("Please set a name");
            if(value.length()<4)
                return FormValidation.warning("Isn't the name too short?");
            return FormValidation.ok();
        }
        
        
        public List<DescriptorgetJDBCConnectionDescriptors(){
            List<Descriptorres=new LinkedList<Descriptor>();
            Descriptor<?> custom=Hudson.getInstance().getDescriptorByTypeCustomJDBCConnectionDescriptor.class );
            Descriptor<?> mysql=Hudson.getInstance().getDescriptorByTypeMySQLJDBCConnectionDescriptor.class );
            Descriptor<?> pgsql=Hudson.getInstance().getDescriptorByTypePostgresqlJDBCConnectionDescriptor.class );
            res.add(mysql);
            res.addpgsql );
            res.add(custom);            
            .info("getJDBCConnectionDescriptors(): custom="+custom+"; mysql="+mysql);
            return res;
        }
        
    }
    
    
New to GrepCode? Check out our FAQ X