コード例 #1
0
    @Override
    public void run() {
      // log.info("START");
      try {
        while (execute) {
          int next = random.nextInt(nodesMaxIndex);
          NodeData rndNode = parentNodes[next];
          if (random.nextBoolean()) {
            // put single item
            if (random.nextBoolean()) {
              // node
              cache.put(
                  new TransientNodeData(
                      QPath.makeChildPath(
                          rndNode.getQPath(), InternalQName.parse("[]childNode-" + next)),
                      IdGenerator.generate(),
                      1,
                      Constants.NT_UNSTRUCTURED,
                      new InternalQName[0],
                      1,
                      IdGenerator.generate(),
                      rndNode.getACL()));
            } else {
              TransientPropertyData pd =
                  new TransientPropertyData(
                      QPath.makeChildPath(
                          rndNode.getQPath(), InternalQName.parse("[]property-" + next)),
                      IdGenerator.generate(),
                      1,
                      PropertyType.STRING,
                      rndNode.getIdentifier(),
                      false,
                      new TransientValueData("prop data"));
              cache.put(pd);
            }
            itemsProcessed++;
          } else {
            // put list of childs
            if (random.nextBoolean()) {
              // nodes
              List<NodeData> cn = createNodesData(rndNode, 100);
              cache.addChildNodes(rndNode, cn);
              itemsProcessed += cn.size();
            } else {
              // properties w/o value
              List<PropertyData> cp = createPropertiesData(rndNode, 100);
              cache.addChildProperties(rndNode, cp);
              itemsProcessed += cp.size();
            }
          }

          Thread.sleep(putTimeout);
        }
      } catch (Exception e) {
        log.error(getName() + " " + e, e);
      }
      // log.info("FINISH");
    }
コード例 #2
0
  public Book addBook(Book book) throws DuplicateBookException {
    SessionProvider sProvider = SessionProvider.createSystemProvider();

    String nodeId = IdGenerator.generate();
    book.setId(nodeId);

    try {
      Node parentNode = getNodeByPath(DEFAULT_PARENT_PATH, sProvider);
      Node bookNode = parentNode.addNode(nodeId, BookNodeTypes.EXO_BOOK);
      bookNode.setProperty(BookNodeTypes.EXP_BOOK_NAME, book.getName());
      bookNode.setProperty(
          BookNodeTypes.EXP_BOOK_CATEGORY, Utils.bookCategoryEnumToString(book.getCategory()));
      bookNode.setProperty(BookNodeTypes.EXP_BOOK_CONTENT, book.getContent());

      parentNode.getSession().save();
      return book;
    } catch (PathNotFoundException e) {
      return null;
    } catch (Exception e) {
      log.error("Failed to add book", e);
      return null;
    } finally {
      sProvider.close();
    }
  }
コード例 #3
0
  /** {@inheritDoc} */
  protected ResultSet findNodesAndProperties(String lastNodeId, int offset, int limit)
      throws SQLException {
    String tempTableAName = "tempdb..a" + IdGenerator.generate();

    boolean tempTableACreated = false;

    try {
      // the Sybase is not allowed DDL query (CREATE TABLE, DROP TABLE, etc. ) within a
      // multi-statement transaction
      if (!dbConnection.getAutoCommit()) {
        dbConnection.setAutoCommit(true);
      }

      selectLimitOffsetNodesIntoTemporaryTable =
          dbConnection.prepareStatement(
              SELECT_LIMIT_OFFSET_NODES_INTO_TEMPORARY_TABLE
                  .replaceAll(SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME, tempTableAName)
                  .replace("${TOP}", new Integer(offset + limit).toString()));

      if (findNodesAndProperties != null) {
        findNodesAndProperties.close();
      }

      findNodesAndProperties =
          dbConnection.prepareStatement(
              FIND_NODES_AND_PROPERTIES.replaceAll(
                  SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME, tempTableAName));

      deleteTemporaryTableA =
          dbConnection.prepareStatement(
              DELETE_TEMPORARY_TABLE_A.replaceAll(
                  SybaseJDBCConnectionHelper.TEMP_A_TABLE_NAME, tempTableAName));

      selectLimitOffsetNodesIntoTemporaryTable.setString(1, lastNodeId);
      selectLimitOffsetNodesIntoTemporaryTable.execute();

      tempTableACreated = true;

      return findNodesAndProperties.executeQuery();
    } finally {
      if (tempTableACreated) {
        try {
          deleteTemporaryTableA.execute();
        } catch (SQLException e) {
          LOG.warn("Can not delete temporary table " + tempTableAName);
        }
      }

      // close prepared statement since we always create new
      if (selectLimitOffsetNodesIntoTemporaryTable != null) {
        selectLimitOffsetNodesIntoTemporaryTable.close();
      }

      if (deleteTemporaryTableA != null) {
        deleteTemporaryTableA.close();
      }
    }
  }
コード例 #4
0
  private List<NodeData> createNodesData(NodeData parent, int count) throws Exception {

    List<NodeData> nodes = new ArrayList<NodeData>();

    for (int i = 1; i <= count; i++) {
      nodes.add(
          new TransientNodeData(
              QPath.makeChildPath(parent.getQPath(), InternalQName.parse("[]node" + i)),
              IdGenerator.generate(),
              1,
              Constants.NT_UNSTRUCTURED,
              new InternalQName[0],
              1,
              IdGenerator.generate(),
              parent.getACL()));
    }

    return nodes;
  }
コード例 #5
0
ファイル: MessageFilter.java プロジェクト: binhnvexo/cs
 public MessageFilter(String name) {
   this.id_ = Utils.KEY_FILTER + IdGenerator.generate();
   this.name_ = name;
   this.toCondition_ = Utils.CONDITION_CONTAIN;
   this.fromCondition_ = Utils.CONDITION_CONTAIN;
   this.subjectCondition_ = Utils.CONDITION_CONTAIN;
   this.bodyCondition_ = Utils.CONDITION_CONTAIN;
   this.hasAttach_ = false;
   this.hasStar_ = false;
   this.priority_ = 0;
   isAscending_ = false;
   orderBy_ = Utils.EXO_LAST_CHECKED_TIME;
   hasStructure_ = false;
 }
コード例 #6
0
  /**
   * properties w/o value.
   *
   * @param parent
   * @param count
   * @return
   * @throws Exception
   */
  private List<PropertyData> createPropertiesData(NodeData parent, int count) throws Exception {

    List<PropertyData> props = new ArrayList<PropertyData>();

    for (int i = 1; i <= count; i++) {
      TransientPropertyData pd =
          new TransientPropertyData(
              QPath.makeChildPath(parent.getQPath(), InternalQName.parse("[]property-" + i)),
              IdGenerator.generate(),
              1,
              PropertyType.STRING,
              parent.getIdentifier(),
              false,
              new TransientValueData("prop data"));
      props.add(pd);
    }

    return props;
  }
コード例 #7
0
ファイル: TestForumService.java プロジェクト: hanhvq/exo-ks
 private String getId(String type) {
   return type + IdGenerator.generate();
 }
コード例 #8
0
 /** Constructor for GenericLesson. It uses GateIn to regenerate an id for the lesson */
 public GenericLesson() {
   // set lesson id by ExoPlatform's api
   setId(PREF + IdGenerator.generate());
   documents = new ArrayList<String>();
 }