magnolia-ui-app-contacts Version: 5.0-alpha1-rc1 Last Published: Dec 10, 2012

CPD Results

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

Duplications

FileLine
info/magnolia/ui/app/contacts/ContactsModule.java153
info/magnolia/ui/app/contacts/ContactsModule.java227
        dialog.form(cfg.forms.form().description("Define the contact information")
                .tabs(
                        cfg.forms.tab("Personal").label("Personal tab")
                                .fields(
                                        cfg.fields.text("salutation").label("Salutation").description("Define salutation"),
                                        cfg.fields.text("firstName").label("First name").description("Please enter the contact first name. Field is mandatory").required(),
                                        cfg.fields.text("lastName").label("Last name").description("Please enter the contact last name. Field is mandatory").required(),
                                        cfg.fields.fileUpload("fileUpload").label("Image").preview().imageNodeName("photo"),
                                        cfg.fields.text("photoCaption").label("Image caption").description("Please define an image caption"),
                                        cfg.fields.text("photoAltText").label("Image alt text").description("Please define an image alt text")
                                ),
                        cfg.forms.tab("Company").label("Company tab")
                                .fields(
                                        cfg.fields.text("organizationName").label("Organization name").description("Enter the organization name").required(),
                                        cfg.fields.text("organizationUnitName").label("Organization unit name").description("Enter the organization unit name"),
                                        cfg.fields.text("streetAddress").label("Street address").description("Please enter the company street address").rows(2),
                                        cfg.fields.text("zipCode").label("ZIP code").description("Please enter the zip code (only digits)").validator(cfg.validators.digitsOnly().errorMessage("validation.message.only.digits")),
                                        cfg.fields.text("city").label("City").description("Please enter the company city  "),
                                        cfg.fields.text("country").label("Country").description("Please enter the company country")
                                ),
                        cfg.forms.tab("Contacts").label("Contact tab")
                                .fields(
                                        cfg.fields.text("officePhoneNr").label("Office phone").description("Please enter the office phone number"),
                                        cfg.fields.text("officeFaxNr").label("Office fax nr.").description("Please enter the office fax number"),
                                        cfg.fields.text("mobilePhoneNr").label("Mobile phone").description("Please enter the mobile phone number"),
                                        cfg.fields.text("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("website").label("Website").description("Please enter the Website")
                                )
                )
FileLine
info/magnolia/ui/app/contacts/dialog/action/SaveContactDialogAction.java77
info/magnolia/ui/app/contacts/form/action/SaveContactFormAction.java78
        }

    }

    // 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);
    }
}