private String getSchoolName(User user) {
    try {
      SchoolUserHome home = (SchoolUserHome) IDOLookup.getHome(SchoolUser.class);
      SchoolUser schoolUser = home.findForUser(user);
      int schoolid = schoolUser.getSchoolId();

      SchoolHome home2 = (SchoolHome) IDOLookup.getHome(School.class);
      School school = home2.findByPrimaryKey(new Integer(schoolid));

      return school.getName();
    } catch (Exception e) {
      return "";
    }
  }
  /**
   * Removes a SchoolClassMember(placement) and its attached ResourceClassMembers (resource
   * placements)
   *
   * @param schoolClassMemberPK
   */
  public void removeSchoolClassMember(Integer schoolClassMemberPK) {
    UserTransaction trans = null;
    try {
      trans = getSessionContext().getUserTransaction();
      trans.begin();

      SchoolClassMember schClMember =
          getSchoolClassMemberHome().findByPrimaryKey(schoolClassMemberPK);
      ResourceClassMemberHome rcmHome =
          (ResourceClassMemberHome) IDOLookup.getHome(ResourceClassMember.class);
      // Remove resource placements
      Collection rscPlacements = rcmHome.findAllByClassMemberId(schoolClassMemberPK);
      for (Iterator iter = rscPlacements.iterator(); iter.hasNext(); ) {
        ResourceClassMember element = (ResourceClassMember) iter.next();
        element.remove();
      }

      // Remove placement
      schClMember.remove();

      trans.commit();
    } catch (Exception e) {
      try {
        trans.rollback();
      } catch (IllegalStateException e1) {
        log(e1);
      } catch (SecurityException e1) {
        log(e1);
      } catch (SystemException e1) {
        log(e1);
      }
    }
  }
  private void updateDomainData() {

    String propertyKey = "dataupdate_domain_done";
    String done = iwma.getSettings().getProperty(propertyKey);
    if (done == null) {

      ICDomainHome domainHome = null;
      ICDomain defaultDomain = null;
      try {
        domainHome = (ICDomainHome) IDOLookup.getHome(ICDomain.class);
        defaultDomain = domainHome.findDefaultDomain();

      } catch (FinderException e) {
        if (defaultDomain == null) {
          try {
            defaultDomain = domainHome.findFirstDomain();
            defaultDomain.setType(ICDomain.TYPE_DEFAULT);
            defaultDomain.store();
            iwma.getSettings().setProperty(propertyKey, "true");
          } catch (FinderException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }
        }
      } catch (IDOLookupException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }
 private LandsmotEventHome getEventHome() {
   try {
     return (LandsmotEventHome) IDOLookup.getHome(LandsmotEvent.class);
   } catch (IDOLookupException e) {
     throw new IDORuntimeException(e);
   }
 }
 private LandsmotGroupRegistrationHome getLandsmotGroupRegistrationHome() {
   try {
     return (LandsmotGroupRegistrationHome) IDOLookup.getHome(LandsmotGroupRegistration.class);
   } catch (IDOLookupException e) {
     throw new IDORuntimeException(e);
   }
 }
Ejemplo n.º 6
0
 @SuppressWarnings("unchecked")
 protected <T extends IDOHome> T getHomeForEntity(Class<? extends IDOEntity> entityClass) {
   try {
     return (T) IDOLookup.getHome(entityClass);
   } catch (Exception e) {
     LOGGER.log(
         Level.WARNING, "Som error occurred getting home interface for entity: " + entityClass, e);
   }
   return null;
 }
 private void addCategoryAsExpanded(String selCat) {
   this.expandedCategories.add(selCat);
   try {
     ICCategory icCat =
         ((ICCategoryHome) IDOLookup.getHome(ICCategory.class))
             .findByPrimaryKey(new Integer(selCat));
     addCategoryAsExpanded(icCat.getParentEntity().getPrimaryKey().toString());
   } catch (Exception e) {
     this.expandedCategories.remove(selCat);
     // e.printStackTrace();
   }
 }
 private void updateStartTypeEmailType() {
   EmailTypeHome home;
   try {
     home = (EmailTypeHome) IDOLookup.getHome(EmailType.class);
     home.updateStartData();
   } catch (IDOLookupException e) {
     log.throwing(this.getClass().getName(), "updateStartTypeEmailType", e);
   } catch (IDOException e) {
     log.throwing(this.getClass().getName(), "updateStartTypeEmailType", e);
   } catch (CreateException e) {
     log.throwing(this.getClass().getName(), "updateStartTypeEmailType", e);
   }
 }
  // œr private ’ protected
  protected void init(IWContext iwc) {
    this.form = new Form();
    this.searchString = iwc.getParameter(this.PARAMETER_SEARCH);
    this.iwrb =
        iwc.getIWMainApplication()
            .getBundle(BuilderConstants.STANDARD_IW_BUNDLE_IDENTIFIER)
            .getResourceBundle(iwc);
    this.showAll = iwc.isParameterSet(this.PARAMETER_VIEW_ALL);

    if (iwc.isParameterSet(this.PARAMETER_CURRENT_PAGE)) {
      this.currentPage = Integer.parseInt(iwc.getParameter(this.PARAMETER_CURRENT_PAGE));
    }
    // int start = currentPage * USERS_PER_PAGE;

    try {
      String useUserPks =
          (String) iwc.getSessionAttribute(USING_AVAILABLE_USER_PKS_SESSION_PARAMETER);
      if (useUserPks != null) {
        this.usingUserPks = true;
      }
      Collection availableUserPks =
          (Collection) iwc.getSessionAttribute(AVAILABLE_USER_PKS_SESSION_PARAMETER);
      String[] userIds = null;
      if (this.usingUserPks && availableUserPks != null) {
        userIds = new String[availableUserPks.size()];
        Iterator iter = availableUserPks.iterator();
        int counter = 0;
        while (iter.hasNext()) {
          Object i = iter.next();
          userIds[counter++] = i.toString();
        }
      }
      if (this.usingUserPks && this.searchString == null) {
        this.showAll = true;
      }

      UserHome uHome = (UserHome) IDOLookup.getHome(User.class);
      if (this.showAll) {
        if (this.usingUserPks && userIds != null) {
          this.users = uHome.findUsers(userIds);
        } else {
          this.users = uHome.findAllUsersOrderedByFirstName();
        }
      } else if (this.searchString != null) {
        this.users = uHome.findUsersBySearchCondition(this.searchString, userIds, false);
      }
    } catch (Exception e) {
      e.printStackTrace(System.err);
    }
  }
  protected void init(IWContext iwc) {
    this.form = new Form();
    this.form.maintainParameter(SchoolUserChooser.PARAMETER_SCHOOL_ID);

    this.searchString = iwc.getParameter(this.PARAMETER_SEARCH);
    this.iwrb =
        iwc.getIWMainApplication()
            .getBundle(BuilderConstants.STANDARD_IW_BUNDLE_IDENTIFIER)
            .getResourceBundle(iwc);
    this.showAll = iwc.isParameterSet(this.PARAMETER_VIEW_ALL);
    if (iwc.isParameterSet(this.PARAMETER_CURRENT_PAGE)) {
      this.currentPage = Integer.parseInt(iwc.getParameter(this.PARAMETER_CURRENT_PAGE));
    }
    try {
      SchoolUserBusiness biz = getSchoolUserBusiness(iwc);
      int[] userTypes = {
        SchoolUserBusinessBean.USER_TYPE_HEADMASTER,
        SchoolUserBusinessBean.USER_TYPE_ASSISTANT_HEADMASTER,
        SchoolUserBusinessBean.USER_TYPE_IB_COORDINATOR,
        SchoolUserBusinessBean.USER_TYPE_STUDY_AND_WORK_COUNCEL,
        SchoolUserBusinessBean.USER_TYPE_TEACHER,
        SchoolUserBusinessBean.USER_TYPE_WEB_ADMIN,
        SchoolUserBusinessBean.USER_TYPE_SCHOOL_MASTER,
        SchoolUserBusinessBean.USER_TYPE_CONTACT_PERSON,
        SchoolUserBusinessBean.USER_TYPE_EXPEDITION,
        SchoolUserBusinessBean.USER_TYPE_PROJECT_MANAGER
      };

      School prov = getProvider(iwc);

      if (prov == null) {
        SchoolUserHome userHome;
        userHome = (SchoolUserHome) IDOLookup.getHome(SchoolUser.class);
        Collection schoolUsers = userHome.findByTypes(userTypes);

        this.users = new Vector();
        Iterator iter = schoolUsers.iterator();
        while (iter.hasNext()) {
          SchoolUser sUser = (SchoolUser) iter.next();
          this.users.add(sUser.getUser());
        }
      } else {
        this.users = biz.getUsers(prov, userTypes);
      }
    } catch (FinderException ex) {
      ex.printStackTrace();
    } catch (RemoteException ex) {
      ex.printStackTrace();
    }
  }
 public String getGroupName() {
   if (groupId != -1) {
     try {
       GenericGroup gr =
           ((com.idega.core.data.GenericGroupHome)
                   com.idega.data.IDOLookup.getHomeLegacy(GenericGroup.class))
               .findByPrimaryKeyLegacy(groupId);
       return gr.getName();
     } catch (Exception ex) {
       return null;
     }
   }
   return null;
 }
  private void initCountries() {

    try {
      CountryHome countryHome = (CountryHome) IDOLookup.getHome(Country.class);
      Collection counts = countryHome.findAll();
      countries = new Hashtable(counts.size());
      for (Iterator iter = counts.iterator(); iter.hasNext(); ) {
        Country element = (Country) iter.next();
        countries.put(element.getIsoAbbreviation(), element);
      }
    } catch (IDOLookupException e) {
      e.printStackTrace();
    } catch (FinderException e) {
      e.printStackTrace();
    }
  }
 private void init(IWContext iwc) {
   String sGroupId = iwc.getParameter(PARAMETER_GROUP_ID);
   if (sGroupId != null) {
     try {
       GroupHome gHome = (GroupHome) IDOLookup.getHome(Group.class);
       this.group = gHome.findByPrimaryKey(new Integer(sGroupId));
     } catch (IDOLookupException e) {
       e.printStackTrace(System.err);
     } catch (NumberFormatException e) {
       e.printStackTrace(System.err);
     } catch (FinderException e) {
       e.printStackTrace(System.err);
     }
   }
   this.iwrb = getResourceBundle(iwc);
 }
  /**
   * @param cardnumber
   * @param parentDataPK
   * @param properties
   * @throws IDOLookupException
   * @throws CreateException
   */
  private void storeAuthorizationEntry(
      String encodedCardnumber, Object parentDataPK, Hashtable properties, String authorizationType)
      throws IDOLookupException, CreateException {
    KortathjonustanAuthorisationEntriesHome authHome =
        (KortathjonustanAuthorisationEntriesHome)
            IDOLookup.getHome(KortathjonustanAuthorisationEntries.class);
    auth = authHome.create();

    if (properties.containsKey(this.PROPERTY_AMOUNT))
      auth.setAmount(
          Double.parseDouble(
              properties.get(this.PROPERTY_AMOUNT).toString())); // Double.parseDouble(strAmount));
    if (properties.containsKey(this.PROPERTY_APPROVAL_CODE))
      auth.setAuthorizationCode(
          properties.get(this.PROPERTY_APPROVAL_CODE).toString()); // authCode);
    if (properties.containsKey(this.PROPERTY_CARD_BRAND_NAME))
      auth.setBrandName(properties.get(this.PROPERTY_CARD_BRAND_NAME).toString());
    if (properties.containsKey(this.PROPERTY_CC_EXPIRE))
      auth.setCardExpires(
          properties.get(this.PROPERTY_CC_EXPIRE).toString()); // monthExpires+yearExpires);
    if (properties.containsKey(this.PROPERTY_CURRENCY_CODE))
      auth.setCurrency(
          getCurrencyAbbreviation(
              properties.get(this.PROPERTY_CURRENCY_CODE).toString())); // currency);
    if (properties.containsKey(this.PROPERTY_ERROR_CODE))
      auth.setErrorNumber(properties.get(this.PROPERTY_ERROR_CODE).toString());
    if (properties.containsKey(this.PROPERTY_ERROR_TEXT))
      auth.setErrorText(properties.get(this.PROPERTY_ERROR_TEXT).toString());
    if (properties.containsKey(this.PROPERTY_TOTAL_RESPONSE))
      auth.setServerResponse(properties.get(this.PROPERTY_TOTAL_RESPONSE).toString());

    auth.setTransactionType(authorizationType);
    auth.setCardNumber(encodedCardnumber);
    auth.setDate(IWTimestamp.RightNow().getDate());

    if (parentDataPK != null) {
      try {
        auth.setParentID(((Integer) parentDataPK).intValue());
      } catch (Exception e) {
        System.out.println("KortathjonustanCCCleint : could not set parentID : " + parentDataPK);
      }
    }
    auth.store();
  }
 private void updateStartDataGroupRelationType() {
   /*
    * @todo Move to user plugin system
    **/
   // Temporary Fix to make sure GroupRelation table exists:
   new GroupRelationBMPBean();
   try {
     ICObjectTypeHome home = (ICObjectTypeHome) IDOLookup.getHome(ICObjectType.class);
     home.updateStartData();
   } catch (IDOLookupException e) {
     log.throwing(this.getClass().getName(), "updateStartDataGroupRelationType", e);
   } catch (IDOException e) {
     log.throwing(this.getClass().getName(), "updateStartDataGroupRelationType", e);
   }
   insertGroupRelationType("GROUP_PARENT");
   insertGroupRelationType("FAM_CHILD");
   insertGroupRelationType("FAM_PARENT");
   insertGroupRelationType("FAM_SPOUSE");
   insertGroupRelationType("FAM_CUSTODIAN");
   insertGroupRelationType("FAM_SIBLING");
 }
  private IWTimestamp getRejectionTimestamp(IWContext iwc, SchoolChoice choice)
      throws IDOLookupException, FinderException, RemoteException {

    IWTimestamp timestamp = null;
    final String denied = getSchoolChoiceBusiness(iwc).getCaseStatusDenied().getStatus();

    CaseLogHome caseLogHome = null;
    caseLogHome = (CaseLogHome) IDOLookup.getHome(CaseLog.class);

    Collection coll = caseLogHome.findAllCaseLogsByCase(choice);

    for (Iterator iter = coll.iterator(); iter.hasNext(); ) {
      CaseLog log = (CaseLog) iter.next();
      if (log.getStatusAfter().equals(denied)) {
        timestamp = new IWTimestamp(log.getTimeStamp());
        break;
      }
    }

    return timestamp;
  }
  /*
   * (non-Javadoc)
   *
   * @see com.idega.business.InputHandler#getResultingObject(java.lang.String, com.idega.presentation.IWContext)
   */
  public Object getResultingObject(String[] value, IWContext iwc) throws Exception {
    if (value != null) {
      Object pk = Integer.decode(value[0]);
      try {
        if (value != null) {
          SchoolSeason season =
              ((SchoolSeasonHome) IDOLookup.getHome(SchoolSeason.class)).findByPrimaryKey(pk);
          if (season != null) {
            return season;
          }
        }
      } catch (IDOLookupException e) {
        e.printStackTrace();
      } catch (FinderException e) {
        e.printStackTrace();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    return (null);
  }
 private void insertGroupRelationType(String groupRelationType) {
   /** @todo Move this to a more appropriate place */
   try {
     GroupRelationTypeHome grtHome =
         (GroupRelationTypeHome) com.idega.data.IDOLookup.getHome(GroupRelationType.class);
     GroupRelationType grType;
     try {
       grType = grtHome.findByPrimaryKey(groupRelationType);
     } catch (FinderException fe) {
       try {
         grType = grtHome.create();
         grType.setType(groupRelationType);
         grType.store();
         log.fine("Registered Group relation type: '" + groupRelationType + "'");
       } catch (CreateException e) {
         log.throwing(this.getClass().getName(), "insertGroupRelationType", e);
       }
     }
   } catch (IDOLookupException e) {
     log.throwing(this.getClass().getName(), "insertGroupRelationType", e);
   }
 }
 private void parseAction(IWContext iwc)
     throws NumberFormatException, IDOStoreException, IOException, RemoteException,
         FinderException {
   if (iwc.isParameterSet(ReportQueryBuilder.PARAM_LAYOUT_FOLDER_ID)) {
     this.layoutFolderId = iwc.getParameter(ReportQueryBuilder.PARAM_LAYOUT_FOLDER_ID);
   } else {
     return;
   }
   if (iwc.isParameterSet(KEY_QUERY_UPLOAD_IS_SUBMITTED)) {
     Object queryToBeReplacedId = iwc.getParameter(KEY_CHOSEN_QUERY_FOR_REPLACING);
     if (VALUE_DO_NOT_REPLACE_A_QUERY.equals(queryToBeReplacedId)) {
       queryToBeReplacedId = null;
     } else {
       queryToBeReplacedId = new Integer((String) queryToBeReplacedId);
     }
     UploadFile uploadFile = iwc.getUploadedFile();
     ICFile icFile = MediaBusiness.saveMediaToDBUploadFolder(uploadFile, iwc);
     String name = iwc.getParameter(KEY_QUERY_NAME);
     String permission = iwc.getParameter(KEY_PERMISSION);
     boolean isPrivate = PRIVATE.equals(permission);
     QueryService queryService =
         (QueryService) IBOLookup.getServiceInstance(iwc, QueryService.class);
     UserQuery userQuery =
         queryService.storeQuery(name, icFile, isPrivate, queryToBeReplacedId, iwc);
     this.userQueryId = ((Integer) userQuery.getPrimaryKey()).intValue();
   } else if (iwc.isParameterSet(KEY_QUERY_DOWNLOAD_IS_SUBMITTED)) {
     Object queryToBeDownloadedId = iwc.getParameter(KEY_CHOSEN_QUERY_FOR_DOWNLOADING);
     if (!VALUE_DO_NOT_REPLACE_A_QUERY.equals(queryToBeDownloadedId)) {
       Integer queryToBeDownloaded = new Integer((String) queryToBeDownloadedId);
       UserQueryHome userQueryHome = (UserQueryHome) IDOLookup.getHome(UserQuery.class);
       UserQuery userQuery = userQueryHome.findByPrimaryKey(queryToBeDownloaded);
       ICFile realQuery = userQuery.getSource();
       FileBusiness fileBusiness =
           (FileBusiness) IBOLookup.getServiceInstance(iwc, FileBusiness.class);
       this.downloadUrl = fileBusiness.getURLForOfferingDownload(realQuery, iwc);
     }
   }
 }
 private Collection getSchoolChoices(IWContext iwc) {
   Collection schoolChoices = new Vector();
   SchoolChoiceHome scHome;
   try {
     scHome = (SchoolChoiceHome) IDOLookup.getHome(SchoolChoice.class);
     String[] statuses =
         new String[] {getSchoolChoiceBusiness(iwc).getCaseStatusDenied().getStatus()};
     schoolChoices =
         scHome.findBySchoolIDAndSeasonIDAndStatus(
             this.schoolID,
             this.seasonID,
             statuses,
             this.ENTRIES_PER_PAGE,
             this.currentStartEntry);
   } catch (IDOLookupException e) {
     e.printStackTrace();
   } catch (RemoteException e) {
     e.printStackTrace();
   } catch (FinderException e) {
     e.printStackTrace();
   }
   return schoolChoices;
 }
  public String getUserNameDWR(String personalID, String localeStr) {
    try {
      if (personalID != null && !personalID.trim().equals("")) {
        UserHome uHome = (UserHome) IDOLookup.getHome(User.class);
        User user = uHome.findByPersonalID(personalID);
        return user.getName();
      } else {
        return "";
      }
    } catch (IDOLookupException e) {
      e.printStackTrace();
    } catch (FinderException e) {
    }

    try {
      IWContext iwc = IWContext.getInstance();
      Locale locale = iwc.getCurrentLocale();
      IWResourceBundle iwrb = getBundle().getResourceBundle(locale);
      return iwrb.getLocalizedString("landsmot.user_not_found", "User not found");
    } catch (UnavailableIWContext e) {
      return "User not found";
    }
  }
  private void testReferencedClasses() {
    ICObjectHome home = null;
    try {
      home = (ICObjectHome) IDOLookup.getHome(ICObject.class);
    } catch (IDOLookupException ex) {
      log.severe("Could not find home of ICObject");
      return;
    }
    // get the current classloader (it is the same that is used for "Class.forName()" )
    ClassLoader currentClassLoader = getClass().getClassLoader();
    try {
      SortedSet classNames = new TreeSet();
      Collection allICObjects = home.findAll();
      Iterator iterator = allICObjects.iterator();
      while (iterator.hasNext()) {
        ICObject object = (ICObject) iterator.next();
        String className = object.getClassName();
        try {
          // delay initialization, we are not using the class here
          RefactorClassRegistry.forName(className, false, currentClassLoader);
        } catch (ClassNotFoundException ex) {
          // bad luck
          classNames.add(className);
          // go ahead
        }
      }
      Iterator classNameIterator = classNames.iterator();
      while (classNameIterator.hasNext()) {
        String className = (String) classNameIterator.next();
        log.warning("Class " + className + " could not be found but is referenced as ICObject");
      }

    } catch (FinderException ex) {
      log.fine("Could not find any ICObjects");
    }
  }
  /* (non-Javadoc)
   * @see com.idega.builder.handler.ICPropertyHandler#getHandlerObject(java.lang.String, java.lang.String, com.idega.presentation.IWContext)
   */
  public PresentationObject getHandlerObject(
      String name,
      String stringValue,
      IWContext iwc,
      boolean oldGenerationHandler,
      String instanceId,
      String method) {
    IBObjectChooser chooser = new IBObjectChooser(name);
    chooser.setToUseClassValue(true);
    try {
      if (stringValue != null && !stringValue.equals("")) {
        ICObjectHome home = (ICObjectHome) IDOLookup.getHome(ICObject.class);
        chooser.setSelectedObject(home.findByClassName(stringValue));
      }
    } catch (IDOLookupException e) {
      e.printStackTrace();
    } catch (NumberFormatException e) {
      e.printStackTrace();
    } catch (FinderException e) {
      e.printStackTrace();
    }

    return chooser;
  }
 protected LocalizedTextHome getLocalizedTextHome() throws RemoteException {
   return (LocalizedTextHome) IDOLookup.getHome(LocalizedText.class);
 }
 protected ICLanguageHome getICLanguageHome() throws RemoteException {
   return (ICLanguageHome) IDOLookup.getHome(ICLanguage.class);
 }
 public SchoolCategoryHome getSchoolCategoryHome() throws RemoteException {
   return (SchoolCategoryHome) IDOLookup.getHome(SchoolCategory.class);
 }
 private SchoolClassMemberHome getSchoolClassMemberHome() throws RemoteException {
   return (SchoolClassMemberHome) IDOLookup.getHome(SchoolClassMember.class);
 }
    public void main(IWContext iwc) throws Exception {

      String save = iwc.getParameter("save");
      if (save != null) {
        String stringGroupId = iwc.getParameter(GroupGroupSetter.PARAMETER_GROUP_ID);
        int groupId = Integer.parseInt(stringGroupId);

        String[] related = iwc.getParameterValues(GroupGroupSetter.FIELDNAME_SELECTION_DOUBLE_BOX);

        GenericGroup group =
            ((com.idega.core.data.GenericGroupHome)
                    com.idega.data.IDOLookup.getHomeLegacy(GenericGroup.class))
                .findByPrimaryKeyLegacy(groupId);
        List currentRelationShip = group.getParentGroups();

        if (related != null) {

          if (currentRelationShip != null) {
            for (int i = 0; i < related.length; i++) {
              int id = Integer.parseInt(related[i]);
              GenericGroup gr =
                  ((com.idega.core.data.GenericGroupHome)
                          com.idega.data.IDOLookup.getHomeLegacy(GenericGroup.class))
                      .findByPrimaryKeyLegacy(id);
              if (!currentRelationShip.remove(gr)) {
                gr.addGroup(group);
              }
            }

            Iterator iter = currentRelationShip.iterator();
            while (iter.hasNext()) {
              Object item = iter.next();
              ((GenericGroup) item).removeGroup(group);
            }

          } else {
            for (int i = 0; i < related.length; i++) {
              ((com.idega.core.data.GenericGroupHome)
                      com.idega.data.IDOLookup.getHomeLegacy(GenericGroup.class))
                  .findByPrimaryKeyLegacy(Integer.parseInt(related[i]))
                  .addGroup(group);
            }
          }

        } else if (currentRelationShip != null) {
          Iterator iter = currentRelationShip.iterator();
          while (iter.hasNext()) {
            Object item = iter.next();
            ((GenericGroup) item).removeGroup(group);
          }
        }

        this.close();
        this.setParentToReload();
      } else {
        LineUpElements(iwc);
      }

      /*
            Enumeration enum = iwc.getParameterNames();
             System.err.println("--------------------------------------------------");
            if(enum != null){
              while (enum.hasMoreElements()) {
                Object item = enum.nextElement();
                if(item.equals("save")){
                  this.close();
                }
                String val[] = iwc.getParameterValues((String)item);
                System.err.print(item+" = ");
                if(val != null){
                  for (int i = 0; i < val.length; i++) {
                    System.err.print(val[i]+", ");
                  }
                }
                System.err.println();
              }
            }
      */
    }
  private Table getPlacementTable(IWContext iwc) throws RemoteException {
    Table table = new Table();
    // table.setColor("#DDDDDD");
    table.setBorder(0);
    table.setWidth(Table.HUNDRED_PERCENT);
    table.setCellpadding(1);
    table.setCellspacing(2);
    int col = 1;
    int row = 1;

    // *** HEADING Placements ***
    Text pupilTxt = new Text(localize(KEY_PLACEMENTS_HEADING, "Placements"));
    pupilTxt.setFontStyle(STYLE_UNDERLINED_SMALL_HEADER);
    table.add(pupilTxt, col++, row);
    table.setRowHeight(row, "40");
    table.setRowVerticalAlignment(row, Table.VERTICAL_ALIGN_BOTTOM);
    table.mergeCells(col, row, table.getColumns(), row);
    col = 1;
    row++;

    // empty space row
    table.add(this.transGIF, col, row);
    table.setRowHeight(row, "10");
    col = 1;
    row++;

    //  *** Column headings ***
    table.add(getLocalizedSmallHeader(KEY_NUMBER, "No."), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_SCHOOL_TYPE, "School type"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_PROVIDER, "Provider"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_SCHOOL_YEAR, "School year"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_STUDY_PATH, "Study path"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_SCHOOL_GROUP, "School group"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_START_DATE, "Start date"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_END_DATE, "End date"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_REGISTRATOR, "Registrator"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_REGISTRATION_CREATED_DATE, "Created date"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_PLACEMENT_PARAGRAPH_SHORT, "Par"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_NOTES, "Notes"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(Text.getNonBrakingSpace(), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(Text.getNonBrakingSpace(), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);

    table.setRowColor(row, getHeaderColor());

    table.setRowHeight(row, "18");
    row++;

    // Loop placements
    Collection placements = null;
    try {
      if (this.pupil != null) {
        placements =
            getSchoolBusiness(iwc)
                .getSchoolClassMemberHome()
                .findAllOrderedByRegisterDate(this.pupil);
      }
    } catch (FinderException e) {
    }

    if (placements != null && placements.size() > 0) {
      int zebra = 0;
      int rowNum = 0;
      table.add(new HiddenInput(PARAM_REMOVE_PLACEMENT, "-1"), 1, 1);
      for (Iterator iter = placements.iterator(); iter.hasNext(); ) {
        rowNum++;
        SchoolClassMember plc = (SchoolClassMember) iter.next();
        col = 1;

        // Row number
        table.add(getSmallText(String.valueOf(rowNum)), col++, row);
        // School type
        try {
          table.add(getSmallText(plc.getSchoolType().getName()), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Provider
        try {
          table.add(getSmallText(plc.getSchoolClass().getSchool().getName()), col++, row);
        } catch (Exception e) {
          col++;
        }
        // School year
        try {
          table.add(getSmallText(plc.getSchoolYear().getName()), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Study path
        try {
          if (plc.getStudyPathId() != -1) {
            SchoolStudyPathHome home =
                (SchoolStudyPathHome) IDOLookup.getHome(SchoolStudyPath.class);
            SchoolStudyPath sp = home.findByPrimaryKey(new Integer(plc.getStudyPathId()));
            table.add(getSmallText(sp.getCode()), col, row);
          }
        } catch (Exception e) {
        }
        col++;
        // School type
        try {
          table.add(getSmallText(plc.getSchoolClass().getSchoolClassName()), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Start date
        try {
          String dateStr =
              getCentralPlacementBusiness(iwc).getDateString(plc.getRegisterDate(), "yyyy-MM-dd");
          table.add(getSmallText(dateStr), col++, row);
        } catch (Exception e) {
          col++;
        }
        // End date
        try {
          String dateStr =
              getCentralPlacementBusiness(iwc).getDateString(plc.getRemovedDate(), "yyyy-MM-dd");
          table.add(getSmallText(dateStr), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Registrator
        try {
          int registratorID = plc.getRegistratorId();
          User registrator = getUserBusiness(iwc).getUser(registratorID);
          if (registrator != null) {
            Name name =
                new Name(
                    registrator.getFirstName(),
                    registrator.getMiddleName(),
                    registrator.getLastName());
            table.add(
                getSmallText(name.getName(iwc.getApplicationSettings().getDefaultLocale(), false)),
                col++,
                row);
          }
        } catch (Exception e) {
          col++;
        }
        // Created date
        try {
          String dateStr =
              getCentralPlacementBusiness(iwc)
                  .getDateString(plc.getRegistrationCreatedDate(), "yyyy-MM-dd");
          table.add(getSmallText(dateStr), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Placement paragraph
        try {
          if (plc.getPlacementParagraph() != null) {
            table.add(getSmallText(plc.getPlacementParagraph()), col++, row);
          } else {
            col++;
          }
        } catch (Exception e) {
          col++;
        }
        // Notes
        try {
          if (plc.getNotes() != null) {
            table.add(getSmallText(plc.getNotes()), col++, row);
          } else {
            col++;
          }
        } catch (Exception e) {
          col++;
        }
        // Pupil overview button
        try {
          // Get Pupil overview button
          String plcId = ((Integer) plc.getPrimaryKey()).toString();
          String schClassId = String.valueOf(plc.getSchoolClassId());

          Link editButt =
              new Link(this.getEditIcon(localize(KEY_TOOLTIP_PUPIL_OVERVIEW, "Pupil overview")));
          editButt.setWindowToOpen(PlacementHistoryEditPlacement.class);
          editButt.setParameter(
              SchoolAdminOverview.PARAMETER_METHOD,
              String.valueOf(SchoolAdminOverview.METHOD_OVERVIEW));
          editButt.addParameter(
              SchoolAdminOverview.PARAMETER_METHOD,
              String.valueOf(SchoolAdminOverview.METHOD_OVERVIEW));
          editButt.addParameter(SchoolAdminOverview.PARAMETER_SHOW_ONLY_OVERVIEW, "true");
          editButt.addParameter(SchoolAdminOverview.PARAMETER_SHOW_NO_CHOICES, "true");
          editButt.addParameter(SchoolAdminOverview.PARAMETER_PAGE_ID, getParentPage().getPageID());
          editButt.addParameter(
              SchoolAdminOverview.PARAMETER_USER_ID, String.valueOf(plc.getClassMemberId()));
          editButt.addParameter(SchoolAdminOverview.PARAMETER_SCHOOL_CLASS_ID, schClassId);
          editButt.addParameter(SchoolAdminOverview.PARAMETER_SCHOOL_CLASS_MEMBER_ID, plcId);
          editButt.addParameter(
              SchoolAdminOverview.PARAMETER_RESOURCE_PERMISSION,
              SchoolAdminOverview.PARAMETER_RESOURCE_PERM_VALUE_CENTRAL_ADMIN);
          editButt.addParameter(
              SchoolAdminOverview.PARAMETER_FROM_CENTRAL_PLACEMENT_EDITOR, "true");
          if (plc.getRemovedDate() != null) {
            editButt.addParameter(
                SchoolAdminOverview.PARAMETER_SCHOOL_CLASS_MEMBER_REMOVED_DATE,
                plc.getRemovedDate().toString());
          }

          table.add(editButt, col, row);
          table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
        } catch (Exception e) {
          col++;
        }
        // Remove button
        try {
          // Get remove button
          Image delImg = getDeleteIcon(localize(KEY_TOOLTIP_REMOVE_PLC, "Delete placement"));
          int plcID = ((Integer) plc.getPrimaryKey()).intValue();

          SubmitButton delButt = new SubmitButton(delImg);
          delButt.setValueOnClick(PARAM_REMOVE_PLACEMENT, String.valueOf(plcID));
          delButt.setSubmitConfirm(
              localize(
                  KEY_CONFIRM_REMOVE_PLC_MSG,
                  "Do you really want to erase this school placement and its resource placements?"));
          delButt.setToolTip(localize(KEY_TOOLTIP_REMOVE_PLC, "Delete school placement"));
          table.add(delButt, col, row);
          table.setAlignment(col, row, Table.HORIZONTAL_ALIGN_CENTER);
        } catch (Exception e) {
        }

        String zebraColor = zebra % 2 == 0 ? getZebraColor2() : getZebraColor1();
        table.setRowColor(row, zebraColor);
        col = 2;
        row++;

        // Resources
        String rscStr = getResourceBusiness(iwc).getResourcesStringXtraInfo(plc);
        if (!("".equals(rscStr))) {
          table.add(
              getSmallText("<i>" + localize(KEY_RESOURCES, "Resources") + ":</i> "), col, row);
          table.add(getSmallText("<i>" + rscStr + "</i>"), col, row);
          table.setRowColor(row, zebraColor);
          table.mergeCells(col, row, table.getColumns(), row);
          row++;
        }

        zebra++;
      }
    }

    col = 1;

    // empty space row
    table.add(this.transGIF, col, row);
    table.setRowHeight(row, "20");

    return table;
  }
  public String getPlacementString(SchoolClassMember placement, User user, IWResourceBundle iwrb) {
    // Placement
    StringBuffer buf = new StringBuffer("");
    try {
      // add school name
      buf.append(placement.getSchoolClass().getSchool().getName());
    } catch (Exception e) {
    }
    try {
      // school year
      SchoolYear theYear = placement.getSchoolYear();
      if (theYear != null) {
        buf.append(
            ", "
                + iwrb.getLocalizedString(
                    CentralPlacementEditorConstants.KEY_SCHOOL_YEAR, "school year")
                + " "
                + theYear.getName());
      }
    } catch (Exception e) {
    }
    try {
      // add school group
      buf.append(
          ", "
              + iwrb.getLocalizedString(CentralPlacementEditorConstants.KEY_SCHOOL_GROUP, "group")
              + " "
              + placement.getSchoolClass().getSchoolClassName());
    } catch (Exception e) {
    }
    try {
      // add study path
      if (placement.getStudyPathId() != -1) {
        SchoolStudyPathHome home = (SchoolStudyPathHome) IDOLookup.getHome(SchoolStudyPath.class);
        SchoolStudyPath sp = home.findByPrimaryKey(new Integer(placement.getStudyPathId()));
        buf.append(
            ", "
                + iwrb.getLocalizedString(
                    CentralPlacementEditorConstants.KEY_STUDY_PATH, "Study path")
                + " "
                + sp.getCode());
      }
    } catch (Exception e) {
    }

    try {
      // add language
      if (placement.getLanguage() != null && !("-1").equals(placement.getLanguage())) {
        buf.append(
            ", "
                + iwrb.getLocalizedString(CentralPlacementEditorConstants.KEY_LANGUAGE, "Language")
                + " "
                + iwrb.getLocalizedString(placement.getLanguage(), ""));
      }
    } catch (Exception e) {
    }

    try {
      // add native language
      if (user.getNativeLanguage() != null) {
        buf.append(
            ", "
                + iwrb.getLocalizedString(
                    CentralPlacementEditorConstants.KEY_NATIVE_LANGUAGE, "Native language")
                + " "
                + user.getNativeLanguage());
      }
    } catch (Exception e) {
    }
    return buf.toString();
  }