private void populateContainer(
      HierarchicalContainer container, List<NodeDTO> nodes, NodeDTO parent) {

    for (NodeDTO node : nodes) {
      Item item = container.addItem(node);
      item.getItemProperty(TreePropertyID.NÁZEV).setValue(node.getName());
      container.setChildrenAllowed(node, true);
      if (parent != null) container.setParent(node, parent);

      List<NodeDTO> childrenNodes = nodeFacade.getNodesByParentNode(node);
      if (childrenNodes != null) populateContainer(container, childrenNodes, node);
    }
  }
  private HierarchicalContainer getCategoriesContainer() {

    // Create new container
    HierarchicalContainer container = new HierarchicalContainer();
    // Create containerproperty for name
    container.addContainerProperty(TreePropertyID.NÁZEV, String.class, null);
    // Create containerproperty for icon
    container.addContainerProperty(
        TreePropertyID.IKONA,
        ThemeResource.class,
        new ThemeResource("../runo/icons/16/folder.png"));

    List<NodeDTO> rootNodes = nodeFacade.getRootNodes();
    populateContainer(container, rootNodes, null);

    return container;
  }
  @Override
  protected HierarchicalContainer populateContainerTable() {
    dataSource = new HierarchicalContainer();

    dataSource.addContainerProperty(ViewConstants.PROPERTY_NAME, String.class, null);
    dataSource.addContainerProperty(ViewConstants.PROPERTY_LINK, Link.class, null);

    for (final MetadataRecord metadataRecord : resourceProxy.getMetadataRecords()) {
      Metadata md = Metadata.newInstance(metadataRecord);
      Item item = dataSource.addItem(md);
      if (item != null) {
        item.getItemProperty(ViewConstants.PROPERTY_NAME).setValue(metadataRecord.getName());
        item.getItemProperty(ViewConstants.PROPERTY_LINK).setValue(buildLink(metadataRecord));
      }
    }

    return dataSource;
  }
Exemple #4
0
 @Scheduled(fixedDelay = 1800000, initialDelay = 2000)
 public void execute() throws OriginalTextMismatchException {
   if (dbService.getIsAutoSynchronizationEnabled()) {
     LOG.info("automatic sync enabled");
     HierarchicalContainer hc = new HierarchicalContainer();
     hc.addContainerProperty("shText", String.class, null);
     hc.addContainerProperty("shNic", String.class, null);
     hc.addContainerProperty("shDate", Date.class, null);
     hc.addContainerProperty("dbText", String.class, null);
     hc.addContainerProperty("dbNic", String.class, null);
     hc.addContainerProperty("dbDate", Date.class, null);
     hc.addContainerProperty("syncType", String.class, null);
     LOG.info("loading " + TABLE_NAME);
     List<GSpreadSheetsNote> items = docsService.getNotes();
     LOG.info("making diff for " + TABLE_NAME);
     hc = dbService.getNotesDiff(items, hc);
     List<NotesDiff> diffs = (List<NotesDiff>) hc.getItemIds();
     List<GSpreadSheetsNote> itemsToSh = new ArrayList<>();
     List<GSpreadSheetsNote> itemsToDb = new ArrayList<>();
     for (NotesDiff diff : diffs) {
       if (diff.getSyncType() == SYNC_TYPE.TO_SPREADSHEET) {
         itemsToSh.add(diff.getDbName());
       } else if (diff.getSyncType() == SYNC_TYPE.TO_DB) {
         itemsToDb.add(diff.getSpreadsheetsName());
       }
     }
     LOG.log(Level.INFO, "uploading {0}" + " " + TABLE_NAME, itemsToSh.size());
     docsService.uploadNotes(itemsToSh);
     LOG.log(Level.INFO, "saving to db {0}" + " " + TABLE_NAME, itemsToDb.size());
     dbService.saveNotes(itemsToDb);
     LOG.info("sync finished for " + TABLE_NAME);
     hc.removeAllItems();
   } else {
     LOG.info("automatic sync disabled");
   }
 }
 @Override
 protected void removeAction(Object target) {
   controller.removeMetadata(target.toString());
   tableContainer.removeItem(target);
 }