@Override public Object execute(Map<Object, Object> iArgs) { if (this.sequenceName == null) { throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet"); } final ODatabaseDocument database = getDatabase(); database.getMetadata().getSequenceLibrary().createSequence(this.sequenceName, this.sequenceType, this.params); return database.getMetadata().getSequenceLibrary().getSequenceCount(); }
@Override public Object execute(Map<Object, Object> iArgs) { if (this.sequenceName == null) { throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet"); } final ODatabaseDocument database = getDatabase(); database.getMetadata().getSequenceLibrary().dropSequence(this.sequenceName); return true; }
private void executeInternal(OCommandContext ctx, OResultInternal result) { OSequence.CreateParams params = createParams(ctx, result); OSequence.SEQUENCE_TYPE seqType = type == TYPE_CACHED ? OSequence.SEQUENCE_TYPE.CACHED : OSequence.SEQUENCE_TYPE.ORDERED; result.setProperty("type", seqType.toString()); ctx.getDatabase().getMetadata().getSequenceLibrary().createSequence(this.name.getStringValue(), seqType, params); }
@Override public Object execute(Map<Object, Object> iArgs) { if (this.sequenceName == null) { throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet"); } final ODatabaseDocument database = getDatabase(); OSequence sequence = database.getMetadata().getSequenceLibrary().getSequence(this.sequenceName); final boolean result = sequence.updateParams(this.params); sequence.reset(); sequence.save(getDatabase()); return result; }
@Override public OResultSet executeDDL(OCommandContext ctx) { final ODatabase database = ctx.getDatabase(); OSequence sequence = database.getMetadata().getSequenceLibrary().getSequence(this.name.getStringValue()); if (sequence == null) { if(ifExists){ return new OInternalResultSet(); }else { throw new OCommandExecutionException("Sequence not found: " + name); } } database.getMetadata().getSequenceLibrary().dropSequence(name.getStringValue()); OInternalResultSet rs = new OInternalResultSet(); OResultInternal result = new OResultInternal(); result.setProperty("operation", "drop sequence"); result.setProperty("sequenceName", name.getStringValue()); rs.add(result); return rs; }
OSequence sequence = database.getMetadata().getSequenceLibrary().getSequence(sequenceName); if (sequence == null) { throw new OCommandExecutionException("Sequence not found: " + sequenceName);
@Override public OResultSet executeSimple(OCommandContext ctx) { OSequence seq = ctx.getDatabase().getMetadata().getSequenceLibrary().getSequence(this.name.getStringValue()); if (seq != null) { if (ifNotExists) { return new OInternalResultSet(); } else { throw new OCommandExecutionException("Sequence " + name.getStringValue() + " already exists"); } } OResultInternal result = new OResultInternal(); result.setProperty("operation", "create sequence"); result.setProperty("name", name.getStringValue()); executeInternal(ctx, result); OInternalResultSet rs = new OInternalResultSet(); rs.add(result); return rs; }