use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob in project GameComposer by mirkosertic.
the class GithubResourceAccessor method publish.
public Promise<GithubCommit, String> publish(AuthorizationState aAuthorizationState, String aCommitMessage) {
return new Promise<>((aFinalResolver, aFinalRejector) -> getLatestHead(aAuthorizationState).thenContinue(aResult -> {
String theHeadCommit = aResult.getObject().getSha();
TeaVMLogger.info("Latest HEAD is " + theHeadCommit);
// We need the commit
getCommit(aAuthorizationState, theHeadCommit).thenContinue(aGithubHead -> {
String theTreeSHA1 = aGithubHead.getTree().getSha();
TeaVMLogger.info("Tree SHA is " + theTreeSHA1);
getTree(aAuthorizationState, theTreeSHA1).thenContinue(aGithubTree -> {
TeaVMLogger.info("Found " + aGithubTree.getTree().getLength() + " files");
// Now we need to iterate over our files
fileSystem.listChangedFiles().thenContinue(aChangedFiles -> {
Map<String, Promise<GithubBlob, String>> theBase64Data = new HashMap<>();
for (File theFile : aChangedFiles) {
if (!EditorProject.DEFINITION_FILENAME.equals(theFile.getFilename())) {
theBase64Data.put(theFile.getFilename(), new Promise<>((aResolver, aRejector) -> {
FileReader theReader = FileReader.create();
theReader.setOnload(() -> {
JSString theURI = JSString.valueOf(theReader.getResult());
JSString theBase64 = theURI.substr(theURI.indexOf(JSString.valueOf(",")) + 1);
// Upload to GitHub as Blob and store SHA
createBlob(aAuthorizationState, theBase64).thenContinue(aLoadedBlob -> {
TeaVMLogger.info("File " + theFile.getFilename() + " uploaded as blob");
aResolver.resolve(aLoadedBlob);
});
});
theReader.readAsDataURL(theFile.getContent());
}));
TeaVMLogger.info(theFile.getFilename() + " was changed");
}
}
Promise.all(new ArrayList<Promise>(theBase64Data.values())).thenContinue(aResult1 -> {
TeaVMLogger.info("All files loaded as base64");
GithubTree theTree = copyTreeAndFillData(aGithubTree, theBase64Data);
createTree(aAuthorizationState, theTree).thenContinue(aNewTree -> {
TeaVMLogger.info("New Tree created with hash : " + aNewTree.getSha());
commitTree(aAuthorizationState, aCommitMessage, aNewTree.getSha(), new String[] { aGithubHead.getSha() }).thenContinue(aNewCommit -> {
TeaVMLogger.info("New Commit created with hash : " + aNewCommit.getSha());
updateHead(aAuthorizationState, aNewCommit.getSha()).thenContinue(aResult11 -> {
TeaVMLogger.info("HEAD updated to new commit");
aFinalResolver.resolve(aNewCommit);
});
});
});
});
});
});
});
}));
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob in project GameComposer by mirkosertic.
the class EditorState method saveGame.
public Promise<File, String> saveGame() {
JSObject theJSForm = TeaVMMap.toJS(loadedGame.serialize());
String theJSON = TeaVMMap.stringifyPretty(theJSForm);
Blob theBlob = Blob.createJSONBlob(JSString.valueOf(theJSON));
return resourceAccessor.persistFile("/game.json", theBlob);
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob in project jaxdb by jaxdb.
the class Compiler method createColumn.
private CreateStatement createColumn(final LinkedHashSet<CreateStatement> alterStatements, final $Table table, final $Column column, final Map<String, Map<String, String>> tableNameToEnumToOwner) {
final StringBuilder builder = new StringBuilder();
builder.append(q(column.getName$().text())).append(' ');
// FIXME: Passing null to compile*() methods will throw a NPE
if (column instanceof $Char) {
final $Char type = ($Char) column;
builder.append(getDialect().compileChar(type.getVarying$() != null && type.getVarying$().text(), type.getLength$() == null ? null : type.getLength$().text()));
} else if (column instanceof $Binary) {
final $Binary type = ($Binary) column;
builder.append(getDialect().compileBinary(type.getVarying$() != null && type.getVarying$().text(), type.getLength$() == null ? null : type.getLength$().text()));
} else if (column instanceof $Blob) {
final $Blob type = ($Blob) column;
builder.append(getDialect().compileBlob(type.getLength$() == null ? null : type.getLength$().text()));
} else if (column instanceof $Clob) {
final $Clob type = ($Clob) column;
builder.append(getDialect().compileClob(type.getLength$() == null ? null : type.getLength$().text()));
} else if (column instanceof $Integer) {
builder.append(createIntegerColumn(($Integer) column));
} else if (column instanceof $Float) {
final $Float type = ($Float) column;
builder.append(getDialect().declareFloat(type.getMin$() == null ? null : type.getMin$().text()));
} else if (column instanceof $Double) {
final $Double type = ($Double) column;
builder.append(getDialect().declareDouble(type.getMin$() == null ? null : type.getMin$().text()));
} else if (column instanceof $Decimal) {
final $Decimal type = ($Decimal) column;
builder.append(getDialect().declareDecimal(type.getPrecision$() == null ? null : type.getPrecision$().text(), type.getScale$() == null ? null : type.getScale$().text(), type.getMin$() == null ? null : type.getMin$().text()));
} else if (column instanceof $Date) {
builder.append(getDialect().declareDate());
} else if (column instanceof $Time) {
final $Time type = ($Time) column;
builder.append(getDialect().declareTime(type.getPrecision$() == null ? null : type.getPrecision$().text()));
} else if (column instanceof $Datetime) {
final $Datetime type = ($Datetime) column;
builder.append(getDialect().declareDateTime(type.getPrecision$() == null ? null : type.getPrecision$().text()));
} else if (column instanceof $Boolean) {
builder.append(getDialect().declareBoolean());
} else if (column instanceof $Enum) {
builder.append(getDialect().declareEnum(($Enum) column, tableNameToEnumToOwner));
}
final String autoIncrementFragment = column instanceof $Integer ? $autoIncrement(alterStatements, table, ($Integer) column) : null;
if (autoIncrementFragment == null || autoIncrementFragment.length() == 0) {
final String defaultFragment = $default(column);
if (defaultFragment != null && defaultFragment.length() > 0)
builder.append(" DEFAULT ").append(defaultFragment);
}
final String nullFragment = $null(table, column);
if (nullFragment != null && nullFragment.length() > 0)
builder.append(' ').append(nullFragment);
if (autoIncrementFragment != null && autoIncrementFragment.length() > 0)
builder.append(' ').append(autoIncrementFragment);
return new CreateStatement(builder.toString());
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob in project jaxdb by jaxdb.
the class SQLiteDecompiler method makeColumn.
@Override
$Column makeColumn(final String columnName, final String typeName, final long size, final int decimalDigits, final String _default, final Boolean nullable, final Boolean autoIncrement) {
final $Column column;
if (typeName.startsWith("BIGINT")) {
final $Bigint type = newColumn($Bigint.class);
if (size != 2000000000)
type.setPrecision$(new $Bigint.Precision$((byte) size));
if (_default != null)
type.setDefault$(new $Bigint.Default$(Long.valueOf(_default)));
if (autoIncrement != null && autoIncrement)
type.setGenerateOnInsert$(new $Bigint.GenerateOnInsert$($Integer.GenerateOnInsert$.AUTO_5FINCREMENT));
column = type;
} else if (typeName.startsWith("BINARY")) {
final $Binary type = newColumn($Binary.class);
final Long length = getLength(typeName);
if (length != null)
type.setLength$(new $Binary.Length$(length));
column = type;
} else if (typeName.startsWith("BLOB")) {
final $Blob type = newColumn($Blob.class);
final Long length = getLength(typeName);
if (length != null)
type.setLength$(new $Blob.Length$(length));
column = type;
} else if ("BOOLEAN".equals(typeName)) {
final $Boolean type = newColumn($Boolean.class);
if (_default != null)
type.setDefault$(new $Boolean.Default$(Boolean.parseBoolean(_default)));
column = type;
} else if (typeName.startsWith("VARCHAR") || typeName.startsWith("CHARACTER")) {
final $Char type = newColumn($Char.class);
if (typeName.startsWith("VARCHAR"))
type.setVarying$(new $Char.Varying$(true));
final Long length = getLength(typeName);
if (length != null)
type.setLength$(new $Char.Length$(length));
if (_default != null)
type.setDefault$(new $Char.Default$(_default.substring(1, _default.length() - 1)));
column = type;
} else if (typeName.startsWith("TEXT")) {
final $Clob type = newColumn($Clob.class);
final Long length = getLength(typeName);
if (length != null)
type.setLength$(new $Clob.Length$(length));
column = type;
} else if ("DATE".equals(typeName)) {
final $Date type = newColumn($Date.class);
if (_default != null)
type.setDefault$(new $Date.Default$(_default.substring(1, _default.length() - 1)));
column = type;
} else if ("DATETIME".equals(typeName)) {
final $Datetime type = newColumn($Datetime.class);
if (size != 2000000000)
type.setPrecision$(new $Datetime.Precision$((byte) size));
if (_default != null)
type.setDefault$(new $Datetime.Default$(_default.substring(1, _default.length() - 1)));
column = type;
} else if (typeName.startsWith("DECIMAL")) {
final $Decimal type = newColumn($Decimal.class);
if (!"DECIMAL(15,0)".equals(typeName)) {
final int open = typeName.indexOf('(');
if (open > 0) {
final int comma = typeName.indexOf(',', open + 1);
if (comma > open) {
final int close = typeName.indexOf(')', comma + 1);
if (close > comma) {
type.setPrecision$(new $Decimal.Precision$(Integer.valueOf(typeName.substring(open + 1, comma).trim())));
type.setScale$(new $Decimal.Scale$(Integer.valueOf(typeName.substring(comma + 1, close).trim())));
}
}
}
}
if (_default != null)
type.setDefault$(new $Decimal.Default$(new BigDecimal(_default)));
column = type;
} else if ("DOUBLE".equals(typeName)) {
final $Double type = newColumn($Double.class);
if (_default != null)
type.setDefault$(new $Double.Default$(Double.valueOf(_default)));
column = type;
} else // }
if ("FLOAT".equals(typeName)) {
final $Float type = newColumn($Float.class);
if (_default != null)
type.setDefault$(new $Float.Default$(Float.valueOf(_default)));
column = type;
} else if (typeName.startsWith("INT") || typeName.startsWith("MEDIUMINT")) {
final $Int type = newColumn($Int.class);
if (size != 2000000000)
type.setPrecision$(new $Int.Precision$((byte) size));
if (_default != null)
type.setDefault$(new $Int.Default$(Integer.valueOf(_default)));
if ("INTEGER".equals(typeName))
type.setGenerateOnInsert$(new $Int.GenerateOnInsert$($Integer.GenerateOnInsert$.AUTO_5FINCREMENT));
column = type;
} else if ("SMALLINT".equals(typeName)) {
final $Smallint type = newColumn($Smallint.class);
if (size != 2000000000)
type.setPrecision$(new $Smallint.Precision$((byte) size));
if (_default != null)
type.setDefault$(new $Smallint.Default$(Short.valueOf(_default)));
if (autoIncrement != null && autoIncrement)
type.setGenerateOnInsert$(new $Smallint.GenerateOnInsert$($Integer.GenerateOnInsert$.AUTO_5FINCREMENT));
column = type;
} else if ("TIME".equals(typeName)) {
final $Time type = newColumn($Time.class);
if (size != 2000000000)
type.setPrecision$(new $Time.Precision$((byte) size));
if (_default != null)
type.setDefault$(new $Time.Default$(_default.substring(1, _default.length() - 1)));
column = type;
} else if ("TINYINT".equals(typeName)) {
final $Tinyint type = newColumn($Tinyint.class);
if (size != 2000000000)
type.setPrecision$(new $Tinyint.Precision$((byte) size));
if (_default != null)
type.setDefault$(new $Tinyint.Default$(Byte.valueOf(_default)));
if (autoIncrement != null && autoIncrement)
type.setGenerateOnInsert$(new $Tinyint.GenerateOnInsert$($Integer.GenerateOnInsert$.AUTO_5FINCREMENT));
column = type;
} else {
throw new UnsupportedOperationException("Unsupported column type: " + typeName);
}
column.setName$(new $Column.Name$(columnName));
if (nullable != null && !nullable)
column.setNull$(new $Column.Null$(false));
return column;
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob in project flytekit-java by flyteorg.
the class LiteralMapDeserializer method deserialize.
private static Literal deserialize(JsonParser p, DeserializationContext ctxt, LiteralType literalType) throws IOException {
switch(literalType.getKind()) {
case SIMPLE_TYPE:
return deserialize(p, literalType.simpleType());
case COLLECTION_TYPE:
List<Literal> collection = new ArrayList<>();
verifyToken(p, JsonToken.START_ARRAY);
while (p.nextToken() != JsonToken.END_ARRAY) {
collection.add(deserialize(p, ctxt, literalType.collectionType()));
}
return Literal.ofCollection(unmodifiableList(collection));
case MAP_VALUE_TYPE:
Map<String, Literal> map = new HashMap<>();
verifyToken(p, JsonToken.START_OBJECT);
p.nextToken();
while (p.currentToken() != JsonToken.END_OBJECT) {
verifyToken(p, JsonToken.FIELD_NAME);
String fieldName = p.currentName();
p.nextToken();
map.put(fieldName, deserialize(p, ctxt, literalType.mapValueType()));
p.nextToken();
}
return Literal.ofMap(unmodifiableMap(map));
case BLOB_TYPE:
JavaType type = ctxt.constructType(Blob.class);
Blob blob = (Blob) ctxt.findNonContextualValueDeserializer(type).deserialize(p, ctxt);
return Literal.ofScalar(Scalar.ofBlob(blob));
case SCHEMA_TYPE:
throw new IllegalArgumentException(String.format("Unsupported LiteralType.Kind: [%s]", literalType.getKind()));
}
throw new AssertionError(String.format("Unexpected LiteralType.Kind: [%s]", literalType.getKind()));
}
Aggregations