public String objectToString(final Object object) {
   if (object == null || object instanceof String == false) {
     return "";
   }
   final String number = (String) object;
   return number
       + '|'
       + StringHelper.removeNonDigits(number)
       + '|'
       + NumberHelper.extractPhonenumber(number);
 }
コード例 #2
0
 @Override
 public synchronized PFUserDO deserialize(
     final JsonElement jsonElement,
     final Type type,
     final JsonDeserializationContext jsonDeserializationContext) {
   final Integer userId = NumberHelper.parseInteger(jsonElement.getAsString());
   if (userId == null) {
     return null;
   }
   return Registry.instance().getUserGroupCache().getUser(userId);
 }
コード例 #3
0
 /**
  * For special phone numbers: id:# or # | name.
  *
  * @return true, if the phone number was successfully processed.
  */
 private boolean processPhoneNumber() {
   final String phoneNumber = form.getPhoneNumber();
   if (StringUtils.isNotEmpty(phoneNumber) == true) {
     if (phoneNumber.startsWith("id:") == true && phoneNumber.length() > 3) {
       final Integer id = NumberHelper.parseInteger(phoneNumber.substring(3));
       if (id != null) {
         form.setPhoneNumber("");
         final AddressDO address = addressDao.getById(id);
         if (address != null) {
           form.setAddress(address);
           final String no = getFirstPhoneNumber();
           if (StringUtils.isNotEmpty(no) == true) {
             setPhoneNumber(no, true);
           }
         }
       }
       return true;
     } else if (phoneNumber.indexOf(SEPARATOR) >= 0) {
       final int pos = phoneNumber.indexOf(SEPARATOR);
       final String rest = phoneNumber.substring(pos + SEPARATOR.length());
       final int numberPos = rest.indexOf('#');
       form.setPhoneNumber(phoneNumber.substring(0, pos));
       if (numberPos > 0) {
         final Integer id = NumberHelper.parseInteger(rest.substring(numberPos + 1));
         if (id != null) {
           final AddressDO address = addressDao.getById(id);
           if (address != null) {
             form.setAddress(address);
           }
         } else {
           form.setAddress(null);
         }
       } else {
         form.setAddress(null);
       }
       return true;
     }
   }
   return false;
 }
コード例 #4
0
 String extractPhonenumber(final String number) {
   final String result =
       NumberHelper.extractPhonenumber(
           number,
           Configuration.getInstance()
               .getStringValue(ConfigurationParam.DEFAULT_COUNTRY_PHONE_PREFIX));
   if (StringUtils.isNotEmpty(result) == true
       && StringUtils.isNotEmpty(ConfigXml.getInstance().getTelephoneSystemNumber()) == true
       && result.startsWith(ConfigXml.getInstance().getTelephoneSystemNumber()) == true) {
     return result.substring(ConfigXml.getInstance().getTelephoneSystemNumber().length());
   }
   return result;
 }
コード例 #5
0
 /**
  * @see org.projectforge.ldap.LdapDao#mapToObject(java.lang.String,
  *     javax.naming.directory.Attributes)
  */
 @Override
 protected LdapGroup mapToObject(final String dn, final Attributes attributes)
     throws NamingException {
   final LdapGroup group = new LdapGroup();
   group.setBusinessCategory(LdapUtils.getAttributeStringValue(attributes, "businessCategory"));
   group.setDescription(LdapUtils.getAttributeStringValue(attributes, "description"));
   group.setOrganization(LdapUtils.getAttributeStringValue(attributes, "o"));
   final String[] members = LdapUtils.getAttributeStringValues(attributes, "uniqueMember");
   if (members != null) {
     for (final String member : members) {
       group.addMember(member, ldapConfig.getBaseDN());
     }
   }
   final boolean posixAccountsConfigured = isPosixAccountsConfigured();
   if (posixAccountsConfigured == true) {
     final String no = LdapUtils.getAttributeStringValue(attributes, "gidNumber");
     group.setGidNumber(NumberHelper.parseInteger(no));
   }
   return group;
 }
コード例 #6
0
 /**
  * @param pageParameters
  * @param key
  * @param objectType
  * @see #putPageParameter(PageParameters, String, Object)
  */
 public static Object getPageParameter(
     final PageParameters pageParameters, final String key, final Class<?> objectType) {
   if (objectType.isAssignableFrom(Date.class) == true) {
     final StringValue sval = pageParameters.get(key);
     if (sval.isNull() == true) {
       return null;
     }
     return new Date(sval.toLongObject());
   } else if (objectType.isAssignableFrom(Boolean.class) == true) {
     return pageParameters.get(key).toBooleanObject();
   } else if (objectType.isPrimitive() == true) {
     if (Boolean.TYPE.equals(objectType)) {
       return pageParameters.get(key).toBooleanObject();
     } else if (Integer.TYPE.equals(objectType) == true) {
       return pageParameters.get(key).toInteger();
     } else if (Long.TYPE.equals(objectType) == true) {
       return pageParameters.get(key).toLong();
     } else if (Float.TYPE.equals(objectType) == true) {
       return new Float(pageParameters.get(key).toDouble());
     } else if (Double.TYPE.equals(objectType) == true) {
       return pageParameters.get(key).toDouble();
     } else if (Character.TYPE.equals(objectType) == true) {
       return pageParameters.get(key).toChar();
     } else {
       log.warn(
           "Primitive objectType '"
               + objectType
               + "' not yet implemented. Parameter type '"
               + key
               + "' is ignored.");
     }
   } else if (Enum.class.isAssignableFrom(objectType) == true) {
     final StringValue sval = pageParameters.get(key);
     if (sval.isNull() == true) {
       return null;
     }
     final String sValue = sval.toString();
     @SuppressWarnings({"unchecked", "rawtypes"})
     final Enum<?> en = Enum.valueOf((Class<Enum>) objectType, sValue);
     return en;
   } else if (objectType.isAssignableFrom(Integer.class) == true) {
     final StringValue sval = pageParameters.get(key);
     if (sval.isNull() == true) {
       return null;
     }
     return sval.toInteger();
   } else if (objectType.isAssignableFrom(String.class) == true) {
     return pageParameters.get(key).toString();
   } else if (objectType.isAssignableFrom(TimePeriod.class) == true) {
     final String sValue = pageParameters.get(key).toString();
     if (sValue == null) {
       return null;
     }
     final int pos = sValue.indexOf('-');
     if (pos < 0) {
       log.warn(
           "PageParameter of type TimePeriod '"
               + objectType.getName()
               + "' in wrong format: "
               + sValue);
       return null;
     }
     final Long fromTime = NumberHelper.parseLong(sValue.substring(0, pos));
     final Long toTime =
         pos < sValue.length() - 1 ? NumberHelper.parseLong(sValue.substring(pos + 1)) : null;
     return new TimePeriod(
         fromTime != null ? new Date(fromTime) : null, toTime != null ? new Date(toTime) : null);
   } else {
     log.error("PageParameter of type '" + objectType.getName() + "' not yet supported.");
   }
   return null;
 }
コード例 #7
0
 @Override
 protected void init() {
   super.init();
   // GRID 50% - BLOCK
   gridBuilder.newSplitPanel(GridSize.COL50);
   {
     // Number
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("legalAffaires.contract.number"));
     fs.add(new DivTextPanel(fs.newChildId(), "C-"));
     numberField =
         new MinMaxNumberField<Integer>(
             InputPanel.WICKET_ID, new PropertyModel<Integer>(data, "number"), 0, 99999999);
     numberField.setMaxLength(8);
     WicketUtils.setSize(numberField, 6);
     fs.add(numberField);
     if (NumberHelper.greaterZero(getData().getNumber()) == false) {
       fs.addHelpIcon(getString("fibu.tooltip.nummerWirdAutomatischVergeben"));
     }
   }
   {
     // Date
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("date"));
     datePanel =
         new DatePanel(
             fs.newChildId(),
             new PropertyModel<Date>(data, "date"),
             DatePanelSettings.get().withTargetType(java.sql.Date.class));
     fs.add(datePanel);
   }
   {
     // Title
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("title"));
     fs.add(createAutocompleteTextField("title"))
         .getField()
         .setRequired(true)
         .add(WicketUtils.setFocus());
   }
   {
     // Contract type
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("legalAffaires.contract.type"));
     final List<ContractType> contractTypes = ConfigXml.getInstance().getContractTypes();
     final LabelValueChoiceRenderer<ContractType> typeChoiceRenderer =
         new LabelValueChoiceRenderer<ContractType>(contractTypes);
     final DropDownChoice<ContractType> typeChoice =
         new DropDownChoice<ContractType>(
             fs.getDropDownChoiceId(),
             new PropertyModel<ContractType>(data, "type"),
             typeChoiceRenderer.getValues(),
             typeChoiceRenderer);
     typeChoice.setNullValid(false);
     fs.add(typeChoice);
   }
   {
     // Status
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("status"));
     // DropDownChoice for convenient selection of time periods.
     final LabelValueChoiceRenderer<String> statusChoiceRenderer =
         new LabelValueChoiceRenderer<String>();
     for (final ContractStatus status : ContractStatus.values()) {
       statusChoiceRenderer.addValue(status.name(), getString(status.getI18nKey()));
     }
     final DropDownChoice<String> statusChoice =
         new DropDownChoice<String>(
             fs.getDropDownChoiceId(),
             new PropertyModel<String>(data, "status"),
             statusChoiceRenderer.getValues(),
             statusChoiceRenderer);
     statusChoice.setNullValid(false);
     fs.add(statusChoice);
   }
   gridBuilder.newSplitPanel(GridSize.COL50);
   {
     // Reference
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("fibu.common.reference"));
     fs.add(
         new MaxLengthTextField(
             InputPanel.WICKET_ID, new PropertyModel<String>(data, "reference")));
   }
   {
     // Resubmission date
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("resubmissionOnDate"));
     resubmissionDatePanel =
         new DatePanel(
             fs.newChildId(),
             new PropertyModel<Date>(data, "resubmissionOnDate"),
             DatePanelSettings.get().withTargetType(java.sql.Date.class));
     fs.add(resubmissionDatePanel);
   }
   {
     // Due date
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("dueDate"));
     dueDatePanel =
         new DatePanel(
             fs.newChildId(),
             new PropertyModel<Date>(data, "dueDate"),
             DatePanelSettings.get().withTargetType(java.sql.Date.class));
     fs.add(dueDatePanel);
   }
   {
     // Signing date
     final FieldsetPanel fs =
         gridBuilder.newFieldset(getString("legalAffaires.contract.signing"), getString("date"));
     signingDatePanel =
         new DatePanel(
             fs.newChildId(),
             new PropertyModel<Date>(data, "signingDate"),
             DatePanelSettings.get().withTargetType(java.sql.Date.class));
     fs.add(signingDatePanel);
   }
   {
     // Validity
     final FieldsetPanel fs =
         gridBuilder.newFieldset(getString("legalAffaires.contract.validity"));
     validFromDatePanel =
         new DatePanel(
             fs.newChildId(),
             new PropertyModel<Date>(data, "validFrom"),
             DatePanelSettings.get().withTargetType(java.sql.Date.class));
     fs.add(validFromDatePanel);
     fs.add(new DivTextPanel(fs.newChildId(), "-"));
     validUntilDatePanel =
         new DatePanel(
             fs.newChildId(),
             new PropertyModel<Date>(data, "validUntil"),
             DatePanelSettings.get().withTargetType(java.sql.Date.class));
     fs.add(validUntilDatePanel);
   }
   gridBuilder.newSplitPanel(GridSize.COL50);
   {
     // CocontractorA
     final FieldsetPanel fs =
         gridBuilder.newFieldset(getString("legalAffaires.contract.coContractorA"));
     fs.add(createAutocompleteTextField("coContractorA"));
   }
   {
     // CopersonA
     final FieldsetPanel fs =
         gridBuilder.newFieldset(getString("legalAffaires.contract.contractPersonA"));
     fs.add(createAutocompleteTextField("contractPersonA"));
   }
   {
     // SignerA
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("legalAffaires.contract.signerA"));
     fs.add(createAutocompleteTextField("signerA"));
   }
   /* GRID8 */
   gridBuilder.newSplitPanel(GridSize.COL50);
   {
     // CocontractorB
     final FieldsetPanel fs =
         gridBuilder.newFieldset(getString("legalAffaires.contract.coContractorB"));
     fs.add(createAutocompleteTextField("coContractorB"));
   }
   {
     // CopersonB
     final FieldsetPanel fs =
         gridBuilder.newFieldset(getString("legalAffaires.contract.contractPersonB"));
     fs.add(createAutocompleteTextField("contractPersonB"));
   }
   {
     // SignerB
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("legalAffaires.contract.signerB"));
     fs.add(createAutocompleteTextField("signerB"));
   }
   /* GRID16 */
   gridBuilder.newGridPanel();
   {
     // Text with JIRA support
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("text"));
     final IModel<String> model = new PropertyModel<String>(data, "text");
     fs.add(new MaxLengthTextArea(TextAreaPanel.WICKET_ID, model));
     fs.addJIRAField(model);
   }
   {
     // Filing
     final FieldsetPanel fs = gridBuilder.newFieldset(getString("filing"));
     fs.add(
         new MaxLengthTextField(InputPanel.WICKET_ID, new PropertyModel<String>(data, "filing")));
   }
   addCloneButton();
 }