com.orientechnologies.orient.core.record.impl.ODocument Java Examples

The following examples show how to use com.orientechnologies.orient.core.record.impl.ODocument. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OJsonRandomExtractorTest.java    From orientdb-etl with Apache License 2.0 6 votes vote down vote up
@Ignore
public void testNonParallel() {
  proc.getFactory().registerExtractor(RandomExtractor.class);

  process("{extractor : { random: {items: " + TOTAL + ", fields: 10} }, "
      + "loader: { orientdb: { dbURL: 'memory:ETLBaseTest', dbType:'graph', class: 'Person', useLightweightEdges:false, "
      + "classes: [{name: 'Person', extends: 'V'}] } } }");

  assertEquals(TOTAL, graph.countVertices("Person"));

  int i = 0;
  for (ODocument doc : graph.getRawGraph().browseClass("Person")) {
    assertEquals(10, doc.fields());
    i++;
  }
}
 
Example #2
Source File: OOrientDBLoader.java    From orientdb-etl with Apache License 2.0 6 votes vote down vote up
@Override
public ODocument getConfiguration() {
  return new ODocument()
      .fromJSON("{parameters:["
          + "{dbUrl:{optional:false,description:'Database URL'}},"
          + "{dbUser:{optional:true,description:'Database user, default is admin'}},"
          + "{dbPassword:{optional:true,description:'Database password, default is admin'}},"
          + "{dbType:{optional:true,description:'Database type, default is document',values:"
          + stringArray2Json(DB_TYPE.values())
          + "}},"
          + "{class:{optional:true,description:'Record class name'}},"
          + "{tx:{optional:true,description:'Transaction mode: true executes in transaction, false for atomic operations'}},"
          + "{dbAutoCreate:{optional:true,description:'Auto create the database if not exists. Default is true'}},"
          + "{dbAutoCreateProperties:{optional:true,description:'Auto create properties in schema'}},"
          + "{dbAutoDropIfExists:{optional:true,description:'Auto drop the database if already exists. Default is false.'}},"
          + "{batchCommit:{optional:true,description:'Auto commit every X items. This speed up creation of edges.'}},"
          + "{wal:{optional:true,description:'Use the WAL (Write Ahead Log)'}},"
          + "{useLightweightEdges:{optional:true,description:'Enable/Disable LightweightEdges in Graphs. Default is false'}},"
          + "{standardElementConstraints:{optional:true,description:'Enable/Disable Standard Blueprints constraints on names. Default is true'}},"
          + "{cluster:{optional:true,description:'Cluster name where to store the new record'}},"
          + "{settings:{optional:true,description:'OrientDB settings as a map'}},"
          + "{classes:{optional:true,description:'Classes used. It assure the classes exist or in case create them'}},"
          + "{indexes:{optional:true,description:'Indexes used. It assure the indexes exist or in case create them'}}],"
          + "input:['OrientVertex','ODocument']}");
}
 
Example #3
Source File: OrientHttpClientConfigurationEntityAdapter.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Nullable
@Override
public EntityEvent newEvent(final ODocument document, final EventKind eventKind) {
  EntityMetadata metadata = new AttachedEntityMetadata(this, document);
  log.debug("Emitted {} event with metadata {}", eventKind, metadata);
  switch (eventKind) {
    case CREATE:
      return new OrientHttpClientConfigurationCreatedEvent(metadata);
    case UPDATE:
      return new OrientHttpClientConfigurationUpdatedEvent(metadata);
    case DELETE:
      return new OrientHttpClientConfigurationDeletedEvent(metadata);
    default:
      return null;
  }
}
 
Example #4
Source File: AbstractTagRule.java    From light with Apache License 2.0 6 votes vote down vote up
protected String getTagDropdownDb(String host) {
    String json = null;
    String sql = "SELECT FROM Tag WHERE host = ? ORDER BY tagId";
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(sql);
        List<ODocument> docs = graph.getRawGraph().command(query).execute(host);
        if (docs.size() > 0) {
            List<Map<String, String>> list = new ArrayList<Map<String, String>>();
            for (ODocument doc : docs) {
                Map<String, String> map = new HashMap<String, String>();
                map.put("label", (String) doc.field("tagId"));
                map.put("value", (String) doc.field("tagId"));
                list.add(map);
            }
            json = mapper.writeValueAsString(list);
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
    } finally {
        graph.shutdown();
    }
    return json;
}
 
Example #5
Source File: EntityHook.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Posts the given events; this will be a paired sequence of ODocument, EventKind, ODocument, EventKind, etc...
 */
private void postEvents(final ODatabase db, final List<Object> events, final String remoteNodeId) {
  final List<EntityEvent> batchedEvents = new ArrayList<>();
  for (int i = 0; i < events.size(); i += 2) {
    final EntityEvent event = newEntityEvent((ODocument) events.get(i), (EventKind) events.get(i + 1));
    if (event != null) {
      event.setRemoteNodeId(remoteNodeId);
      eventManager.post(event);
      db.activateOnCurrentThread();
      if (event instanceof Batchable) {
        batchedEvents.add(event);
      }
    }
  }

  if (!batchedEvents.isEmpty()) {
    eventManager.post(new EntityBatchEvent(batchedEvents));
    db.activateOnCurrentThread();
  }
}
 
Example #6
Source File: CommentMapping.java    From rtc2jira with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void afterWorkItem(ODocument doc) {
  if (value != null) {
    // don't just overwrite existing comments, because they contain jira export history
    List<Comment> comments = doc.field(FieldNames.COMMENTS);
    if (comments == null) {
      comments = new ArrayList<>();
    }
    for (IComment rtcCom : value) {
      Contributor rtcCreator = fetchCompleteItem(rtcCom.getCreator());
      String creatorEmail = rtcCreator.getEmailAddress();
      String creatorName = rtcCreator.getName();
      Date creationDate = new Date(rtcCom.getCreationDate().getTime());
      String plainTextComment = rtcCom.getHTMLContent().getPlainText();
      Comment comment = new Comment(creatorName, creatorEmail, creationDate, plainTextComment);
      if (!comments.contains(comment)) {
        comments.add(comment);
      }
    }
    if (!comments.isEmpty()) {
      doc.field(FieldNames.COMMENTS, comments);
    }
  }
}
 
Example #7
Source File: LuceneInsertReadMultithreadTest.java    From orientdb-lucene with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {

  db = new ODatabaseDocumentTx(url);
  db.open("admin", "admin");
  db.declareIntent(new OIntentMassiveInsert());
  db.begin();
  for (int i = 0; i < cycle; i++) {
    ODocument doc = new ODocument("City");

    doc.field("name", "Rome");

    db.save(doc);
    if (i % commitBuf == 0) {
      db.commit();
      db.begin();
    }

  }

  db.close();
}
 
Example #8
Source File: OrientDbLoader.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
protected void createProperties(Row row) {
    OClass clazz;
    if (className != null) {
        clazz = getOrCreateClass(className);
    } else {
        clazz = ((ODocument) row.getPayload()).getSchemaClass();
    }

    int count = row.getFieldCount();
    for (int i = 0; i < count; i++) {
        String fieldName = row.getFieldName(i);
        OProperty property = clazz.getProperty(fieldName);
        if (property == null) {
            OType type = OType.getTypeByClass(row.getFieldType(i));
            try {
                clazz.createProperty(fieldName, type);
            } catch (OSchemaException e) {
                log.error(e.getMessage(), e);
            }

            log.debug("Created property '{}' of type '{}'", fieldName, type);
        }
    }
}
 
Example #9
Source File: OJDBCExtractor.java    From orientdb-etl with Apache License 2.0 6 votes vote down vote up
@Override
public OExtractedItem next() {
  try {
    if (!didNext) {
      if (!rs.next())
        throw new NoSuchElementException("[JDBC extractor] previous position was " + current);
    }
    didNext = false;

    final ODocument doc = new ODocument();
    for (int i = 0; i < rsColumns; i++) {
      // final OType fieldType = columnTypes != null ? columnTypes.get(i) : null;
      Object fieldValue = rs.getObject(i + 1);
      doc.field(columnNames.get(i), fieldValue);
    }

    return new OExtractedItem(current++, doc);

  } catch (SQLException e) {
    throw new OExtractorException("[JDBC extractor] error on moving forward in resultset of query '" + query
        + "'. Previous position was " + current, e);
  }
}
 
Example #10
Source File: CreateCityDb.java    From orientdb-lucene with Apache License 2.0 6 votes vote down vote up
@Override
@Test(enabled = false)
public void cycle() throws Exception {

  String readed = lineReader.readLine();
  String[] nextLine = readed.split("\\t");
  if (readed != null) {
    ODocument doc = new ODocument("City");
    doc.field("name", nextLine[1]);
    doc.field("country", nextLine[8]);
    Double lat = ((Double) OType.convert(nextLine[4], Double.class)).doubleValue();
    Double lng = ((Double) OType.convert(nextLine[5], Double.class)).doubleValue();
    doc.field("latitude", lat);
    doc.field("longitude", lng);
    doc.save();
    if (i % 1000 == 0) {
      databaseDocumentTx.commit();
      databaseDocumentTx.begin();
    }
    i++;
  }

}
 
Example #11
Source File: HomePage.java    From wicket-orientdb with Apache License 2.0 6 votes vote down vote up
public HomePage(final PageParameters parameters) {
		super(parameters);

		add(new DebugBar("debugBar"));
		add(new Label("dbName", new PropertyModel<String>(this, "session.database.name")));
		add(new Label("dbUrl", new PropertyModel<String>(this, "session.database.URL")));
		add(new Label("dbUserName", new PropertyModel<String>(this, "session.database.user.name")));
		add(new Label("signedIn", new PropertyModel<String>(this, "session.signedIn")));
		add(new Label("signedInUser", new PropertyModel<String>(this, "session.user.name")));
//		((OrientDbWebSession)getSession()).getDatabase().getUser().
		add(new SignInPanel("signInPanel"));
		OQueryDataProvider<ODocument> provider = new OQueryDataProvider<>("select from "+WicketApplication.CLASS_NAME);
		List<IColumn<ODocument, String>> columns = new ArrayList<>();
		columns.add(new DocumentPropertyColumn(Model.of(WicketApplication.PROP_NAME), WicketApplication.PROP_NAME, WicketApplication.PROP_NAME));
		columns.add(new DocumentPropertyColumn(Model.of(WicketApplication.PROP_INT), WicketApplication.PROP_INT, WicketApplication.PROP_INT));
		columns.add(new DocumentPropertyColumn(Model.of(WicketApplication.PROP_DATE), WicketApplication.PROP_DATE, WicketApplication.PROP_DATE));
		DefaultDataTable<ODocument, String> table = new DefaultDataTable<>("table", columns, provider, 15);
		add(table);
    }
 
Example #12
Source File: WicketOrientDbFilterTesterScope.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
private List<List<ODocument>> createListOfDocuments(List<ODocument> docs) {
    List<List<ODocument>> listOfLinks = Lists.newArrayList();
    listOfLinks.add(createListOfDocuments(docs, LIST_ORDER_1));
    listOfLinks.add(createListOfDocuments(docs, LIST_ORDER_2));
    listOfLinks.add(createListOfDocuments(docs, LIST_ORDER_3));
    listOfLinks.add(createListOfDocuments(docs, LIST_ORDER_4));
    return listOfLinks;
}
 
Example #13
Source File: OrientApiKeyEntityAdapter.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void readFields(final ODocument document, final OrientApiKey entity) {
  String domain = document.field(P_DOMAIN, OType.STRING);
  String apiKey = document.field(P_APIKEY, OType.STRING);
  final PrincipalCollection principals = (PrincipalCollection) deserialize(document, P_PRINCIPALS);

  entity.setDomain(domain);
  entity.setApiKey(apiKey.toCharArray());
  entity.setPrincipals(principals);
}
 
Example #14
Source File: UpdateEntityByPropertyAction.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
public boolean execute(final ODatabaseDocumentTx db, final T entity, final Object... values) {
  checkNotNull(db);
  checkArgument(values.length > 0);

  List<ODocument> results = db.command(new OSQLSynchQuery<>(query))
      .execute(values);

  if (results.isEmpty()) {
    return false;
  }
  else {
    adapter.writeEntity(results.get(0), entity);
    return true;
  }
}
 
Example #15
Source File: MarshalledEntityAdapter.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void writeFields(final ODocument document, final MarshalledEntity entity) throws Exception {
  Object value = entity.getValue();
  checkState(value != null, "Marshalled entity missing value: %s", entity);
  String valueType = value.getClass().getName();
  document.field(P_VALUE_TYPE, valueType);

  // marshall
  try (TcclBlock tccl = TcclBlock.begin(classLoader)) {
    Object valueData = marshaller.marshall(value);
    document.field(P_VALUE_DATA, valueData);
  }
}
 
Example #16
Source File: BrowseNodeEntityAdapter.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * remove any parent nodes that only contain 1 child, and if not an asset/component node of course
 */
private void maybeDeleteParents(final ODatabaseDocumentTx db, final String repositoryName, final String parentPath) {
  //count of 1 meaning the node we are currently deleting
  if (!"/".equals(parentPath) && childCountEqualTo(db, repositoryName, parentPath, 1)) {
    ODocument parent = getFirst(db.command(new OCommandSQL(FIND_BY_PARENT_PATH)).execute(ImmutableMap
        .of(P_REPOSITORY_NAME, repositoryName, P_PARENT_PATH, previousParentPath(parentPath), P_NAME,
            previousParentName(parentPath))), null);

    if (parent != null && parent.field(P_COMPONENT_ID) == null && parent.field(P_ASSET_ID) == null) {
      maybeDeleteParents(db, repositoryName, parent.field(P_PARENT_PATH));
      parent.delete();
    }
  }
}
 
Example #17
Source File: ODocumentAliasMapper.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
public ODocumentAliasMapper(String url, OQueryModel<ODocument> model) {
    super(
            url,
            ODocumentPage.class,
            model,
            PARAM_RID,
            new TransparentParameterPageEncoder(PARAM_RID)
    );
}
 
Example #18
Source File: OToursModule.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public ODocument onInstall(OrienteerWebApplication app, ODatabaseDocument db) {
	super.onInstall(app, db);
	OSchemaHelper helper = OSchemaHelper.bind(db);
	helper.describeAndInstallSchema(IOTour.class, IOTourStep.class);
	return null;
}
 
Example #19
Source File: OClassPropertiesWidget.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
public OClassPropertiesWidget(String id, IModel<OClass> model,
		IModel<ODocument> widgetDocumentModel) {
	super(id, model, widgetDocumentModel);

	IModel<DisplayMode> propertiesDisplayMode = getModeModel();
	List<IColumn<OProperty, String>> pColumns = new ArrayList<IColumn<OProperty,String>>();
	pColumns.add(new CheckBoxColumn<OProperty, String, String>(OPropertyFullNameConverter.INSTANCE));
	pColumns.add(new OPropertyDefinitionColumn(OPropertyPrototyper.NAME, propertiesDisplayMode));
	pColumns.add(new OPropertyMetaColumn(OPropertyPrototyper.TYPE, propertiesDisplayMode));
	pColumns.add(new OPropertyMetaColumn(OPropertyPrototyper.LINKED_TYPE, propertiesDisplayMode));
	pColumns.add(new OPropertyMetaColumn(OPropertyPrototyper.LINKED_CLASS, propertiesDisplayMode));
	pColumns.add(new OPropertyMetaColumn(OPropertyPrototyper.NOT_NULL, propertiesDisplayMode));
	pColumns.add(new OPropertyMetaColumn(OPropertyPrototyper.MANDATORY, propertiesDisplayMode));
	pColumns.add(new OPropertyMetaColumn(OPropertyPrototyper.READONLY, propertiesDisplayMode));
	pColumns.add(new OPropertyMetaColumn(CustomAttribute.UI_READONLY, propertiesDisplayMode));
	pColumns.add(new OPropertyMetaColumn(CustomAttribute.DISPLAYABLE, propertiesDisplayMode));
	pColumns.add(new OPropertyMetaColumn(CustomAttribute.CALCULABLE, propertiesDisplayMode));
	pColumns.add(new OPropertyMetaColumn(CustomAttribute.ORDER, propertiesDisplayMode));
	pColumns.add(new OPropertyMetaColumn(CustomAttribute.DESCRIPTION, propertiesDisplayMode));
	pColumns.add(new OPropertyMetaColumn(OPropertyPrototyper.DEFAULT_VALUE, propertiesDisplayMode));

	ExtendedOPropertiesDataProvider pProvider = new ExtendedOPropertiesDataProvider(getModel(), showParentPropertiesModel);
	pProvider.setSort(CustomAttribute.ORDER.getName(), SortOrder.ASCENDING);
	GenericTablePanel<OProperty> tablePanel = new GenericTablePanel<OProperty>("tablePanel", pColumns, pProvider ,20);
	OrienteerDataTable<OProperty, String> pTable = tablePanel.getDataTable();
	pTable.addCommand(new CreateOPropertyCommand(pTable, getModel()));
	pTable.addCommand(new EditSchemaCommand<OProperty>(pTable, propertiesDisplayMode));
	pTable.addCommand(new SaveSchemaCommand<OProperty>(pTable, propertiesDisplayMode));
	pTable.addCommand(new ShowHideParentsCommand<OProperty>(getModel(), pTable, showParentPropertiesModel));
	pTable.addCommand(new DeleteOPropertyCommand(pTable));
	pTable.addCommand(new CreateOIndexFromOPropertiesCommand(pTable, getModel()));
	pTable.setCaptionModel(new ResourceModel("class.properties"));
	add(tablePanel);
	add(DisableIfPrototypeBehavior.INSTANCE, UpdateOnActionPerformedEventBehavior.INSTANCE_ALL_CONTINUE);
}
 
Example #20
Source File: RecordConverter.java    From guice-persist-orient with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
private <T> T tryObjectConversion(final ODocument doc, final Class<T> targetType) {
    // Possible case: custom result converter required. For example, targetType may be even mapped object
    // class but returned document does not represent this class (assumed manual conversion)
    if (doc.getClassName().equals(targetType.getSimpleName())) {
        final ODatabaseObject db = injector.getInstance(ODatabaseObject.class);
        if (db.getEntityManager().getRegisteredEntities().contains(targetType)) {
            return (T) db.getUserObjectByRecord(doc, null);
        }
    }
    return null;
}
 
Example #21
Source File: OLetBlock.java    From orientdb-etl with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(OETLProcessor iProcessor, final ODocument iConfiguration, final OCommandContext iContext) {
  super.configure(iProcessor, iConfiguration, iContext);

  name = iConfiguration.field("name");
  if (iConfiguration.containsField("value")) {
    value = iConfiguration.field("value");
  } else
    expression = new OSQLFilter((String) iConfiguration.field("expression"), iContext, null);

  if (value == null && expression == null)
    throw new IllegalArgumentException("'value' or 'expression' parameter are mandatory in Let Transformer");
}
 
Example #22
Source File: DoubleLuceneTest.java    From orientdb-lucene with Apache License 2.0 5 votes vote down vote up
@Test
public void testDoubleLucene() {
  OrientGraphNoTx graph = new OrientGraphNoTx("memory:doubleLucene");
  ODatabaseDocumentTx db = graph.getRawGraph();

  db.command(new OCommandSQL("create class Test extends V")).execute();
  db.command(new OCommandSQL("create property Test.attr1 string")).execute();
  db.command(new OCommandSQL("create index Test.attr1 on Test (attr1) fulltext engine lucene")).execute();
  db.command(new OCommandSQL("create property Test.attr2 string")).execute();
  db.command(new OCommandSQL("create index Test.attr2 on Test (attr2) fulltext engine lucene")).execute();
  db.command(new OCommandSQL("insert into Test set attr1='foo', attr2='bar'")).execute();
  db.command(new OCommandSQL("insert into Test set attr1='bar', attr2='foo'")).execute();

  List<ODocument> results = db.command(new OCommandSQL("select from Test where attr1 lucene 'foo*' OR attr2 lucene 'foo*'"))
      .execute();
  Assert.assertEquals(results.size(), 2);

  results = db.command(new OCommandSQL("select from Test where attr1 lucene 'bar*' OR attr2 lucene 'bar*'")).execute();

  Assert.assertEquals(results.size(), 2);

  results = db.command(new OCommandSQL("select from Test where attr1 lucene 'foo*' AND attr2 lucene 'bar*'")).execute();

  Assert.assertEquals(results.size(), 1);

  results = db.command(new OCommandSQL("select from Test where attr1 lucene 'bar*' AND attr2 lucene 'foo*'")).execute();

  Assert.assertEquals(results.size(), 1);

}
 
Example #23
Source File: OAuth2ServicesWidget.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private CreateODocumentCommand newCreateODocumentCommand(OrienteerDataTable<ODocument, String> table, IModel<OClass> expectedClass) {
    return new CreateODocumentCommand(table, expectedClass) {
        @Override
        protected void onConfigure() {
            super.onConfigure();
            List<IOAuth2Provider> providers = OUsersCommonUtils.getOAuth2Providers();
            long size = table.getDataProvider().size();
            setVisible(size < providers.size());
        }
    };
}
 
Example #24
Source File: OCSVTransformerTest.java    From orientdb-etl with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullCell() {
  String cfgJson = "{source: { content: { value: 'id,postId,text\n1,,Hello'} }, extractor : { row : {} }, transformers : [{ csv : {} }], loader : { test: {} } }";
  process(cfgJson);
  List<ODocument> res = getResult();
  ODocument doc = res.get(0);
  assertEquals(new Integer(1), (Integer) doc.field("id"));
  assertNull(doc.field("postId"));
  assertEquals("Hello", (String) doc.field("text"));
}
 
Example #25
Source File: WicketOrientDbFilterTesterScope.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
private void createLinksForDocuments(List<ODocument> documents, List<ODocument> links) {
    Args.isTrue(documents.size() == links.size(), "documents.size() == linkedDocs.size()");
    for (int i = 0; i < documents.size(); i++) {
        ODocument document = documents.get(i);
        document.field(LINK_FIELD, links.get(i).getIdentity().toString(), OType.LINK);
        document.save();
    }
}
 
Example #26
Source File: BrowseAssetIteratorTest.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testRid() {
  db = mockDbQuery("#11:924448", 50, page(3, "#9:54"), page(3, "#9:54"));
  underTest = new BrowseAssetIterator(contentAuthHelper, db, "#11:924448", FOO, singletonList("#9:54"), 10, 50);

  assertThat(underTest.getRid(), equalTo("#11:924448"));
  assertThat(underTest.getBucketIds(), contains("#9:54"));
  assertThat(underTest.getLimit(), equalTo(10));
  assertThat(underTest.getStartRid(), equalTo("#11:924448"));
  assertThat(underTest.getCount(), equalTo(0));
  assertThat(underTest.getQuery(), equalTo("select from asset where @rid > #11:924448"));

  assertThat(size((Iterable<ODocument>)() -> underTest), equalTo(6));
  assertThat(underTest.isHasBrowsedClass(), is(false));
}
 
Example #27
Source File: OCSVTransformerTest.java    From orientdb-etl with Apache License 2.0 5 votes vote down vote up
@Test
public void testDoubleWithingQuotes() {
  Double minDouble = 540282346638528870000000000000000000000.0d;

  String cfgJson = "{source: { content: { value: 'secondNumber\n\"540282346638528870000000000000000000000.0\"'}  }, extractor : { row: {} }, transformers : [{ csv: {} }], loader: { test: {} } }";
  process(cfgJson);
  List<ODocument> res = getResult();
  ODocument doc = res.get(0);
  assertEquals(minDouble, (Double) doc.field("secondNumber"));
}
 
Example #28
Source File: LuceneExportImportTest.java    From orientdb-lucene with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public void init() {
  initDB();

  OSchema schema = databaseDocumentTx.getMetadata().getSchema();
  OClass oClass = schema.createClass("City");

  oClass.createProperty("name", OType.STRING);
  databaseDocumentTx.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();

  ODocument doc = new ODocument("City");
  doc.field("name", "Rome");
  databaseDocumentTx.save(doc);
}
 
Example #29
Source File: StorageQuery.java    From rtc2jira with GNU General Public License v2.0 5 votes vote down vote up
public static final List<ODocument> getRTCWorkItems(StorageEngine engine) {
  final List<ODocument> result = new ArrayList<>();
  engine.withDB(db -> {
    OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>("select ID from WorkItem");
    List<ODocument> queryResults = db.query(query);
    result.addAll(queryResults);
  });
  return result;
}
 
Example #30
Source File: ODocumentPage.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected IModel<ODocument> resolveByPageParameters(PageParameters parameters) {
	String rid = parameters.get("rid").toOptionalString();
	if (rid != null) {
		try {
			return new ODocumentModel(new ORecordId(rid));
		} catch (IllegalArgumentException e) {
			//NOP Support of case with wrong rid
		}
	}
	String className = parameters.get("class").toOptionalString();
	return new ODocumentModel(!Strings.isEmpty(className) ? new ODocument(className) : null);
}