/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright © 2012-2015 ForgeRock AS. All rights reserved.
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
* $Id$
*/
/**
* TableHandler appropriate for Oracle-specific query syntax.
*/
public OracleTableHandler(JsonValue tableConfig, String dbSchemaName, JsonValue queriesConfig, JsonValue commandsConfig,
}
public void create(String fullId, String type, String localId, Map<String, Object> obj, Connection connection)
connection.setAutoCommit(true);
connection.setAutoCommit(false);
try {
// Since ORACLE returns the ROWID instead of an autoincremented column, we have to tell the PreparedStatement to
// return the value of the "id-column" instead of the rowid. This is done by passing the following array to the PreparedStatement
createStatement = queries.getPreparedStatement(connection, queryMap.get(QueryDefinition.CREATEQUERYSTR), generatedColumns);
if (!validKeyEntry) {
throw new InternalServerErrorException("Object creation for " + fullId + " failed to retrieve an assigned ID from the DB.");
}
// Should now contain the value of the autoincremented column
} finally {
}
}
// ORACLE is not capable of using the DELETE statements defined in the StandardHandler, therefore we are changing them to
// something more ORACLEfriendly (thanks to the one that wrote the DB2 adapter
result.put(QueryDefinition.DELETEQUERYSTR, "DELETE FROM " + mainTable + " obj WHERE EXISTS (SELECT 1 FROM " + typeTable + " objtype WHERE obj.objecttypes_id = objtype.id AND objtype.objecttype = ?) AND obj.objectid = ? AND obj.rev = ?");
result.put(QueryDefinition.PROPDELETEQUERYSTR, "DELETE FROM " + propertyTable + " WHERE " + mainTableName + "_id = (SELECT obj.id FROM " + mainTable + " obj, " + typeTable + " objtype WHERE obj.objecttypes_id = objtype.id AND objtype.objecttype = ? AND obj.objectid = ?)");
return result;
}
/**
* @inheritDoc
*/
public String renderQueryFilter(QueryFilter<JsonPointer> filter, Map<String, Object> replacementTokens, Map<String, Object> params) {
// Create custom builder which overrides SQL output syntax
// note enclosing offsetParam and pageSizeParam - we don't bother passing these to the builder to deal with
final SQLBuilder builder =
new SQLBuilder() {
return "SELECT * FROM ( SELECT obj.fullobject, row_number() OVER ("
+ getOrderByClause().toSQL()
+ " ) rn "
+ getFromClause().toSQL()
+ getJoinClause().toSQL()
+ getWhereClause().toSQL()
+ getOrderByClause().toSQL()
+ ") WHERE rn BETWEEN "
+ (offsetParam + 1)
+ " AND "
+ (offsetParam + pageSizeParam)
+ " ORDER BY rn";
}
};
// "SELECT obj.* FROM mainTable obj..."
// join objecttypes to fix OPENIDM-2773
.and("objecttypes.objecttype = ${otype}"))
// override numeric value clause generation to cast propvalue to a number
}
},
// other half of OPENIDM-2773 fix
// JsonValue-cheat to avoid an unchecked cast
// Check for sort keys and build up order-by syntax
} else {
}
}
}