001/*
002 * (C) Copyright 2006-2016 Nuxeo SA (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 *     Tiago Cardoso <tcardoso@nuxeo.com>
018 */
019package org.nuxeo.ecm.platform.threed.convert;
020
021import org.nuxeo.ecm.core.api.Blob;
022import org.nuxeo.ecm.core.api.blobholder.BlobHolder;
023import org.nuxeo.ecm.core.convert.api.ConversionException;
024
025import java.io.Serializable;
026import java.util.HashMap;
027import java.util.Map;
028import static org.nuxeo.ecm.platform.threed.convert.Constants.*;
029
030/**
031 * Batch conversion for 3D document types Generate thumbnail render, Collada version and LOD versions
032 *
033 * @since 8.4
034 */
035public class BatchConverter extends BaseBlenderConverter {
036
037    @Override
038    protected Map<String, Blob> getCmdBlobParameters(BlobHolder blobHolder, Map<String, Serializable> parameters)
039            throws ConversionException {
040        return null;
041    }
042
043    @Override
044    protected Map<String, String> getCmdStringParameters(BlobHolder blobHolder, Map<String, Serializable> parameters)
045            throws ConversionException {
046        Map<String, String> cmdStringParams = new HashMap<>();
047
048        String percPoly = null;
049        if (parameters.containsKey(PERC_POLY_PARAMETER)) {
050            percPoly = (String) parameters.get(PERC_POLY_PARAMETER);
051        } else if (initParameters.containsKey(PERC_POLY_PARAMETER)) {
052            percPoly = initParameters.get(PERC_POLY_PARAMETER);
053        }
054        cmdStringParams.put(PERC_POLY_PARAMETER, percPoly);
055
056        String maxPoly = null;
057        if (parameters.containsKey(MAX_POLY_PARAMETER)) {
058            maxPoly = (String) parameters.get(MAX_POLY_PARAMETER);
059        } else if (initParameters.containsKey(MAX_POLY_PARAMETER)) {
060            maxPoly = initParameters.get(MAX_POLY_PARAMETER);
061        }
062        cmdStringParams.put(MAX_POLY_PARAMETER, maxPoly);
063
064        String dimensions = null;
065        if (parameters.containsKey(DIMENSIONS_PARAMETER)) {
066            dimensions = (String) parameters.get(DIMENSIONS_PARAMETER);
067        } else if (initParameters.containsKey(DIMENSIONS_PARAMETER)) {
068            dimensions = initParameters.get(DIMENSIONS_PARAMETER);
069        }
070        cmdStringParams.put(DIMENSIONS_PARAMETER, dimensions);
071
072        return cmdStringParams;
073    }
074
075}