Skip to content

Commit

Permalink
Merge pull request #3 from thewall13/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Thewall13 committed Aug 23, 2014
2 parents f90cdd0 + e871f8e commit 0d15c0f
Show file tree
Hide file tree
Showing 21 changed files with 978 additions and 170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@
*/
package com.orientechnologies.orient.core.config;

import com.orientechnologies.common.io.OFileUtils;
import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.orient.core.OConstants;
import com.orientechnologies.orient.core.Orient;
import com.orientechnologies.orient.core.metadata.OMetadataDefault;
import com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerSchemaAware2CSV;
import com.orientechnologies.orient.core.storage.fs.OMMapManagerOld;

import java.io.PrintStream;
import java.lang.management.OperatingSystemMXBean;
import java.util.Map;
Expand All @@ -31,6 +23,14 @@
import java.util.logging.FileHandler;
import java.util.logging.Level;

import com.orientechnologies.common.io.OFileUtils;
import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.orient.core.OConstants;
import com.orientechnologies.orient.core.Orient;
import com.orientechnologies.orient.core.metadata.OMetadataDefault;
import com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinary;
import com.orientechnologies.orient.core.storage.fs.OMMapManagerOld;

/**
* Keeps all configuration settings. At startup assigns the configuration values by reading system properties.
*
Expand Down Expand Up @@ -553,7 +553,7 @@ public void change(final Object iCurrentValue, final Object iNewValue) {
"Maximum timeout in milliseconds to collect all the asynchronous responses from replication", Integer.class, 15000l),

DB_DOCUMENT_SERIALIZER("db.document.serializer", "The default record serializer used by the document database", String.class,
ORecordSerializerSchemaAware2CSV.NAME);
ORecordSerializerBinary.NAME);

private final String key;
private final Object defValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
*/
package com.orientechnologies.orient.core.db.tool;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.zip.Deflater;
import java.util.zip.GZIPOutputStream;

import com.orientechnologies.common.io.OIOException;
import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.common.serialization.types.OBinarySerializer;
Expand All @@ -29,6 +41,7 @@
import com.orientechnologies.orient.core.iterator.ORecordIteratorCluster;
import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.metadata.schema.OClassImpl;
import com.orientechnologies.orient.core.metadata.schema.OGlobalProperty;
import com.orientechnologies.orient.core.metadata.schema.OProperty;
import com.orientechnologies.orient.core.metadata.schema.OPropertyImpl;
import com.orientechnologies.orient.core.metadata.schema.OSchemaProxy;
Expand All @@ -39,25 +52,13 @@
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import com.orientechnologies.orient.core.type.tree.provider.OMVRBTreeMapProvider;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.zip.Deflater;
import java.util.zip.GZIPOutputStream;

/**
* Export data from a database to a file.
*
* @author Luca Garulli (l.garulli--at--orientechnologies.com)
*/
public class ODatabaseExport extends ODatabaseImpExpAbstract {
public static final int VERSION = 9;
public static final int VERSION = 9;

protected OJSONWriter writer;
protected long recordExported;
Expand Down Expand Up @@ -453,6 +454,18 @@ private void exportSchema() throws IOException {
OSchemaProxy s = (OSchemaProxy) database.getMetadata().getSchema();
writer.writeAttribute(2, true, "version", s.getVersion());

if (!s.getGlobalProperties().isEmpty()) {
writer.beginCollection(2, true, "globalProperties");
for (OGlobalProperty global : s.getGlobalProperties()) {
writer.beginObject(3, true, null);
writer.writeAttribute(0, false, "name", global.getName());
writer.writeAttribute(0, false, "global-id", global.getId());
writer.writeAttribute(0, false, "type", global.getType().toString());
writer.endObject(3, true);
}
writer.endCollection(2, true);
}

if (!s.getClasses().isEmpty()) {
writer.beginCollection(2, true, "classes");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@
*/
package com.orientechnologies.orient.core.db.tool;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.zip.GZIPInputStream;

import com.orientechnologies.common.listener.OProgressListener;
import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.common.serialization.types.OBinarySerializer;
Expand Down Expand Up @@ -64,25 +83,6 @@
import com.orientechnologies.orient.core.type.tree.provider.OMVRBTreeRIDProvider;
import com.orientechnologies.orient.core.version.OVersionFactory;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.zip.GZIPInputStream;

/**
* Import data from a file into a database.
*
Expand Down Expand Up @@ -711,8 +711,26 @@ private void importSchema() throws IOException, ParseException {
@SuppressWarnings("unused")
int schemaVersion = jsonReader.readNext(OJSONReader.FIELD_ASSIGNMENT).checkContent("\"version\"")
.readNumber(OJSONReader.ANY_NUMBER, true);
jsonReader.readNext(OJSONReader.COMMA_SEPARATOR).readNext(OJSONReader.FIELD_ASSIGNMENT).checkContent("\"classes\"")
.readNext(OJSONReader.BEGIN_COLLECTION);
jsonReader.readNext(OJSONReader.COMMA_SEPARATOR);
jsonReader.readNext(OJSONReader.FIELD_ASSIGNMENT);
if (jsonReader.getValue().equals("\"globalProperties\"")) {
jsonReader.readNext(OJSONReader.BEGIN_COLLECTION);
do {
jsonReader.readNext(OJSONReader.BEGIN_OBJECT);
jsonReader.readNext(OJSONReader.FIELD_ASSIGNMENT).checkContent("\"name\"");
String name = jsonReader.readString(OJSONReader.NEXT_IN_OBJECT);
jsonReader.readNext(OJSONReader.FIELD_ASSIGNMENT).checkContent("\"global-id\"");
String id = jsonReader.readString(OJSONReader.NEXT_IN_OBJECT);
jsonReader.readNext(OJSONReader.FIELD_ASSIGNMENT).checkContent("\"type\"");
String type = jsonReader.readString(OJSONReader.NEXT_IN_OBJECT);
getDatabase().getMetadata().getSchema().createGlobalProperty(name, OType.valueOf(type), Integer.valueOf(id));
jsonReader.readNext(OJSONReader.NEXT_IN_ARRAY);
} while (jsonReader.lastChar() == ',');
jsonReader.readNext(OJSONReader.COMMA_SEPARATOR);
jsonReader.readNext(OJSONReader.FIELD_ASSIGNMENT);
}

jsonReader.checkContent("\"classes\"").readNext(OJSONReader.BEGIN_COLLECTION);

long classImported = 0;

Expand Down Expand Up @@ -839,7 +857,6 @@ private void importProperty(final OClass iClass) throws IOException, ParseExcept
next = jsonReader.readString(OJSONReader.COMMA_SEPARATOR);
next = jsonReader.readNext(OJSONReader.FIELD_ASSIGNMENT).getValue();
}

next = jsonReader.checkContent("\"type\"").readString(OJSONReader.NEXT_IN_OBJECT);

final OType type = OType.valueOf(next);
Expand Down Expand Up @@ -886,10 +903,10 @@ else if (attrib.equals("\"customFields\""))
}

OPropertyImpl prop = (OPropertyImpl) iClass.getProperty(propName);
if (prop == null)
if (prop == null) {
// CREATE IT
prop = (OPropertyImpl) iClass.createProperty(propName, type);

}
prop.setMandatory(mandatory);
prop.setReadonly(readonly);
prop.setNotNull(notNull);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@
*/
package com.orientechnologies.orient.core.fetch.json;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;
import java.util.Stack;

import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.db.record.ORecordLazyList;
import com.orientechnologies.orient.core.db.record.ORecordLazySet;
import com.orientechnologies.orient.core.db.record.ridbag.ORidBag;
import com.orientechnologies.orient.core.exception.OFetchException;
import com.orientechnologies.orient.core.fetch.OFetchContext;
Expand All @@ -29,12 +37,6 @@
import com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerJSON.FormatSettings;
import com.orientechnologies.orient.core.version.ODistributedVersion;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;
import java.util.Stack;

/**
* @author luca.molino
*
Expand Down Expand Up @@ -174,7 +176,7 @@ private void appendType(final StringBuilder iBuffer, final String iFieldName, fi
}

public void writeSignature(final OJSONWriter json, final ORecordInternal<?> record) throws IOException {
if( record == null ) {
if (record == null) {
json.write("null");
return;
}
Expand Down Expand Up @@ -234,6 +236,10 @@ else if (iFieldValue instanceof Byte || iFieldValue instanceof byte[])
appendType(typesStack.peek(), iFieldName, 'b');
else if (iFieldValue instanceof BigDecimal)
appendType(typesStack.peek(), iFieldName, 'c');
else if (iFieldValue instanceof ORecordLazyList)
appendType(typesStack.peek(), iFieldName, 'z');
else if (iFieldValue instanceof ORecordLazySet)
appendType(typesStack.peek(), iFieldName, 'n');
else if (iFieldValue instanceof Set<?>)
appendType(typesStack.peek(), iFieldName, 'e');
else if (iFieldValue instanceof ORidBag)
Expand Down
Loading

0 comments on commit 0d15c0f

Please sign in to comment.