public Collection getFwMap() {
    ArrayList<FirmwareMapEntry> a = new ArrayList<FirmwareMapEntry>();
    Map<Integer, HardwareModelLocal> hwmap = Ejb.getHardwareModelMap();

    try {
      Iterator<DeviceProfile2SoftwareLocal> i =
          Ejb.lookupDeviceProfile2SoftwareBean().findByProfile(name).iterator();
      while (i.hasNext()) {
        DeviceProfile2SoftwareLocal o = i.next();
        HardwareModelLocal hwm = hwmap.get(o.getHwid());
        a.add(new FirmwareMapEntry(hwm.getDisplayName(), (Integer) hwm.getId(), o.getVersion()));
      }
    } catch (FinderException ex) {
    }
    return a;
  }
 public Collection getAll() {
   try {
     return Ejb.lookupDeviceProfileBean().findAll();
   } catch (FinderException ex) {
     setErrorMessage(ex.getMessage());
     return null;
   }
 }
 public String create() {
   try {
     save(Ejb.lookupDeviceProfileBean().create(name));
     return "created";
   } catch (CreateException ex) {
     setErrorMessage(ex.getMessage());
   }
   return null;
 }
 public String RemoveFwMapping() {
   //      System.out.println("DeviceProfileBean.RemoveFwMapping");
   DeviceProfile2SoftwareLocalHome h = Ejb.lookupDeviceProfile2SoftwareBean();
   try {
     h.remove(new DeviceProfile2SoftwarePK(hwidrem, name));
   } catch (Exception ex) {
     setErrorMessage(ex.getMessage());
   }
   return null;
 }
 public String save() {
   try {
     save(Ejb.lookupDeviceProfileBean().findByPrimaryKey(name));
     setSaved();
     return "saved";
   } catch (FinderException ex) {
     setErrorMessage(ex.getMessage());
   }
   return null;
 }
 public String AddFw() {
   //        System.out.println("DeviceProfileBean.AddFw name="+name+" hwid="+hwid+"
   // version="+version);
   DeviceProfile2SoftwareLocalHome h = Ejb.lookupDeviceProfile2SoftwareBean();
   try {
     h.create(name, hwid, version);
   } catch (CreateException ex) {
     setErrorMessage(ex.getMessage());
   }
   return null;
 }
 public Collection getScriptNames() {
   ArrayList<SelectItem> a = new ArrayList<SelectItem>();
   try {
     Iterator<ScriptLocal> fws = Ejb.lookupScriptBean().findAll().iterator();
     while (fws.hasNext()) {
       ScriptLocal script = fws.next();
       a.add(new SelectItem(script.getName(), script.getName()));
     }
   } catch (FinderException ex) {
   }
   return a;
 }
 public Collection getList() {
   try {
     Iterator lst = Ejb.lookupDeviceProfileBean().findAll().iterator();
     ArrayList<SelectItem> a = new ArrayList<SelectItem>();
     while (lst.hasNext()) {
       DeviceProfileLocal it = (DeviceProfileLocal) lst.next();
       a.add(new SelectItem(it.getName(), it.getName()));
     }
     return a;
   } catch (FinderException ex) {
     setErrorMessage(ex.getMessage());
   }
   return null;
 }
 public Collection getDevices() {
   // System.out.println("DeviceProfileBean.getDevices");
   try {
     //            Iterator cfgs = Ejb.lookupConfigurationBean().findAll().iterator();
     Iterator<HardwareModelLocal> hwms = Ejb.lookupHardwareModelBean().findAll().iterator();
     ArrayList<SelectItem> a = new ArrayList<SelectItem>();
     while (hwms.hasNext()) {
       HardwareModelLocal hwm = hwms.next();
       a.add(new SelectItem(hwm.getId(), hwm.getDisplayName()));
     }
     return a;
   } catch (FinderException ex) {
   }
   return null;
 }
 public Collection getFwVersions() {
   //        javax.faces.context.FacesContext.getCurrentInstance().
   // System.out.println("DeviceProfileBean.getFwVersions hwid=" + hwid);
   ArrayList<SelectItem> a = new ArrayList<SelectItem>();
   a.add(new SelectItem(DeviceProfile2SoftwareLocal.NOUPDATE, "No update"));
   a.add(new SelectItem(DeviceProfile2SoftwareLocal.AUTOUPDATE, "Automatic"));
   try {
     //            Iterator cfgs = Ejb.lookupConfigurationBean().findAll().iterator();
     Iterator<SoftwareLocal> fws = Ejb.lookupSoftwareBean().findByHardware(hwid).iterator();
     while (fws.hasNext()) {
       SoftwareLocal fw = fws.next();
       a.add(new SelectItem(fw.getVersion(), fw.getVersion()));
     }
   } catch (FinderException ex) {
   }
   return a;
 }
 public String delete() {
   if (name.equalsIgnoreCase("default")) {
     setErrorMessage("Builtin profile 'Default' can not be deleted.");
     return null;
   }
   try {
     Ejb.lookupDeviceProfileBean().findByPrimaryKey(name).remove();
     setDeleted();
     return "deleted";
   } catch (RemoveException ex) {
     setErrorMessage(ex.getMessage());
   } catch (EJBException ex) {
     setErrorMessage(ex.getMessage());
   } catch (FinderException ex) {
     setErrorMessage(ex.getMessage());
   }
   return null;
 }
  public String load() {
    try {
      DeviceProfileLocal d = Ejb.lookupDeviceProfileBean().findByPrimaryKey(name);
      setPeriodicInformInterval(d.getInforminterval());
      setDaysToKeepStats(d.getDayskeepstats());
      setSaveParamValuesInterval(d.getSaveParamValuesInterval());
      saveParamValuesOnBoot = d.getSaveParamValuesOnBoot();
      saveParamValuesOnChange = d.getSaveParamValuesOnChange();
      saveLog = d.getSaveLog();
      saveParamValues = d.getSaveParamValues();
      scriptName = d.getScriptname();

      props = new ProfilePropertySet(name);
      props.Load();
      return "loaded";
    } catch (FinderException ex) {
      setErrorMessage(ex.getMessage());
    }
    return null;
  }