Package info.jtrac.domain

Examples of info.jtrac.domain.Field


                if (listItem.getIndex() % 2 == 0) {
                    listItem.add(sam);
                }
               
                Field.Name fieldName = (Field.Name) listItem.getModelObject();
                Field field = fields.get(fieldName);
                listItem.add(new Label("label", field.getLabel()));
                listItem.add(new Label("value", item.getCustomValue(fieldName)));
            }
        });
       
        final List<Field> editable = item.getSpace().getMetadata().getEditableFields();
       
        add(new ListView("labels", editable) {
            /* (non-Javadoc)
             * @see org.apache.wicket.markup.html.list.ListView#populateItem(org.apache.wicket.markup.html.list.ListItem)
             */
            protected void populateItem(ListItem listItem) {
                Field field = (Field) listItem.getModelObject();
                listItem.add(new Label("label", field.getLabel()));
            }
        });
       
        if (item.getHistory() != null) {
            List<History> history = new ArrayList(item.getHistory());
            add(new ListView("history", history) {
                /* (non-Javadoc)
                 * @see org.apache.wicket.markup.html.list.ListView#populateItem(org.apache.wicket.markup.html.list.ListItem)
                 */
                protected void populateItem(ListItem listItem) {
                    if (listItem.getIndex() % 2 != 0) {
                        listItem.add(sam);
                    }
                   
                    final History h = (History) listItem.getModelObject();
                    listItem.add(new Label("loggedBy", new PropertyModel(h, "loggedBy.name")));
                    listItem.add(new Label("status", new PropertyModel(h, "statusValue")));
                    listItem.add(new Label("assignedTo", new PropertyModel(h, "assignedTo.name")));
                   
                    WebMarkupContainer comment = new WebMarkupContainer("comment");
                    comment.add(new AttachmentLinkPanel("attachment", h.getAttachment()));
                    comment.add(new Label("comment", ItemUtils.fixWhiteSpace(h.getComment())).setEscapeModelStrings(false));
                    listItem.add(comment);
                   
                    listItem.add(new Label("timeStamp", DateUtils.formatTimeStamp(h.getTimeStamp())));
                    listItem.add(new ListView("fields", editable) {
                        /* (non-Javadoc)
                         * @see org.apache.wicket.markup.html.list.ListView#populateItem(org.apache.wicket.markup.html.list.ListItem)
                         */
                        protected void populateItem(ListItem listItem) {
                            Field field = (Field) listItem.getModelObject();
                            listItem.add(new Label("field", h.getCustomValue(field.getName())));
                        }
                    });
                }
            });
        }
View Full Code Here


        sb.append("</tr>");
       
        int row = 0;
        Map<Field.Name, Field> fields = item.getSpace().getMetadata().getFields();
        for(Field.Name fieldName : item.getSpace().getMetadata().getFieldOrder()) {
            Field field = fields.get(fieldName);
            sb.append("<tr" + (row % 2 == 0 ? altStyle : "") + ">");
            sb.append("  <td" + labelStyle + ">" + field.getLabel() + "</td>");
            sb.append("  <td colspan='5'" + tdStyle + ">" + item.getCustomValue(fieldName) + "</td>");
            sb.append("</tr>");
            row++;
        }
        sb.append("</table>");
       
        //=========================== HISTORY ==================================
        sb.append("<br/>&nbsp;<b" + tableStyle + ">" + fmt("history", ms, loc) + "</b>");
        sb.append("<table width='100%'" + tableStyle + ">");
        sb.append("<tr>");
        sb.append("  <th" + thStyle + ">" + fmt("loggedBy", ms, loc) + "</th><th" + thStyle + ">" + fmt("status", ms, loc) + "</th>"
                + "<th" + thStyle + ">" + fmt("assignedTo", ms, loc) + "</th><th" + thStyle + ">" + fmt("comment", ms, loc) + "</th><th" + thStyle + ">" + fmt("timeStamp", ms, loc) + "</th>");
        List<Field> editable = item.getSpace().getMetadata().getEditableFields();
        for(Field field : editable) {
            sb.append("<th" + thStyle + ">" + field.getLabel() + "</th>");
        }
        sb.append("</tr>");
       
        if (item.getHistory() != null) {
            row = 1;
            for(History history : item.getHistory()) {
                sb.append("<tr valign='top'" + (row % 2 == 0 ? altStyle : "") + ">");
                sb.append("  <td" + tdStyle + ">" + history.getLoggedBy().getName() + "</td>");
                sb.append("  <td" + tdStyle + ">" + history.getStatusValue() +"</td>");
                sb.append("  <td" + tdStyle + ">" + (history.getAssignedTo() == null ? "" : history.getAssignedTo().getName()) + "</td>");
                sb.append("  <td" + tdStyle + ">");
                Attachment attachment = history.getAttachment();
                if (attachment != null) {
                    if (request != null && response != null) {
                        String href = response.encodeURL(request.getContextPath() + "/app/attachments/" + attachment.getFileName() +"?filePrefix=" + attachment.getFilePrefix());
                        sb.append("<a target='_blank' href='" + href + "'>" + attachment.getFileName() + "</a>&nbsp;");
                    } else {
                        sb.append("(attachment:&nbsp;" + attachment.getFileName() + ")&nbsp;");
                    }
                }
                sb.append(fixWhiteSpace(history.getComment()));
                sb.append("  </td>");
                sb.append("  <td" + tdStyle + ">" + history.getTimeStamp() + "</td>");
                for(Field field : editable) {
                    sb.append("<td" + tdStyle + ">" + history.getCustomValue(field.getName()) + "</td>");
                }
                sb.append("</tr>");
                row++;
            }
        }
View Full Code Here

        // custom fields
        Map<Field.Name, Field> fields = item.getSpace().getMetadata().getFields();
        for(Field.Name fieldName : item.getSpace().getMetadata().getFieldOrder()) {
            Object value = item.getValue(fieldName);
            if(value != null) {
                Field field = fields.get(fieldName);
                Element customField = root.addElement(fieldName.getText());
                customField.addAttribute("label", field.getLabel());
                if(field.isDropDownType()) {
                    customField.addAttribute("optionId", value + "");
                }
                customField.addText(item.getCustomValue(fieldName));
            }
        }
        // timestamp
        Element timestamp = root.addElement("timestamp");
        timestamp.addText(DateUtils.formatTimeStamp(item.getTimeStamp()));       
        // history
        if (item.getHistory() != null) { 
            Element historyRoot = root.addElement("history");
            for(History history : item.getHistory()) {  
                Element event = historyRoot.addElement("event");
                // index
                event.addAttribute("eventId", (history.getIndex() + 1) + "");
                // logged by
                Element historyLoggedBy = event.addElement("loggedBy");
                // historyLoggedBy.addAttribute("userId", history.getLoggedBy().getId() + "");
                historyLoggedBy.addText(history.getLoggedBy().getName());
                // status
                if(history.getStatus() != null) {
                    Element historyStatus = event.addElement("status");
                    historyStatus.addAttribute("statusId", history.getStatus() + "");
                    historyStatus.addText(history.getStatusValue());
                }
                // assigned to
                if(history.getAssignedTo() != null) {
                    Element historyAssignedTo = event.addElement("assignedTo");
                    // historyAssignedTo.addAttribute("userId", history.getAssignedTo().getId() + "");
                    historyAssignedTo.addText(history.getAssignedTo().getName());
                }
                // attachment
                if(history.getAttachment() != null) {
                    Element historyAttachment = event.addElement("attachment");
                    historyAttachment.addAttribute("attachmentId", history.getAttachment().getId() + "");
                    historyAttachment.addText(history.getAttachment().getFileName());
                }
                // comment
                if(history.getComment() != null) {
                    Element historyComment = event.addElement("comment");
                    historyComment.addText(history.getComment());
                }
                // timestamp
                Element historyTimestamp = event.addElement("timestamp");
                historyTimestamp.addText(DateUtils.formatTimeStamp(history.getTimeStamp()));
                // custom fields
                List<Field> editable = item.getSpace().getMetadata().getEditableFields();
                for(Field field : editable) {    
                    Object value = history.getValue(field.getName());
                    if(value != null) {
                        Element historyCustomField = event.addElement(field.getName().getText());
                        historyCustomField.addAttribute("label", field.getLabel());
                        if(field.isDropDownType()) {
                            historyCustomField.addAttribute("optionId", value + "");
                        }                       
                        historyCustomField.addText(history.getCustomValue(field.getName()));
                    }
                }               
            }  
        }       
        return root;
View Full Code Here

        for(AbstractItem item : items) {
            row++;
            col = 0;
            for(ColumnHeading ch : columnHeadings) {
                if(ch.isField()) {
                    Field field = ch.getField();
                    switch(field.getName().getType()) {
                        case 4: // double
                            setDouble(row, col++, (Double) item.getValue(field.getName()));
                            break;
                        case 6: // date
                            setDate(row, col++, (Date) item.getValue(field.getName()));
                            break;
                        default:
                            setText(row, col++, item.getCustomValue(field.getName()));
                    }
                } else {
                    switch(ch.getName()) {
                        case ID:
                            if (showHistory) {
View Full Code Here

import org.dom4j.Element;

public class FieldTest extends TestCase {
   
    public void testSetValidName() {
        Field field = new Field();
        field.setName("cusInt01");
        assertEquals(field.getName().toString(), "cusInt01");       
    }
View Full Code Here

        field.setName("cusInt01");
        assertEquals(field.getName().toString(), "cusInt01");       
    }
   
    public void testSetInValidNameFails() {
        Field field = new Field();
        try {
            field.setName("foo");
            fail("How did we set an invalid name?");
        } catch (Exception e) {
            // expected
        }       
    }   
View Full Code Here

        }       
    }   
   
    public void testConstructFromXml() {
        Document d = XmlUtils.parse("<field name='cusInt01' label='Test Label'/>");
        Field field = new Field(d.getRootElement());
        assertEquals("cusInt01", field.getName().toString());
        assertEquals("Test Label", field.getLabel());
        assertEquals(field.isOptional(), false);
    }
View Full Code Here

        assertEquals(field.isOptional(), false);
    }
   
    public void testConstructFromXmlWithOptionalAttribute() {
        Document d = XmlUtils.parse("<field name='cusInt01' label='Test Label' optional='true'/>");
        Field field = new Field(d.getRootElement());
        assertTrue(field.isOptional());
    }
View Full Code Here

        Field field = new Field(d.getRootElement());
        assertTrue(field.isOptional());
    }
   
    public void testGetAsXml() {
        Field field = new Field();
        field.setName("cusInt01");
        field.setLabel("Test Label");       
        Element e = field.getAsElement();
        assertEquals("cusInt01", e.attributeValue("name"));
        assertEquals("Test Label", e.attributeValue("label"));   
   
View Full Code Here

        }
    }
   
    private void doInMemorySort(List<Item> list, ItemSearch itemSearch) {
        // we should never come here if search is across multiple spaces
        final Field field = itemSearch.getSpace().getMetadata().getField(itemSearch.getSortFieldName());
        final ArrayList<String> valueList = new ArrayList<String>(field.getOptions().keySet());
        Comparator<Item> comp = new Comparator<Item>() {
            public int compare(Item left, Item right) {
                Object leftVal = left.getValue(field.getName());
                String leftValString = leftVal == null ? null : leftVal.toString();
                int leftInd = valueList.indexOf(leftValString);
                Object rightVal = right.getValue(field.getName());
                String rightValString = rightVal == null ? null : rightVal.toString();
                int rightInd = valueList.indexOf(rightValString);
                return leftInd - rightInd;
            }
        };
View Full Code Here

TOP

Related Classes of info.jtrac.domain.Field

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.