001/* 002 * (C) Copyright 2018 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 * Antoine Taillefer <[email protected]> 018 */ 019package org.nuxeo.ecm.platform.picture.operation; 020 021import org.nuxeo.ecm.automation.core.Constants; 022import org.nuxeo.ecm.automation.core.annotations.Context; 023import org.nuxeo.ecm.automation.core.annotations.Operation; 024import org.nuxeo.ecm.automation.core.annotations.OperationMethod; 025import org.nuxeo.ecm.automation.core.annotations.Param; 026import org.nuxeo.ecm.core.api.CoreSession; 027import org.nuxeo.ecm.core.work.api.WorkManager; 028import org.nuxeo.ecm.platform.picture.recompute.ImagingRecomputeWork; 029import org.nuxeo.runtime.api.Framework; 030 031/** 032 * Recomputes the picture views of the documents resulting from the provided NXQL query. 033 * 034 * @since 10.3 035 */ 036@Operation(id = RecomputePictureViews.ID, category = Constants.CAT_SERVICES, label = "Recompute Picture Views", description = "Recompute the picture views of the documents resulting from the provided NXQL query.", since = "10.3") 037public class RecomputePictureViews { 038 039 public static final String ID = "Picture.RecomputeViews"; 040 041 public static final String DEFAULT_QUERY = "SELECT * FROM Document WHERE ecm:mixinType = 'Picture' AND picture:views/*/title IS NULL"; 042 043 @Context 044 protected CoreSession session; 045 046 @Param(name = "query", description = "NXQL query to collect the documents whose picture views to recompute.", values = { 047 DEFAULT_QUERY }) 048 protected String query; 049 050 @OperationMethod 051 public void run() { 052 ImagingRecomputeWork work = new ImagingRecomputeWork(session.getRepositoryName(), query); 053 Framework.getService(WorkManager.class).schedule(work); 054 } 055 056}