/** * ============LICENSE_START========================================== * org.onap.aai * =================================================================== * Copyright © 2017 AT&T Intellectual Property. All rights reserved. * Copyright © 2017 Amdocs * =================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ package org.onap.aai.champcore.graph.impl; import java.util.Map; import java.util.Optional; import org.onap.aai.champcore.ChampTransaction; import org.onap.aai.champcore.event.AbstractLoggingChampGraph; import org.onap.aai.champcore.exceptions.ChampMarshallingException; import org.onap.aai.champcore.exceptions.ChampObjectNotExistsException; import org.onap.aai.champcore.exceptions.ChampRelationshipNotExistsException; import org.onap.aai.champcore.exceptions.ChampSchemaViolationException; import org.onap.aai.champcore.exceptions.ChampTransactionException; import org.onap.aai.champcore.exceptions.ChampUnmarshallingException; import org.onap.aai.champcore.model.ChampObject; import org.onap.aai.champcore.model.ChampObjectConstraint; import org.onap.aai.champcore.model.ChampPartition; import org.onap.aai.champcore.model.ChampRelationship; import org.onap.aai.champcore.model.ChampRelationshipConstraint; import org.onap.aai.champcore.model.ChampSchema; import org.onap.aai.champcore.schema.ChampSchemaEnforcer; public abstract class AbstractValidatingChampGraph extends AbstractLoggingChampGraph { private ChampSchema schema = ChampSchema.emptySchema(); protected abstract ChampSchemaEnforcer getSchemaEnforcer(); protected abstract boolean isShutdown(); /** * Updates an existing vertex in the graph data store. *
* If a transaction context is not provided, then a transaction will be automatically * created and committed for this operation only, otherwise, the supplied transaction * will be used and it will be up to the caller to commit the transaction at its * discretion. *
*
* @param object - The vertex to be updated in the graph data store.
* @param transaction - Optional transaction context to perform the operation in.
*
* @return - The updated vertex, marshaled as a {@link ChampObject}
*
* @throws ChampMarshallingException - If the {@code relationship} is not able to be
* marshalled into the backend representation
* @throws ChampObjectNotExistsException - If {@link org.onap.aai.champcore.model.ChampObject#getKey}
* is not present or object not found in the graph
*/
protected abstract ChampObject doReplaceObject(ChampObject object, Optional
* If a transaction context is not provided, then a transaction will be automatically
* created and committed for this operation only, otherwise, the supplied transaction
* will be used and it will be up to the caller to commit the transaction at its
* discretion.
*
* @param object - The vertex to be stored in the graph data store.
* @param transaction - Optional transaction context to perform the operation in.
*
* @return - The vertex which was created, marshaled as a {@link ChampObject}
*
* @throws ChampMarshallingException - If the {@code relationship} is not able to be
* marshaled into the back end representation
* @throws ChampObjectNotExistsException - If {@link org.onap.aai.champcore.model.ChampObject#getKey}
* is not present or object not found in the graph
*/
protected abstract ChampObject doStoreObject(ChampObject object, Optional
* If a transaction context is not provided, then a transaction will be automatically
* created and committed for this operation only, otherwise, the supplied transaction
* will be used and it will be up to the caller to commit the transaction at its
* discretion.
*
* @param relationship - The edge to be replaced in the graph data store.
* @param transaction - Optional transaction context to perform the operation in.
*
* @return - The edge as it was replaced, marshaled as a {@link ChampRelationship}
*
* @throws ChampUnmarshallingException - If the edge which was created could not be
* unmarshaled into a ChampObject
* @throws ChampRelationshipNotExistsException - If {@link org.onap.aai.champcore.model.ChampRelationship#getKey}.isPresent()
* but the object cannot be found in the graph
* @throws ChampMarshallingException - If the {@code relationship} is not able to be
* marshaled into the back end representation
*/
protected abstract ChampRelationship doReplaceRelationship(ChampRelationship relationship, Optional
* If a transaction context is not provided, then a transaction will be automatically
* created and committed for this operation only, otherwise, the supplied transaction
* will be used and it will be up to the caller to commit the transaction at its
* discretion.
*
* @param relationship - The relationship to be stored in the graph data store.
* @param transaction - Optional transaction context to perform the operation in.
*
* @return - The relationship that was stored.
*
* @throws ChampUnmarshallingException - If the edge which was created could not be
* unmarshalled into a ChampObject
* @throws ChampObjectNotExistsException - If {@link org.onap.aai.champcore.model.ChampObject#getKey}
* is not present or object not found in the graph
* @throws ChampRelationshipNotExistsException - If {@link org.onap.aai.champcore.model.ChampRelationship#getKey}.isPresent()
* but the object cannot be found in the graph
* @throws ChampMarshallingException - If the {@code relationship} is not able to be
* marshalled into the backend representation
*/
protected abstract ChampRelationship doStoreRelationship(ChampRelationship relationship, Optional