001/*
002 *  Copyright 2019 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.plugins.queriesdirectory;
017
018import javax.jcr.Node;
019
020import org.ametys.plugins.repository.AmetysObject;
021import org.ametys.plugins.repository.AmetysRepositoryException;
022import org.ametys.plugins.repository.MovableAmetysObject;
023import org.ametys.plugins.repository.RepositoryIntegrityViolationException;
024import org.ametys.plugins.repository.jcr.DefaultTraversableAmetysObject;
025
026/**
027 * Class representing a query container, backed by a JCR node.<br>
028 */
029public class QueryContainer extends DefaultTraversableAmetysObject<QueryContainerFactory> implements MovableAmetysObject
030{
031    /**
032     * Creates a {@link QueryContainer}.
033     * @param node the node backing this {@link AmetysObject}
034     * @param parentPath the parentPath in the Ametys hierarchy
035     * @param factory the DefaultAmetysObjectFactory which created the AmetysObject
036     */
037    public QueryContainer(Node node, String parentPath, QueryContainerFactory factory)
038    {
039        super(node, parentPath, factory);
040    }
041    
042    @Override
043    public boolean canMoveTo(AmetysObject newParent) throws AmetysRepositoryException
044    {
045        return QueryAndContainerCommonMethods.canMoveTo(newParent, this, _getFactory().getQueryDAO());
046    }
047    
048    @Override
049    public void moveTo(AmetysObject newParent, boolean renameIfExist) throws AmetysRepositoryException, RepositoryIntegrityViolationException
050    {
051        QueryAndContainerCommonMethods.moveTo(newParent, renameIfExist, this);
052    }
053    
054    @Override
055    public void orderBefore(AmetysObject siblingNode) throws AmetysRepositoryException
056    {
057        QueryAndContainerCommonMethods.orderBefore(siblingNode, this);
058    }
059}