CPD Results

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

Duplications

FileLine
org/directdemocracyportal/democracy/web/views/OnlinePoliticalPartyOverviewPanel.java150
org/directdemocracyportal/democracy/web/views/OrganisationOverviewPanel.java218
                .getMessage(MessageConstans.OVERVIEW));

        orgStructure.setLayout(new TableLayout(new double[][] { { 0 }, // Column
                // Widths
                { 20, 0 } }, // Row Heights
                1, // Margin around edge of container
                5)); // Spacing between cells

        Label nameLabel = new Label(ApplicationMessageHolder
                .getMessage(MessageConstans.ORGANISATIONS));
        nameLabel.setLimit("0,0");
        orgStructure.getChildren().add(nameLabel);

        GridBox orgBox = getOrgGridBox(organisation);
        orgBox.setLimit("0,1");
        orgStructure.getChildren().add(orgBox);

        return orgStructure;
    }

    /**
     * Gets the org grid box.
     *
     * @param organisation the organisation
     * @return the org grid box
     */
    private GridBox getOrgGridBox(Organisation organisation) {
        GridBox gridBox = new GridBox();
        gridBox.addActionListener(ACTION_CLICK, BeanLocator
                .getApplicationActionListener());
        gridBox.setVisibleHeader(true);

        GridBox.Column nameHeader = new GridBox.Column();
        nameHeader.setName(ApplicationMessageHolder
                .getMessage(MessageConstans.HEADER_NAME));
        gridBox.getColumns().add(nameHeader);

        GridBox.Column orgTypeHeader = new GridBox.Column();
        orgTypeHeader.setName(ApplicationMessageHolder
                .getMessage(MessageConstans.ORGANISATION_TYPE));
        gridBox.getColumns().add(orgTypeHeader);

        GridBox.Column numberPeopleHeader = new GridBox.Column();
        numberPeopleHeader.setName(ApplicationMessageHolder
                .getMessage(MessageConstans.NUMBER_OF_MEMBERS));
        gridBox.getColumns().add(numberPeopleHeader);

        for (GroupAgent groupAgent : organisation.getChildren()) {
            Organisation orgUnit = (Organisation) groupAgent;
            GridBox.Row row = new GridBox.Row(orgUnit.getName(), orgUnit
                    .getOrganisationType(), orgUnit
                    .getNumberOfMembers());
            row.setUserObject(new ShowOrganisationAction(orgUnit.getId()));
FileLine
org/directdemocracyportal/democracy/web/views/OnlinePoliticalPartyOverviewPanel.java74
org/directdemocracyportal/democracy/web/views/OrganisationOverviewPanel.java129
    }

    /**
     * Creates the members tab sheet.
     *
     * @param organisation the organisation
     * @return the tab sheet
     */
    private TabSheet createMembersTabSheet(Organisation organisation) {
        TabSheet members = new TabSheet();

        members.setText(organisation.getName() + ApplicationMessageHolder
                .getMessage(MessageConstans.MEMBERS));

        members.setLayout(new TableLayout(new double[][] { { 0 }, // Column
                // Widths
                { 20, 0 } }, // Row Heights
                1, // Margin around edge of container
                5)); // Spacing between cells

        Label nameLabel = new Label(ApplicationMessageHolder
                .getMessage(MessageConstans.MEMBERS));
        nameLabel.setLimit("0,0");
        members.getChildren().add(nameLabel);

        GridBox orgBox = getMemberGridBox(organisation);
        orgBox.setLimit("0,1");
        members.getChildren().add(orgBox);

        return members;
    }

    /**
     * Gets the member grid box.
     *
     * @param organisation the organisation
     * @return the member grid box
     */
    private GridBox getMemberGridBox(Organisation organisation) {
        GridBox gridBox = new GridBox();
        gridBox.setVisibleHeader(true);
FileLine
org/directdemocracyportal/democracy/service/governmentloader/SwedishGovernmentImporterImpl.java652
org/directdemocracyportal/democracy/service/governmentloader/SwedishGovernmentImporterImpl.java753
    private List<Politician> getAllInternationalGovernmentMembers(
            HtmlElement pageContent) {

        HtmlTableBody tableBody = (HtmlTableBody) pageContent
                .getElementById("tableBody");
        List<HtmlTableRow> rows = tableBody.getRows();

        List<Politician> members = new ArrayList<Politician>();
        for (HtmlTableRow row : rows) {
            List<HtmlTableCell> cells = row.getCells();

            if (cells.size() == 3) {
                members.add(new Politician(cells.get(0).asText().trim(), "",
                        cells.get(1).asText().trim(), cells.get(2).asText()
                                .trim(), "Parlamentsledamot"));
FileLine
org/directdemocracyportal/democracy/web/views/OnlinePoliticalPartyOverviewPanel.java113
org/directdemocracyportal/democracy/web/views/OrganisationOverviewPanel.java171
                .getApplicationActionListener());
        gridBox.setVisibleHeader(true);

        GridBox.Column nameHeader = new GridBox.Column();
        nameHeader.setName(ApplicationMessageHolder
                .getMessage(MessageConstans.HEADER_NAME));
        gridBox.getColumns().add(nameHeader);

        GridBox.Column rolesHeader = new GridBox.Column();
        rolesHeader.setName(ApplicationMessageHolder
                .getMessage(MessageConstans.ROLES));
        gridBox.getColumns().add(rolesHeader);

        GridBox.Column partyHeader = new GridBox.Column();
        partyHeader.setName(ApplicationMessageHolder
                .getMessage(MessageConstans.POLITICAL_PARTY));
        gridBox.getColumns().add(partyHeader);
FileLine
org/directdemocracyportal/democracy/model/core/Agent.java119
org/directdemocracyportal/democracy/model/core/Environment.java102
    }

    /*
     * (non-Javadoc)
     *
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }

    /*
     * (non-Javadoc)
     *
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        final Environment other = (Environment) obj;