Example usage for org.apache.commons.lang WordUtils capitalizeFully

List of usage examples for org.apache.commons.lang WordUtils capitalizeFully

Introduction

In this page you can find the example usage for org.apache.commons.lang WordUtils capitalizeFully.

Prototype

public static String capitalizeFully(String str) 

Source Link

Document

Converts all the whitespace separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.

Usage

From source file:com.redsqirl.HelpBean.java

public final List<String[]> getHelpHtmlSuperActionList() {
    List<String[]> result = new ArrayList<String[]>();
    for (String name : helpHtmlSA.keySet()) {
        result.add(new String[] { name, WordUtils.capitalizeFully(name.replace("_", " ")) });
    }//w  w  w . j  av  a 2s  .  com

    Collections.sort(result, new Comparator<String[]>() {
        @Override
        public int compare(String[] o1, String[] o2) {
            return o1[0].compareTo(o2[0]);
        }
    });

    return result;
}

From source file:com.tripad.cootrack.erpCommon.upload.TMC_UpdateBusinessPartner.java

public BaseOBObject updateDataBPartner(final String organization, //rowOrganization
        final String sKey, final String commercialName, final String alamat, final String kota,
        final String negara, final String kodePos, final String phoneCompany, final String fax,
        final String priceList, final String paymentmethod, final String paymentTerm,
        final String financialAccount, final String firstName, final String lastName, final String email,
        final String phone

) throws Exception {

    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");

    //Customer : C_BPartner - cuma 1 record
    //Location : C_BPartner_Location - multiple
    //Contact  : AD_USER - multiple

    final OBCriteria<BusinessPartner> businessPartnerCriteria = OBDal.getInstance()
            .createCriteria(BusinessPartner.class);
    businessPartnerCriteria.add(Restrictions.eq(BusinessPartner.PROPERTY_SEARCHKEY, sKey));
    //businessPartnerCriteria.add(Restrictions.eq(BusinessPartner.PROPERTY_CLIENT, OBContext.getOBContext().getCurrentClient()));
    businessPartnerCriteria//from   w  w  w. ja  va 2 s  .c  o  m
            .add(Restrictions.eq(BusinessPartner.PROPERTY_CREATEDBY, OBContext.getOBContext().getUser()));

    if (businessPartnerCriteria.list().isEmpty()) {
        throw new OBException("BusinessPartner Not Found ! (" + sKey + ")");
    }

    for (BusinessPartner businessPartner : businessPartnerCriteria.list()) {
        businessPartnerData = businessPartner;
        businessPartnerData.setName(commercialName);

        //Customer
        if (isEdit(priceList)) {
            PriceList priceListExist = findDALInstance(false, PriceList.class,
                    new Value(PriceList.PROPERTY_NAME, priceList));
            if (priceListExist == null) {
                throw new OBException("Price List  \"" + priceList + "\" doesn't exists");
            }
            businessPartnerData.setPriceList(priceListExist);
        } else {
            businessPartnerData.setPriceList(null);
        }

        if (isEdit(paymentmethod)) {
            FIN_PaymentMethod paymentmethodExist = findDALInstance(false, FIN_PaymentMethod.class,
                    new Value(FIN_PaymentMethod.PROPERTY_NAME, paymentmethod));
            if (paymentmethodExist == null) {
                throw new OBException("Payment Method  \"" + paymentmethod + "\" doesn't exists");
            }
            businessPartnerData.setPaymentMethod(paymentmethodExist);
        } else {
            businessPartnerData.setPaymentMethod(null);
        }

        if (isEdit(paymentTerm)) {
            PaymentTerm paymentTermExist = findDALInstance(false, PaymentTerm.class,
                    new Value(PaymentTerm.PROPERTY_SEARCHKEY, paymentTerm));
            if (paymentTermExist == null) {
                throw new OBException("Payment Term  \"" + paymentTerm + "\" doesn't exists");
            }
            businessPartnerData.setPaymentTerms(paymentTermExist);
        } else {
            businessPartnerData.setPaymentTerms(null);
        }

        if (isEdit(financialAccount)) {
            FIN_FinancialAccount accountExist = findDALInstance(false, FIN_FinancialAccount.class,
                    new Value(FIN_FinancialAccount.PROPERTY_NAME, financialAccount));
            if (accountExist == null) {
                throw new OBException("Financial Account  \"" + financialAccount + "\" doesn't exists");
            }
            businessPartnerData.setAccount(accountExist);
        } else {
            businessPartnerData.setAccount(null);
        }

        //Country countryExist = null;

        Country countryExist = findDALInstance(false, Country.class,
                new Value(Country.PROPERTY_NAME, WordUtils.capitalizeFully(negara.trim())));
        if (countryExist == null) {
            throw new OBException("Country  \"" + negara.trim() + "\" doesn't exists");
        }
        //}

        OBCriteria<Location> locationBpCrit = OBDal.getInstance().createCriteria(Location.class);
        locationBpCrit.add(Restrictions.eq(Location.PROPERTY_CREATEDBY, OBContext.getOBContext().getUser()));
        locationBpCrit
                .add(Restrictions.eq(Location.PROPERTY_NAME, getBPLocationName(kota.trim(), alamat.trim())));
        locationBpCrit.add(Restrictions.eq(Location.PROPERTY_BUSINESSPARTNER, businessPartnerData));

        if (locationBpCrit.list().isEmpty()) { //check apakah Bisnis Partner location dengan nama yg sama sudah ada ? samakan yg alama dengan excel : buat baru
            locationBpartnerData = OBProvider.getInstance().get(Location.class);
            locationBpartnerData.setActive(true);
            OBCriteria<org.openbravo.model.common.geography.Location> locationCrit = OBDal.getInstance()
                    .createCriteria(org.openbravo.model.common.geography.Location.class);
            locationCrit.add(Restrictions.eq(org.openbravo.model.common.geography.Location.PROPERTY_CREATEDBY,
                    OBContext.getOBContext().getUser()));
            locationCrit.add(Restrictions
                    .sqlRestriction("UPPER(TRIM(address1)) = UPPER(TRIM('" + alamat.trim() + "'))"));//eq(org.openbravo.model.common.geography.Location.PROPERTY_ADDRESSLINE1, alamat));
            locationCrit
                    .add(Restrictions.sqlRestriction("UPPER(TRIM(city)) = UPPER(TRIM('" + kota.trim() + "'))"));//locationCrit.add(Restrictions.eq(org.openbravo.model.common.geography.Location.PROPERTY_CITYNAME, kota));
            locationCrit.add(
                    Restrictions.sqlRestriction("UPPER(TRIM(postal)) = UPPER(TRIM('" + kodePos.trim() + "'))"));
            locationCrit.add(Restrictions.eq(org.openbravo.model.common.geography.Location.PROPERTY_COUNTRY,
                    countryExist));
            if (locationCrit.list().isEmpty()) { //check apakah Location dengan alamat di atas sudah ada ? : update yg lama, samakan dengan excel : buat baru
                locationData = OBProvider.getInstance()
                        .get(org.openbravo.model.common.geography.Location.class);
                locationData.setActive(true);
                locationData.setAddressLine1(alamat.trim());
                locationData.setCityName(kota.trim());
                locationData.setCountry(countryExist);
                locationData.setPostalCode(kodePos.trim());
                OBDal.getInstance().save(locationData);
            } else {
                locationData = locationCrit.list().get(0);
                locationData.setAddressLine1(alamat.trim());
                locationData.setCityName(kota.trim());
                locationData.setCountry(countryExist);
                locationData.setPostalCode(kodePos.trim());
            }
            if (locationData != null) {
                locationBpartnerData.setLocationAddress(locationData);
            } else {
                throw new OBException("Error : locationData variable is null");
            }
            locationBpartnerData.setBusinessPartner(businessPartnerData);
            locationBpartnerData.setName(getBPLocationName(kota.trim(), alamat.trim()));
            locationBpartnerData.setPhone(phoneCompany);
            locationBpartnerData.setFax(fax);
            OBDal.getInstance().save(locationBpartnerData);
        } else {
            for (Location locBPExisting : locationBpCrit.list()) {

                //for (org.openbravo.model.common.geography.Location locExisting : locBPExisting.getLocationAddress().getBusinessPartnerLocationList()) {
                locBPExisting.getLocationAddress().setAddressLine1(alamat.trim());
                locBPExisting.getLocationAddress().setCityName(kota.trim());
                locBPExisting.getLocationAddress().setCountry(countryExist);
                locBPExisting.getLocationAddress().setPostalCode(kodePos.trim());

                //locBPExisting.setBusinessPartner(businessPartnerData);
                locBPExisting.setName(getBPLocationName(kota.trim(), alamat.trim()));
                locBPExisting.setPhone(phoneCompany);
                locBPExisting.setFax(fax);
                OBDal.getInstance().save(locBPExisting);
                //}
            }
        }

        //Contact
        OBCriteria<User> contactCrit = OBDal.getInstance().createCriteria(User.class);
        contactCrit.add(Restrictions.eq(User.PROPERTY_CREATEDBY, OBContext.getOBContext().getUser()));
        contactCrit.add(Restrictions.eq(User.PROPERTY_BUSINESSPARTNER, businessPartnerData));
        contactCrit.add(Restrictions
                .sqlRestriction("UPPER(TRIM(firstname)) = UPPER(TRIM('" + firstName.trim() + "'))"));
        contactCrit.add(
                Restrictions.sqlRestriction("UPPER(TRIM(lastname)) = UPPER(TRIM('" + lastName.trim() + "'))"));
        contactCrit
                .add(Restrictions.sqlRestriction("UPPER(TRIM(email)) = UPPER(TRIM('" + email.trim() + "'))"));
        contactCrit
                .add(Restrictions.sqlRestriction("UPPER(TRIM(phone)) = UPPER(TRIM('" + phone.trim() + "'))"));

        if (contactCrit.list().isEmpty()) { //bila kosong / blm ada sebelumnya ? buat baru : edit yg lama, sesuaikan dengan excel
            contactData = OBProvider.getInstance().get(User.class);
            contactData.setActive(true);
            contactData.setFirstName(firstName.trim());
            contactData.setLastName(lastName.trim());
            contactData.setEmail(email.trim());
            contactData.setPhone(phone.trim());
            contactData.setName(firstName.trim() + " " + lastName.trim());
            contactData.setBusinessPartner(businessPartnerData);
            OBDal.getInstance().save(contactData);
        } else {
            for (User existingUser : contactCrit.list()) {
                existingUser.setFirstName(firstName.trim());
                existingUser.setLastName(lastName.trim());
                existingUser.setEmail(email.trim());
                existingUser.setPhone(phone.trim());
                existingUser.setName(firstName.trim() + " " + lastName.trim());
                OBDal.getInstance().save(existingUser);
            }
        }

        //sHRLeaveEncash = OBProvider.getInstance().get(SHRLeaveEncash.class);
        //sHRLeaveEncash.setActive(true);

        OBDal.getInstance().save(businessPartnerData);
        OBDal.getInstance().flush();
    }

    return businessPartnerData;
}

From source file:com.googlecode.jmxtrans.model.output.InfluxDbWriterTests.java

private String enumValueToAttribute(ResultAttribute attribute) {
    String[] split = attribute.name().split("_");
    return StringUtils.lowerCase(split[0]) + WordUtils.capitalizeFully(split[1]);
}

From source file:com.redsqirl.interaction.TableInteraction.java

private void mountTableInteractionConstraint(Tree<String> dfeInteractionTree) throws RemoteException {
    List<SelectItem> listFields = new ArrayList<SelectItem>();
    if (dfeInteractionTree.getFirstChild("constraint").getFirstChild("values") != null) {
        List<Tree<String>> list = dfeInteractionTree.getFirstChild("constraint").getFirstChild("values")
                .getSubTreeList();/*  w ww  . j a va  2s.c  o m*/

        if (list != null) {
            // logger.info("list not null: " + list.toString());
            for (Tree<String> tree : list) {
                if (tree.getFirstChild() != null && !tree.getFirstChild().getHead().isEmpty()) {
                    logger.info("list value " + tree.getFirstChild().getHead());
                    listFields.add(
                            new SelectItem(tree.getFirstChild().getHead(), tree.getFirstChild().getHead()));
                }
            }
        }
        Collections.sort(listFields, new SelectItemComparator());
        tableConstraints.put(
                WordUtils.capitalizeFully(
                        dfeInteractionTree.getFirstChild("title").getFirstChild().getHead().replace("_", " ")),
                listFields);
        tableConstraintsString.put(
                WordUtils.capitalizeFully(
                        dfeInteractionTree.getFirstChild("title").getFirstChild().getHead().replace("_", " ")),
                calcString(listFields));
    }
}

From source file:com.redsqirl.dynamictable.SelectableTable.java

public void sortRows(String collun) {
    final int index = getTitles().indexOf(WordUtils.capitalizeFully(collun));
    if (index != -1) {
        List<SelectableRow> list = getRows();
        Collections.sort(list, new Comparator<SelectableRow>() {
            @Override/*  ww w. ja va2 s  .  com*/
            public int compare(SelectableRow s1, SelectableRow s2) {
                return s1.getRow()[index].compareTo(s2.getRow()[index]);
            }
        });
    }
}

From source file:de.Keyle.MyPet.listeners.EntityListener.java

@EventHandler
public void onMyPetEntityDamageByEntity(final EntityDamageByEntityEvent event) {
    if (event.getEntity() instanceof MyPetBukkitEntity) {
        MyPetBukkitEntity craftMyPet = (MyPetBukkitEntity) event.getEntity();
        MyPet myPet = craftMyPet.getMyPet();
        if (event.getDamager() instanceof Player || (event.getDamager() instanceof Projectile
                && ((Projectile) event.getDamager()).getShooter() instanceof Player)) {
            Player damager;/*from w  w  w .j av  a 2s .  co  m*/
            if (event.getDamager() instanceof Projectile) {
                damager = (Player) ((Projectile) event.getDamager()).getShooter();
            } else {
                damager = (Player) event.getDamager();
            }
            if (MyPetApi.getMyPetInfo().getLeashItem(myPet.getPetType()).compare(damager.getItemInHand())) {
                boolean infoShown = false;
                if (CommandInfo.canSee(PetInfoDisplay.Name.adminOnly, damager, myPet)) {
                    damager.sendMessage(ChatColor.AQUA + myPet.getPetName() + ChatColor.RESET + ":");
                    infoShown = true;
                }
                if (CommandInfo.canSee(PetInfoDisplay.Owner.adminOnly, damager, myPet)
                        && myPet.getOwner().getPlayer() != damager) {
                    damager.sendMessage("   " + Translation.getString("Name.Owner", damager) + ": "
                            + myPet.getOwner().getName());
                    infoShown = true;
                }
                if (CommandInfo.canSee(PetInfoDisplay.HP.adminOnly, damager, myPet)) {
                    String msg;
                    if (myPet.getHealth() > myPet.getMaxHealth() / 3 * 2) {
                        msg = "" + ChatColor.GREEN;
                    } else if (myPet.getHealth() > myPet.getMaxHealth() / 3) {
                        msg = "" + ChatColor.YELLOW;
                    } else {
                        msg = "" + ChatColor.RED;
                    }
                    msg += String.format("%1.2f", myPet.getHealth()) + ChatColor.WHITE + "/"
                            + String.format("%1.2f", myPet.getMaxHealth());
                    damager.sendMessage("   " + Translation.getString("Name.HP", damager) + ": " + msg);
                    infoShown = true;
                }
                if (myPet.getStatus() == PetState.Dead
                        && CommandInfo.canSee(PetInfoDisplay.RespawnTime.adminOnly, damager, myPet)) {
                    damager.sendMessage("   " + Translation.getString("Name.Respawntime", damager) + ": "
                            + myPet.getRespawnTime());
                    infoShown = true;
                }
                if (!myPet.isPassiv() && CommandInfo.canSee(PetInfoDisplay.Damage.adminOnly, damager, myPet)) {
                    double damage = (myPet.getSkills().isSkillActive(Damage.class)
                            ? myPet.getSkills().getSkill(Damage.class).get().getDamage()
                            : 0);
                    damager.sendMessage("   " + Translation.getString("Name.Damage", damager) + ": "
                            + String.format("%1.2f", damage));
                    infoShown = true;
                }
                if (myPet.getRangedDamage() > 0
                        && CommandInfo.canSee(PetInfoDisplay.RangedDamage.adminOnly, damager, myPet)) {
                    double damage = myPet.getRangedDamage();
                    damager.sendMessage("   " + Translation.getString("Name.RangedDamage", damager) + ": "
                            + String.format("%1.2f", damage));
                    infoShown = true;
                }
                if (myPet.getSkills().hasSkill(Behavior.class)
                        && CommandInfo.canSee(PetInfoDisplay.Behavior.adminOnly, damager, myPet)) {
                    Behavior behavior = myPet.getSkills().getSkill(Behavior.class).get();
                    damager.sendMessage("   " + Translation.getString("Name.Skill.Behavior", damager) + ": "
                            + Translation.getString("Name." + behavior.getBehavior().name(), damager));
                    infoShown = true;
                }
                if (Configuration.HungerSystem.USE_HUNGER_SYSTEM
                        && CommandInfo.canSee(PetInfoDisplay.Hunger.adminOnly, damager, myPet)) {
                    damager.sendMessage("   " + Translation.getString("Name.Hunger", damager) + ": "
                            + Math.round(myPet.getHungerValue()));

                    FancyMessage m = new FancyMessage(
                            "   " + Translation.getString("Name.Food", damager) + ": ");
                    boolean comma = false;
                    for (ConfigItem material : MyPetApi.getMyPetInfo().getFood(myPet.getPetType())) {
                        ItemStack is = material.getItem();
                        if (is == null) {
                            continue;
                        }
                        if (comma) {
                            m.then(", ");
                        }
                        if (is.hasItemMeta() && is.getItemMeta().hasDisplayName()) {
                            m.then(is.getItemMeta().getDisplayName());
                        } else {
                            m.then(WordUtils.capitalizeFully(MyPetApi.getPlatformHelper()
                                    .getMaterialName(material.getItem().getTypeId()).replace("_", " ")));
                        }
                        m.color(ChatColor.GOLD);
                        ItemTooltip it = new ItemTooltip();
                        it.setMaterial(is.getType());
                        if (is.hasItemMeta()) {
                            if (is.getItemMeta().hasDisplayName()) {
                                it.setTitle(is.getItemMeta().getDisplayName());
                            }
                            if (is.getItemMeta().hasLore()) {
                                it.setLore(is.getItemMeta().getLore()
                                        .toArray(new String[is.getItemMeta().getLore().size()]));
                            }
                        }
                        m.itemTooltip(it);
                        comma = true;
                    }
                    MyPetApi.getPlatformHelper().sendMessageRaw(damager, m.toJSONString());

                    infoShown = true;
                }
                if (CommandInfo.canSee(PetInfoDisplay.Skilltree.adminOnly, damager, myPet)
                        && myPet.getSkilltree() != null) {
                    damager.sendMessage("   " + Translation.getString("Name.Skilltree", damager) + ": "
                            + myPet.getSkilltree().getName());
                    infoShown = true;
                }
                if (CommandInfo.canSee(PetInfoDisplay.Level.adminOnly, damager, myPet)) {
                    int lvl = myPet.getExperience().getLevel();
                    damager.sendMessage("   " + Translation.getString("Name.Level", damager) + ": " + lvl);
                    infoShown = true;
                }
                int maxLevel = myPet.getSkilltree() != null ? myPet.getSkilltree().getMaxLevel()
                        : Configuration.LevelSystem.Experience.LEVEL_CAP;
                if (CommandInfo.canSee(PetInfoDisplay.Exp.adminOnly, damager, myPet)
                        && myPet.getExperience().getLevel() < maxLevel) {
                    double exp = myPet.getExperience().getCurrentExp();
                    double reqEXP = myPet.getExperience().getRequiredExp();
                    damager.sendMessage("   " + Translation.getString("Name.Exp", damager) + ": "
                            + String.format("%1.2f", exp) + "/" + String.format("%1.2f", reqEXP));
                    infoShown = true;
                }
                if (myPet.getOwner().getDonationRank() != DonateCheck.DonationRank.None) {
                    infoShown = true;
                    damager.sendMessage("   " + myPet.getOwner().getDonationRank().getDisplayText());
                }

                if (!infoShown) {
                    damager.sendMessage(Translation.getString("Message.No.NothingToSeeHere",
                            myPet.getOwner().getLanguage()));
                }

                event.setCancelled(true);
            } else if (myPet.getOwner().equals(damager) && (!Configuration.Misc.OWNER_CAN_ATTACK_PET
                    || !PvPChecker.canHurt(myPet.getOwner().getPlayer()))) {
                event.setCancelled(true);
            } else if (!myPet.getOwner().equals(damager)
                    && !PvPChecker.canHurt(damager, myPet.getOwner().getPlayer(), true)) {
                event.setCancelled(true);
            }
        }
        if (event.getDamager() instanceof CraftMyPetProjectile) {
            EntityMyPetProjectile projectile = ((CraftMyPetProjectile) event.getDamager()).getMyPetProjectile();

            if (myPet == projectile.getShooter().getMyPet()) {
                event.setCancelled(true);
            }
            if (!PvPChecker.canHurt(projectile.getShooter().getOwner().getPlayer(),
                    myPet.getOwner().getPlayer(), true)) {
                event.setCancelled(true);
            }
        }
        if (!event.isCancelled() && event.getDamager() instanceof LivingEntity) {
            LivingEntity damager = (LivingEntity) event.getDamager();
            if (damager instanceof Player) {
                if (!PvPChecker.canHurt(myPet.getOwner().getPlayer(), (Player) damager, true)) {
                    return;
                }
            }

            if (myPet.getSkills().isSkillActive(Thorns.class)) {
                if (damager instanceof Creeper) {
                    return;
                }
                Thorns thornsSkill = myPet.getSkills().getSkill(Thorns.class).get();
                if (thornsSkill.activate()) {
                    isSkillActive = true;
                    thornsSkill.reflectDamage(damager, event.getDamage());
                    isSkillActive = false;
                }
            }
        }
    }
}

From source file:com.redsqirl.CanvasModal.java

/**
 * Open Canvas Modal//from w w  w  .j ava  2s.  com
 * 
 * @return
 * @author Igor.Souza
 * @throws RemoteException
 */
public String[] getOpenCanvasModal() throws RemoteException {
    logger.info("openCanvasModal");

    String error = null;

    FacesContext context = FacesContext.getCurrentInstance();
    canvasBean = (CanvasBean) context.getApplication().evaluateExpressionGet(context, "#{canvasBean}",
            CanvasBean.class);

    HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext()
            .getRequest();

    // set the first tab for obj
    String selTab = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap()
            .get("paramSelectedTab");
    if (selTab == null || selTab.isEmpty() || selTab.equalsIgnoreCase("undefined")) {
        selTab = "confTabCM";
    }
    //logger.info("selected tab: " + selTab);
    setSelectedTab(selTab);

    // Don't update the element if you it close immediately
    elementToUpdate = false;
    cleanEl = false;

    // Get the image
    pathImage = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap()
            .get("paramPathImage");

    // Get the Element
    idGroup = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap()
            .get("paramGroupId");

    Integer pageNb = 0;
    String pageNbParam = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap()
            .get("paramPageNb");
    if (pageNbParam != null && !pageNbParam.isEmpty() && !pageNbParam.equalsIgnoreCase("undefined")) {
        try {
            pageNb = Integer.parseInt(FacesContext.getCurrentInstance().getExternalContext()
                    .getRequestParameterMap().get("paramPageNb"));
        } catch (NumberFormatException e) {
            pageNb = 0;
            logger.warn("Page nb issue: " + e.getMessage(), e);
        }
    }

    try {
        dfe = canvasBean.getDf().getElement(canvasBean.getIdElement(idGroup));
        //logger.info("Get element dfe");
    } catch (RemoteException e) {
        logger.error(e.getMessage(), e);
    }

    String paramLMW = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap()
            .get("paramLoadMainWindow");
    if (paramLMW != null) {
        loadMainWindow = !paramLMW.equalsIgnoreCase("false");
    } else {
        loadMainWindow = true;
    }

    if (dfe == null) {
        logger.info("The element is null!");
        error = getMessageResources("msg_error_oops");
    } else {
        elementId = getComponentId();
        //logger.info("Element id: "+elementId);
        elementComment = dfe.getComment();
        if (loadMainWindow) {
            //logger.info("load Main window");
            try {

                // validate if you can open or not the dynamic form of the object
                error = dfe.checkIn();

                //logger.info("error " + error);

                if (error == null) {

                    // mount output tab
                    outputTab = new CanvasModalOutputTab(datastores, dfe);
                    Iterator<DFEInteraction> iterIt = dfe.getInteractions().iterator();
                    sourceNode = false;
                    while (iterIt.hasNext() && !sourceNode) {
                        sourceNode = iterIt.next().getDisplay().equals(DisplayType.browser);
                    }

                    if (sourceNode && dfe.getDFEOutput().size() <= 1) {
                        outputTab.setShowOutputForm("N");
                    }

                    listPageSize = getPageList().size();

                    //initialise the position of list and check all pages before
                    setListPosition(pageNb);
                    String e = null;
                    if (pageNb > 0) {
                        int i = -1;
                        while (e == null && i < Math.min(pageNb, listPageSize)) {
                            ++i;
                            dfe.update(i);
                            e = getPageList().get(i).checkPage();
                        }
                        setListPosition(i);
                    }
                    //specific error message to validation object
                    if (e != null) {
                        logger.info("openCanvasModal checkpages before " + e);
                        MessageUseful.addErrorMessage(e);
                        request.setAttribute("msnErrorPage", "msnErrorPage");
                        usageRecordLog().addError("ERROR OPENCANVASMODAL", e);
                    }

                    // retrieves the correct page
                    setCanvasTitle(
                            WordUtils.capitalizeFully(dfe.getName().replace("_", " ")) + ": " + elementId);

                    if (listPageSize > 0) {
                        mountInteractionForm();
                    } else {
                        updateOutputElement();
                    }

                    outputTab.mountOutputForm(!sourceNode || dfe.getDFEOutput().size() > 1);

                    checkVoronoiTab();

                    checkFirstPage();

                    //logger.info("List size " + getListPageSize());

                    checkLastPage();

                }

            } catch (RemoteException e) {
                logger.error(e, e);
            } catch (Exception e) {
                logger.error(e, e);
            }
        }

    }

    //logger.info("listPage:"+ Integer.toString(getListPageSize()) + " getIdGroup:" + getIdGroup()+ " getCurElId:"+getCurElId()+ " getCurElComment:"+getCurElComment());
    boolean loadOutputTab = false;
    String cloneWFId = null;
    try {
        loadOutputTab = loadMainWindow
                && ((canvasBean.getWorkflowType().equals("W") && (getOutputTab().getShowOutputForm() != null
                        && getOutputTab().getShowOutputForm().equals("Y")) || getListPageSize() > 0));
        cloneWFId = canvasBean.cloneWorkflowGetId();
    } catch (Exception e) {
    }

    displayErrorMessage(error, "OPENCANVASMODAL");

    String[] ans = new String[] { Boolean.toString(loadOutputTab), Integer.toString(pageNb), getIdGroup(),
            getCurElId(), getCurElComment(), Boolean.toString(loadMainWindow), cloneWFId };

    logger.info(ans[0] + ", " + ans[1] + ", " + ans[2] + ", " + ans[3] + ", " + ans[4] + ", " + ans[5] + ", "
            + ans[6]);

    return ans;
}

From source file:com.redsqirl.workflow.server.ActionManager.java

public void addPackageToFooter(Collection<String> packageNames) throws RemoteException {
    Map<String, List<String>> footer = getFooter();
    String user = System.getProperty("user.name");
    PackageManager pm = new PackageManager();
    Iterator<String> packIt = packageNames.iterator();
    while (packIt.hasNext()) {
        String packName = packIt.next();
        RedSqirlPackage pck = pm.getAvailablePackage(user, packName);
        String packFooterName = WordUtils
                .capitalizeFully(packName.replace("redsqirl-", "").replace("_", " ").replace("-", " "))
                .replace(" ", "_");
        List<String> packActions = pck.getAction();
        if (!footer.containsKey(packFooterName)) {
            footer.put(packFooterName, new ArrayList<String>(packActions.size()));
        }/*  w w w .ja  v a  2 s .  co m*/
        Iterator<String> actIt = packActions.iterator();
        while (actIt.hasNext()) {
            String cur = actIt.next();
            if (!footer.get(packFooterName).contains(cur)) {
                footer.get(packFooterName).add(cur);
            }
        }
    }
    loadMenu(footer);
    saveMenu();
    packageNotified(packageNames);
}

From source file:com.redsqirl.interaction.TableInteraction.java

public SelectableTable generateLinesTableInteractionPanel(SelectableTable tg, String generetor) {
    if (tableGeneratorRowToInsert.containsKey(generetor)) {
        logger.info("Number of row to add: " + tableGeneratorRowToInsert.get(generetor).size());
        int index = 0;
        for (Map<String, String> l : tableGeneratorRowToInsert.get(generetor)) {
            String[] value = new String[l.size()];
            for (String column : l.keySet()) {
                if (tg.columnIdsIndexOf(WordUtils.capitalizeFully(column.replace("_", " "))) >= 0) {
                    value[tg.columnIdsIndexOf(WordUtils.capitalizeFully(column.replace("_", " ")))] = l
                            .get(column);
                }//from w w w . ja va 2  s . c om
            }
            SelectableRow s = new SelectableRow(value);
            s.setNameTabHidden(index + 1 + generetor);
            s.setNameTab(WordUtils.capitalizeFully(generetor));
            tg.add(s);
            index++;
        }
    }
    return tg;
}

From source file:com.sfs.whichdoctor.dao.onlineapplication.BasicTrainingOnlineApplicationHandler.java

/**
 * Load person details from the XML application.
 *
 * @param root the root of the XML application
 * @return the person bean/*from w  w w  .  j  a va 2  s .  c  o m*/
 */
private PersonBean loadPersonDetails(final Element root) {
    PersonBean person = new PersonBean();

    Element pd = root.getChild("personaldetails");
    try {
        String name = pd.getChildText("firstname").trim();
        person.setFirstName(name);
        if (StringUtils.contains(name, " ")) {
            // Split the first and middle names
            person.setFirstName(StringUtils.substringBefore(name, " "));
            person.setMiddleName(StringUtils.substringAfter(name, " "));
        }
    } catch (Exception e) {
        dataLogger.error("Error parsing firstname: " + e.getMessage());
    }
    try {
        person.setPreferredName(pd.getChildText("prefname").trim());
    } catch (Exception e) {
        dataLogger.error("Error parsing prefname: " + e.getMessage());
    }
    try {
        person.setLastName(pd.getChildText("lastname").trim());
    } catch (Exception e) {
        dataLogger.error("Error parsing lastname: " + e.getMessage());
    }
    try {
        String birthDate = pd.getChildText("dob").trim();
        person.setBirthDate(parseDate(birthDate));
    } catch (Exception e) {
        dataLogger.error("Error parsing dob: " + e.getMessage());
    }
    try {
        String gender = pd.getChildText("gender").trim();
        person.setGender(WordUtils.capitalizeFully(gender));
    } catch (Exception e) {
        dataLogger.error("Error parsing lastname: " + e.getMessage());
    }
    person.setTitle("Dr");

    return person;
}