001/** 002 * Copyright 2015 Tampere University of Technology, Pori Department 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 service.tut.pori.fuzzyvisuals; 017 018import org.apache.log4j.Logger; 019 020import core.tut.pori.context.ServiceInitializer; 021import service.tut.pori.contentanalysis.Definitions; 022import service.tut.pori.contentanalysis.AsyncTask.TaskType; 023 024/** 025 * Fuzzy Visuals core methods 026 * 027 */ 028public final class FuzzyVisualsCore { 029 private static final Logger LOGGER = Logger.getLogger(FuzzyVisualsCore.class); 030 031 /** 032 * 033 * @param taskDetails 034 * @throws IllegalArgumentException 035 */ 036 public static void addTask(TaskDetails taskDetails) throws IllegalArgumentException { 037 TaskType taskType = taskDetails.getTaskType(); 038 if(taskType == null){ 039 throw new IllegalArgumentException(Definitions.ELEMENT_TASK_TYPE+" is missing."); 040 } 041 switch(taskType){ 042 case BACKEND_FEEDBACK: 043 case FEEDBACK: 044 LOGGER.debug("Receiving task of type "+taskType.name()+", returning OK."); 045 break; 046 case ANALYSIS: 047 ServiceInitializer.getExecutorHandler().getExecutor().execute(new FuzzyAnalysisTask(taskDetails.getBackendId(), taskDetails.getCallbackUri(), taskDetails.getMedia(), taskDetails.getTaskId())); 048 break; 049 default: 050 throw new IllegalArgumentException("Unsupported "+Definitions.ELEMENT_TASK_TYPE+" : "+taskType.name()); 051 } 052 } 053}