Package org.structr.core

Examples of org.structr.core.GraphObjectMap


    // extract types from ModuleService
    for (String rawType : StructrApp.getConfiguration().getNodeEntities().keySet()) {

      // create & add schema information
      Class type            = SchemaHelper.getEntityClassForRawType(rawType);
      GraphObjectMap schema = new GraphObjectMap();
      resultList.add(schema);

      if (type != null) {

        String url = "/".concat(CaseHelper.toUnderscore(rawType, true));

        schema.setProperty(new StringProperty("url"), url);
        schema.setProperty(new StringProperty("type"), type.getSimpleName());
        schema.setProperty(new StringProperty("className"), type.getName());
        schema.setProperty(new StringProperty("isRel"), AbstractRelationship.class.isAssignableFrom(type));
        schema.setProperty(new LongProperty("flags"), SecurityContext.getResourceFlags(rawType));

      }


    }
View Full Code Here


      if (propertyView != null) {

        for (final Map.Entry<String, Object> entry : getPropertiesForView(type, propertyView).entrySet()) {

          final GraphObjectMap property = new GraphObjectMap();

          for (final Map.Entry<String, Object> prop : ((Map<String, Object>) entry.getValue()).entrySet()) {

            property.setProperty(new StringProperty(prop.getKey()), prop.getValue());
          }

          resultList.add(property);
        }

      } else {

        final GraphObjectMap schema = new GraphObjectMap();

        resultList.add(schema);

        String url = "/".concat(CaseHelper.toUnderscore(rawType, true));

        schema.setProperty(new StringProperty("url"), url);
        schema.setProperty(new StringProperty("type"), type.getSimpleName());
        schema.setProperty(new StringProperty("className"), type.getName());
        schema.setProperty(new StringProperty("isRel"), AbstractRelationship.class.isAssignableFrom(type));
        schema.setProperty(new LongProperty("flags"), SecurityContext.getResourceFlags(rawType));

        Set<String> propertyViews = new LinkedHashSet<>(StructrApp.getConfiguration().getPropertyViews());

        // list property sets for all views
        Map<String, Map<String, Object>> views = new TreeMap();
        schema.setProperty(new StringProperty("views"), views);

        for (String view : propertyViews) {

          views.put(view, getPropertiesForView(type, view));
View Full Code Here

      final Object value = entry.getValue();

      if (value instanceof Map) {

        final Map<String, Object> map = (Map<String, Object>)value;
        final GraphObjectMap obj      = new GraphObjectMap();

        target.put(new StringProperty(key), obj);

        recursivelyConvertMapToGraphObjectMap(obj, map, depth + 1);
View Full Code Here

  }

  private GraphObject extractActiveElement(final DOMNode node, final Set<String> dataKeys, final String parentId, final ActiveElementState state, final int depth) {

    final GraphObjectMap activeElement = new GraphObjectMap();

    activeElement.put(GraphObject.id, node.getUuid());
    activeElement.put(GraphObject.type, node.getType());
    activeElement.put(DOMElement.dataKey, StringUtils.join(dataKeys, ","));
    activeElement.put(Content.content, node.getProperty(Content.content));

    switch (state) {

      case Button:
        activeElement.put(actionProperty, node.getProperty(DOMElement._action));
        break;

      case Link:
        activeElement.put(actionProperty, node.getProperty(Link._href));
        break;

      case Query:
        extractQueries(activeElement, node);
        break;

    }

    activeElement.put(stateProperty, state.name());
    activeElement.put(recursionDepthProperty, depth);
    activeElement.put(parentIdProperty, parentId);

    return activeElement;
  }
View Full Code Here

        if (syncables != null) {

          final List<GraphObject> result = new LinkedList<>();
          for (final SyncableInfo info : syncables) {

            final GraphObjectMap map = new GraphObjectMap();
            map.put(GraphObject.id,               info.getId());
            map.put(NodeInterface.name,           info.getName());
            map.put(File.size,                    info.getSize());
            map.put(GraphObject.type,             info.getType());
            map.put(GraphObject.lastModifiedDate, info.getLastModified());

            // check for existance
            map.put(isSynchronized, isSynchronized(info));

            result.add(map);
          }

          webSocketData.setResult(result);
View Full Code Here

      final String filesPath             = Services.getInstance().getConfigurationValue(Services.FILES_PATH);
      final String subjectId             = request.getParameter(subjectProperty.jsonName());
      final String objectId              = request.getParameter(objectProperty.jsonName());
      final String action                = request.getParameter(actionProperty.jsonName());
      final GraphObjectMap overviewMap   = new GraphObjectMap();
      final Map<String, Integer> actions = new LinkedHashMap<>();
      final List<Path> files             = new LinkedList<>();
      final String aggregate             = request.getParameter("aggregate");

      boolean overview    = false;
      boolean inverse     = false;
      long beginTimestamp = Long.MAX_VALUE;
      long endTimestamp   = 0L;
      int entryCount      = 0;

      if (StringUtils.isNotEmpty(subjectId) && StringUtils.isNotEmpty(objectId)) {

        final String fileName       = mergeIds(subjectId, objectId);
        final String path           = getDirectoryPath(fileName, 8);
        final Path filePath         = new File(filesPath + SUBJECTS + path + fileName).toPath();

        if (Files.exists(filePath)) {
          files.add(filePath);
        }


      } else if (StringUtils.isNotEmpty(subjectId) && StringUtils.isEmpty(objectId)) {

        final String path           = getDirectoryPath(subjectId, 8);
        final Path directoryPath    = new File(filesPath + SUBJECTS + path).toPath();

        try (final DirectoryStream<Path> stream = Files.newDirectoryStream(directoryPath, subjectId + "????????????????????????????????")) {

          for (final Path p : stream) {
            files.add(p);
          }

        } catch (IOException ioex) {
          ioex.printStackTrace();
        }

      } else if (StringUtils.isEmpty(subjectId) && StringUtils.isNotEmpty(objectId)) {

        inverse = true;

        final String path           = getDirectoryPath(objectId, 8);
        final Path directoryPath    = new File(filesPath + OBJECTS + path).toPath();

        try (final DirectoryStream<Path> stream = Files.newDirectoryStream(directoryPath, objectId + "????????????????????????????????")) {

          for (final Path p : stream) {
            files.add(p);
          }

        } catch (IOException ioex) {
          ioex.printStackTrace();
        }

      } else if (StringUtils.isNotEmpty(action)) {

        collectFiles(new File(filesPath + SUBJECTS).toPath(), files);

      } else {

        collectFiles(new File(filesPath + SUBJECTS).toPath(), files);

        // create overview of existing logs
        overview = true;

      }

      final List<GraphObject> entries = new LinkedList<>();
      final Query query               = getTimestampQuery();
      final Range<Long> range         = getRangeFromQuery(query);
      final Predicate datePredicate   = query.toPredicate();

      for (final Path path : files) {

        try (final BufferedReader reader = Files.newBufferedReader(path, Charset.forName("utf-8"))) {

          final String fileName = path.getFileName().toString();
          String pathSubjectId  = inverse ? fileName.substring(33, 64) : fileName.substring(0, 32);
          String pathObjectId   = inverse ? fileName.substring(0, 32: fileName.substring(33, 64);

          String line = reader.readLine();
          while (line != null) {

            try {

              final int pos0            = line.indexOf(",");
              final int pos1            = line.indexOf(",", pos0+1);

              final String part0        = line.substring(0, pos0);
              final String part1        = line.substring(pos0+1, pos1);
              final String part2        = line.substring(pos1+1);

              final long timestamp      = Long.valueOf(part0);
              final Date date           = new Date(timestamp);
              final String entryAction  = part1;
              final String entryMessage = part2;

              // determine first timestamp
              if (timestamp <= beginTimestamp) {
                beginTimestamp = timestamp;
              }

              // determine last timestamp
              if (timestamp >= endTimestamp) {
                endTimestamp = timestamp;
              }

              if (overview) {

                Integer actionCount = actions.get(entryAction);
                if (actionCount == null) {

                  actions.put(entryAction, 1);

                } else {

                  actions.put(entryAction, actionCount + 1);
                }

                entryCount++;

              } else {

                // action present or matching?
                if (action == null || action.equals(entryAction)) {

                  final GraphObjectMap map = new GraphObjectMap();
                  map.put(subjectProperty, pathSubjectId);
                  map.put(objectProperty, pathObjectId);
                  map.put(actionProperty, entryAction);
                  map.put(timestampProperty, date);
                  map.put(messageProperty, entryMessage);

                  // date predicate present?
                  if (date == null || datePredicate.accept(map)) {
                    entries.add(map);
                  }
View Full Code Here

    return null;
  }

  private Result aggregate(final List<GraphObject> entries, final String dateFormat, final long startTimestamp, final long endTimestamp) {

    final GraphObjectMap result           = new GraphObjectMap();
    final SimpleDateFormat format         = new SimpleDateFormat(dateFormat);
    final long interval                   = findInterval(dateFormat);
    final long start                      = alignDateOnFormat(dateFormat, startTimestamp);
    final TreeMap<Long, Integer> countMap = toCountMap(entries);

    for (long current = start; current <= endTimestamp; current += interval) {

      final Map<Long, Integer> counts = countMap.subMap(current, true, current+interval, false);
      long sum                        = 0;

      for (final Integer count : counts.values()) {
        sum += count;
      }

      result.put(new LongProperty(Long.toString(current)), sum);
//      result.put(new LongProperty(format.format(current)), sum);  // uncomment this for human-readable debug output
    }

    return new Result(result, false);
  }
View Full Code Here

  @Export
  public RestMethodResult getMetadata() throws FrameworkException {

    final Map<String, String> metadata = AVConv.newInstance(securityContext, this).getMetadata();
    final RestMethodResult result      = new RestMethodResult(200);
    final GraphObjectMap map           = new GraphObjectMap();

    for (final Entry<String, String> entry : metadata.entrySet()) {
      map.setProperty(new StringProperty(entry.getKey()), entry.getValue());
    }

    result.addContent(map);

    return result;
View Full Code Here

      result = engine.execute(query);
    }

    for (Map<String, Object> row : result) {

      GraphObjectMap dummyObject = null;
     
      for (Entry<String, Object> entry : row.entrySet()) {
       
        String key   = entry.getKey();
        Object value = entry.getValue();
     
        if (value instanceof Node) {

          NodeInterface node = nodeFactory.instantiate((Node) value, includeHiddenAndDeleted, publicOnly);

          if (node != null) {

            resultList.add(node);
          }

        } else if (value instanceof Relationship) {

          RelationshipInterface rel = relFactory.instantiate((Relationship) value);

          if (rel != null) {

            resultList.add(rel);
          }

        } else {
         
          if (dummyObject == null) {
           
            dummyObject = new GraphObjectMap();
            resultList.add(dummyObject);
          }
           
          dummyObject.setProperty(new GenericProperty(key), value);
        }

      }

    }
View Full Code Here

TOP

Related Classes of org.structr.core.GraphObjectMap

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.