001/*
002 * (C) Copyright 2006-2017 Nuxeo (http://nuxeo.com/) and others.
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 *
016 * Contributors:
017 *     Florent Guillaume
018 */
019package org.nuxeo.ecm.core.storage.sql;
020
021import java.io.Serializable;
022import java.util.Calendar;
023import java.util.Collection;
024import java.util.Map;
025import java.util.Set;
026
027import org.nuxeo.ecm.core.api.IterableQueryResult;
028import org.nuxeo.ecm.core.api.PartialList;
029import org.nuxeo.ecm.core.api.ScrollResult;
030import org.nuxeo.ecm.core.query.QueryFilter;
031
032/**
033 * A {@link Mapper} that uses a {@link SoftRefCachingRowMapper} for row-related operation, and delegates to the
034 * {@link Mapper} for others.
035 */
036public class SoftRefCachingMapper extends SoftRefCachingRowMapper implements CachingMapper {
037
038    /**
039     * The {@link Mapper} to which operations are delegated.
040     */
041    public Mapper mapper;
042
043    @Override
044    public void initialize(String repositoryName, Model model, Mapper mapper, VCSInvalidationsPropagator cachePropagator,
045            Map<String, String> properties) {
046        super.initialize(repositoryName, model, mapper, cachePropagator, properties);
047        this.mapper = mapper;
048    }
049
050    @Override
051    public ScrollResult scroll(String query, int batchSize, int keepAliveSeconds) {
052        return mapper.scroll(query, batchSize, keepAliveSeconds);
053    }
054
055    @Override
056    public ScrollResult scroll(String query, QueryFilter queryFilter, int batchSize, int keepAliveSeconds) {
057        return mapper.scroll(query, queryFilter, batchSize, keepAliveSeconds);
058    }
059
060    @Override
061    public ScrollResult scroll(String scrollId) {
062        return mapper.scroll(scrollId);
063    }
064
065    @Override
066    public Identification getIdentification() {
067        return mapper.getIdentification();
068    }
069
070    @Override
071    public void close() {
072        super.close();
073        mapper.close();
074    }
075
076    @Override
077    public int getTableSize(String tableName) {
078        return mapper.getTableSize(tableName);
079    }
080
081    @Override
082    public Serializable getRootId(String repositoryId) {
083        return mapper.getRootId(repositoryId);
084    }
085
086    @Override
087    public void setRootId(Serializable repositoryId, Serializable id) {
088        mapper.setRootId(repositoryId, id);
089    }
090
091    @Override
092    public PartialList<Serializable> query(String query, String queryType, QueryFilter queryFilter,
093            boolean countTotal) {
094        return mapper.query(query, queryType, queryFilter, countTotal);
095    }
096
097    @Override
098    public PartialList<Serializable> query(String query, String queryType, QueryFilter queryFilter, long countUpTo) {
099        return mapper.query(query, queryType, queryFilter, countUpTo);
100    }
101
102    @Override
103    public IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter,
104            boolean distinctDocuments, Object... params) {
105        return mapper.queryAndFetch(query, queryType, queryFilter, distinctDocuments, params);
106    }
107
108    @Override
109    public PartialList<Map<String, Serializable>> queryProjection(String query, String queryType,
110            QueryFilter queryFilter, boolean distinctDocuments, long countUpTo, Object... params) {
111        return mapper.queryProjection(query, queryType, queryFilter, distinctDocuments, countUpTo, params);
112    }
113
114    @Override
115    public Set<Serializable> getAncestorsIds(Collection<Serializable> ids) {
116        return mapper.getAncestorsIds(ids);
117    }
118
119    @Override
120    public void updateReadAcls() {
121        mapper.updateReadAcls();
122    }
123
124    @Override
125    public void rebuildReadAcls() {
126        mapper.rebuildReadAcls();
127    }
128
129    @Override
130    public int getClusterNodeIdType() {
131        return mapper.getClusterNodeIdType();
132    }
133
134    @Override
135    public void createClusterNode(Serializable nodeId) {
136        mapper.createClusterNode(nodeId);
137    }
138
139    @Override
140    public void removeClusterNode(Serializable nodeId) {
141        mapper.removeClusterNode(nodeId);
142    }
143
144    @Override
145    public void insertClusterInvalidations(Serializable nodeId, VCSInvalidations invalidations) {
146        mapper.insertClusterInvalidations(nodeId, invalidations);
147    }
148
149    @Override
150    public VCSInvalidations getClusterInvalidations(Serializable nodeId) {
151        return mapper.getClusterInvalidations(nodeId);
152    }
153
154    @Override
155    public void markReferencedBinaries() {
156        mapper.markReferencedBinaries();
157    }
158
159    @Override
160    public int cleanupDeletedRows(int max, Calendar beforeTime) {
161        return mapper.cleanupDeletedRows(max, beforeTime);
162    }
163
164}