magnolia-ui-app-contacts Version: 5.0-alpha2-2 Last Published: Jan 30, 2013

CPD Results

The following document contains the results of PMD's CPD 4.2.5.

Duplications

FileLine
info/magnolia/ui/app/contacts/ContactsModule.java178
info/magnolia/ui/app/contacts/ContactsModule.java267
        dialog.form(
                cfg.forms
                        .form()
                        .description("Define the contact information")
                        .tabs(cfg.forms
                                .tab("Personal")
                                .label("Personal")
                                .fields(cfg.fields.text(Contact.PROPERTY_SALUTATION).label("Salutation").description("Define salutation"),
                                        cfg.fields.text(Contact.PROPERTY_FIRST_NAME).label("First name").description("Please enter the contact first name. Field is mandatory")
                                                .required(),
                                        cfg.fields.text(Contact.PROPERTY_LAST_NAME).label("Last name").description("Please enter the contact last name. Field is mandatory").required(),
                                        cfg.fields.fileUpload("fileUpload").label("Image").preview().imageNodeName(Contact.IMAGE_NODE_NAME),
                                        cfg.fields.text(Contact.PROPERTY_PHOTO_CAPTION).label("Image caption").description("Please define an image caption"),
                                        cfg.fields.text(Contact.PROPERTY_PHOTO_ALT_TEXT).label("Image alt text").description("Please define an image alt text")),
                                cfg.forms
                                        .tab("Address")
                                        .label("Address")
                                        .fields(cfg.fields.text(Contact.PROPERTY_ORGANIZATION_NAME).label("Organization name").description("Enter the organization name")
                                                .required(),
                                                cfg.fields.text(Contact.PROPERTY_ORGANIZATION_UNIT_NAME).label("Organization unit name")
                                                        .description("Enter the organization unit name"),
                                                cfg.fields.text(Contact.PROPERTY_STREET_ADDRESS).label("Street address").description("Please enter the company street address")
                                                        .rows(2),
                                                cfg.fields.text(Contact.PROPERTY_ZIP_CODE).type(PropertyType.TYPENAME_LONG).label("ZIP code").description("Please enter the zip code (only digits)"),
                                                cfg.fields.text(Contact.PROPERTY_CITY).label("City").description("Please enter the company city  "),
                                                cfg.fields.text(Contact.PROPERTY_COUNTRY).label("Country").description("Please enter the company country")),
                                cfg.forms
                                        .tab("Contact details")
                                        .label("Contact details")
                                        .fields(cfg.fields.text(Contact.PROPERTY_OFFICE_PHONE_NR).label("Office phone").description("Please enter the office phone number"),
                                                cfg.fields.text(Contact.PROPERTY_OFFICE_FAX_NR).label("Office fax nr.").description("Please enter the office fax number"),
                                                cfg.fields.text(Contact.PROPERTY_MOBILE_PHONE_NR).label("Mobile phone").description("Please enter the mobile phone number"),
                                                cfg.fields.text(Contact.PROPERTY_EMAIL).label("E-Mail address").description("Please enter the email address").required()
                                                        .validator(cfg.validators.email().errorMessage("validation.message.non.valid.email")),
                                                cfg.fields.text(Contact.PROPERTY_WEBSITE).label("Website").description("Please enter the Website")))).actions(
FileLine
info/magnolia/ui/app/contacts/dialog/action/SaveContactDialogAction.java76
info/magnolia/ui/app/contacts/form/action/SaveContactFormAction.java79
        }

    }

    // we have already utilities in core to generate unique names. Why not reuse them rather then inventing your own code?
    private void generateUniqueNodeNameForContact(final Node node) throws RepositoryException {
        String firstName = node.getProperty("firstName").getString();
        String lastName = node.getProperty("lastName").getString();
        String newNodeName = (firstName.charAt(0) + lastName.replaceAll("\\s+", "")).toLowerCase();
        String parentPath = node.getParent().getPath();
        String newNodeAbsPath = NodeUtil.combinePathAndName(parentPath, newNodeName);
        int i = 1;

        while (node.getSession().itemExists(newNodeAbsPath)) {
            newNodeAbsPath = NodeUtil.combinePathAndName(parentPath, newNodeName + i);
            i++;
        }
        node.getSession().move(node.getPath(), newNodeAbsPath);
    }
}