Package honeycrm.client.dto

Examples of honeycrm.client.dto.ModuleDto


      final Dto related = ((Dto) dto.get(fieldId + "_resolved"));

      if (null == related) {
        return new Label("[unresolved]");
      } else {
        final ModuleDto moduleDtoRelated = DtoModuleRegistry.instance().get(relatedModule);
        final String token = CollectionHelper.join(" ", moduleDtoRelated.getHistoryToken(), ModuleAction.DETAIL.toString().toLowerCase(), String.valueOf(value));
        final Hyperlink link = new Hyperlink(related.getQuicksearch(), token);

        if (related.getAllPreviewableFieldsSorted().isEmpty()) {
          /**
           * there are no details that can be displayed. only display the link to the related item.
View Full Code Here


  protected Dto[] internalParse(final String[][] table, final Map<String, Integer> positions) {
    final ArrayList<Dto> list = new ArrayList<Dto>();

    final Map<String, String> map = getMapping();

    final ModuleDto moduleDto = DtoModuleRegistry.instance().get(getModule());
   
    // start at 1 to skip header row
    for (int y = 1; y < table.length; y++) {
      final Dto dto = new Dto();
      dto.setModule(getModule());

      for (final String keyHoney : map.keySet()) {
        final String importStr = getGluedValues(table, positions, y, map.get(keyHoney));
        final Serializable typedValue = moduleDto.getFieldById(keyHoney).getTypedData(importStr);
       
        dto.set(keyHoney, typedValue);
      }

      list.add(dto);
View Full Code Here

  public String export(final List<Dto> list) {
    if (list.isEmpty()) {
      return "";
    }
   
    final ModuleDto moduleDto = DtoModuleRegistry.instance().get(list.get(0).getModule());
    final String[] fields = moduleDto.getListFieldIds();
    String csv = "";

    for (Dto entry : list) {
      final Collection<String> line = new LinkedList<String>();
View Full Code Here

  public void testWizard() {
    final Configuration c = NewDtoWizard.getConfiguration();

    final String kind = "Contact";

    final ModuleDto contact = c.getModuleDtos().get(kind);
    assertEquals(kind, contact.getModule());
    assertNotNull(contact.getExtraButtons());
    assertNotNull(contact.getFields());
    assertNotNull(contact.getFieldById("name"));
    assertNotNull(contact.getFieldById("accountId"));
  }
View Full Code Here

  public void testRelateFieldMappings() {
    final HashMap<String, ModuleDto> moduleDtos = NewDtoWizard.getConfiguration().getModuleDtos();
   
    for (final Map.Entry<String, ModuleDto> entry: moduleDtos.entrySet()) {
      final ModuleDto moduleDto = entry.getValue();

      assertEquals(entry.getKey(), moduleDto.getModule());

      for (final Map.Entry<String, String> relate: entry.getValue().getRelateFieldMappings().entrySet()) {
        final boolean relatedEntityExists = moduleDtos.containsKey(relate.getValue());
        assertTrue(relatedEntityExists);
      }
View Full Code Here

  private static String getLabel(Field field) {
    return field.isAnnotationPresent(Label.class) ? field.getAnnotation(Label.class).value() : "";
  }

  private static ModuleDto getEntityMetaData(final Class<?> domainClass) {
    final ModuleDto moduleDto = new ModuleDto();
    final String kind = domainClass.getSimpleName();
    moduleDto.setModule(kind);
    moduleDto.setTitle(kind);
    moduleDto.setHistoryToken(kind);
    moduleDto.setHidden(domainClass.isAnnotationPresent(Hidden.class));
    moduleDto.setFields(getFields(domainClass));

    if (domainClass.isAnnotationPresent(HasExtraButton.class)) {
      final String label = domainClass.getAnnotation(HasExtraButton.class).label();
      final Class<? extends AbstractAction> action = domainClass.getAnnotation(HasExtraButton.class).action();
      final ModuleAction show = domainClass.getAnnotation(HasExtraButton.class).show();

      final ExtraButton b = new ExtraButton();
      b.setLabel(label);
      try {
        b.setAction(action.newInstance());
      } catch (Exception e) {
        e.printStackTrace();
        log.warning("Cannot instantiate action for " + ExtraButton.class);
      }
      b.setShow(show);

      moduleDto.setExtraButtons(new ExtraButton[] { b });
    } else {
      moduleDto.setExtraButtons(new ExtraButton[0]);
    }

    if (domainClass.isAnnotationPresent(Quicksearchable.class)) {
      moduleDto.setQuickSearchItems(domainClass.getAnnotation(Quicksearchable.class).value());
    }
    if (domainClass.isAnnotationPresent(ListViewable.class)) {
      moduleDto.setListFieldIds(domainClass.getAnnotation(ListViewable.class).value());
    }
    if (domainClass.isAnnotationPresent(DetailViewable.class)) {
      final String[] rows = domainClass.getAnnotation(DetailViewable.class).value();
      final String[][] fields = new String[rows.length][];
      for (int i = 0; i < rows.length; i++) {
        fields[i] = rows[i].split(",");
      }
      moduleDto.setFormFieldIds(fields);
    }
    moduleDto.setRelateFieldMappings(getRelateFieldMappings(domainClass));
    moduleDto.setOneToManyMappings(getOneToManyMappings(domainClass));
    moduleDto.setFulltextFields(getFulltextFields(domainClass));

    return moduleDto;
  }
View Full Code Here

      }
      response.setContentType("application/pdf");
      response.setHeader("Content-Disposition", "inline; filename=" + module + ".pdf"); // TODO add more information about the entity into the filename.

      final Dto dto = readService.get(module, id);
      final ModuleDto moduleDto = config.getModuleDtos().get(module);

      document.add(new Paragraph(moduleDto.getTitle(), new Font(FontFamily.HELVETICA, 20, Font.BOLD)));
     
      for (final Entry<String, Serializable> entry : dto.getAllData().entrySet()) {
        if ("id".equals(entry.getKey()) || entry.getKey().endsWith("_resolved")) {
          continue;
        }
        final String label = moduleDto.getFieldById(entry.getKey()).getLabel();
        final String value;
       
        if (dto.getAllData().containsKey(entry.getKey() + "_resolved")) {
          final Dto resolved = (Dto) dto.getAllData().get(entry.getKey() + "_resolved");
          value = String.valueOf(resolved.get("name"));
        } else {
          value = null == entry.getValue() ? "-" : String.valueOf(entry.getValue());
        }

        if (entry.getValue() instanceof List<?>) {
          if (!((List<?>)entry.getValue() ).isEmpty()) {
            final List<Dto> list = (List<Dto>) entry.getValue();
            final ModuleDto listModuleDto = config.getModuleDtos().get(list.get(0).getModule());
           
            PdfPTable table = new PdfPTable(listModuleDto.getListFieldIds().length);
            table.setHeaderRows(1);

            for (final String col: listModuleDto.getListFieldIds()) {
              final String colHeader = listModuleDto.getFieldById(col).getLabel();
              table.addCell(new Phrase(colHeader, new Font(FontFamily.HELVETICA, 12, Font.BOLD)));
            }
           
            for (int i = 0; i < list.size(); i++) {
              for (final String col: listModuleDto.getListFieldIds()) {
                final String colValue;
               
                if (list.get(i).getAllData().containsKey(col + "_resolved")) {
                  final Dto resolved = (Dto) list.get(i).get(col + "_resolved");
                  colValue = String.valueOf(resolved.get("name"));
View Full Code Here

TOP

Related Classes of honeycrm.client.dto.ModuleDto

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.