package org.aksw.limes.core.ml.algorithm;

import java.lang.reflect.Constructor;

import org.aksw.limes.core.exceptions.UnsupportedMLImplementationException;
import org.aksw.limes.core.io.mapping.AMapping;

/**
 * @author Tommaso Soru (tsoru@informatik.uni-leipzig.de)
 *
 */
public class ActiveMLAlgorithm extends AMLAlgorithm {

    public final static MLImplementationType ML_IMPLEMENTATION_TYPE = MLImplementationType.SUPERVISED_ACTIVE;

    /**
     * @param clazz the CoreMLAlgorithm class
     * @throws UnsupportedMLImplementationException if ML implementation is not supported
     */
    public ActiveMLAlgorithm(Class<? extends ACoreMLAlgorithm> clazz) throws UnsupportedMLImplementationException {

        try {
            Constructor<? extends ACoreMLAlgorithm> ctor = clazz.getDeclaredConstructor();
            setMl(ctor.newInstance());
        } catch (Exception e) {
            throw new UnsupportedMLImplementationException(getMl().getName());
        }

        if (!getMl().supports(ML_IMPLEMENTATION_TYPE)) {
            throw new UnsupportedMLImplementationException(getMl().getName());
        }

    }

    /**
     * @param size number of examples to return
     * @return the mapping
     * @throws UnsupportedMLImplementationException if ML implementation is not supported
     */
    public AMapping getNextExamples(int size) throws UnsupportedMLImplementationException {
		throw new UnsupportedMLImplementationException("Not implemented yet!");
    }

    /**
     * @return wrap with results
     * @throws UnsupportedMLImplementationException Exception
     */
    public MLResults activeLearn() throws UnsupportedMLImplementationException {
        return getMl().activeLearn();
    }
    
    /**
     * @param oracleMapping mapping from the oracle
     * @return wrap with results
     * @throws UnsupportedMLImplementationException if ML implementation is not supported
     */
    public MLResults activeLearn(AMapping oracleMapping) throws UnsupportedMLImplementationException {
        return getMl().activeLearn(oracleMapping);
    }


}

@@ -324,20 +324,17 @@
 ithm %7B%0A%0A
-    
+%09
 public f
@@ -432,28 +432,22 @@
 CTIVE;%0A%0A
-    /**%0A    
+%09/**%0A%09
  * @para
@@ -453,16 +453,31 @@
 am clazz
+%0A%09 *           
  the Cor
@@ -495,20 +495,17 @@
 m class%0A
-    
+%09
  * @thro
@@ -535,32 +535,48 @@
 ntationException
+%0A%09 *            
  if ML implement
@@ -594,36 +594,30 @@
 t supported%0A
-     */%0A    
+%09 */%0A%09
 public Activ
@@ -721,33 +721,24 @@
  %7B%0A%0A
-        try %7B%0A           
+%09%09try %7B%0A%09%09%09final
  Con
@@ -813,28 +813,24 @@
 ctor();%0A
-            
+%09%09%09this.
 setMl(ct
@@ -848,24 +848,18 @@
 nce());%0A
-        
+%09%09
 %7D catch 
@@ -859,16 +859,22 @@
  catch (
+final 
 Exceptio
@@ -876,36 +876,27 @@
 eption e) %7B%0A
-            
+%09%09%09
 throw new Un
@@ -922,32 +922,37 @@
 tationException(
+this.
 getMl().getName(
@@ -959,32 +959,25 @@
 ));%0A
-        %7D%0A%0A        if (!
+%09%09%7D%0A%0A%09%09if (!this.
 getM
@@ -1016,28 +1016,19 @@
 YPE)) %7B%0A
-            
+%09%09%09
 throw ne
@@ -1066,16 +1066,21 @@
 ception(
+this.
 getMl().
@@ -1095,52 +1095,52 @@
 ));%0A
-        %7D%0A%0A    %7D%0A%0A    /**%0A     * @param size
+%09%09%7D%0A%0A%09%7D%0A%0A%09/**%0A%09 * @param size%0A%09 *           
  num
@@ -1165,20 +1165,17 @@
  return%0A
-    
+%09
  * @retu
@@ -1189,20 +1189,17 @@
 mapping%0A
-    
+%09
  * @thro
@@ -1229,32 +1229,48 @@
 ntationException
+%0A%09 *            
  if ML implement
@@ -1288,36 +1288,30 @@
 t supported%0A
-     */%0A    
+%09 */%0A%09
 public AMapp
@@ -1392,99 +1392,61 @@
 %7B%0A%09%09
-throw new UnsupportedMLImplementationException(%22Not implemented yet!%22);%0A    %7D%0A%0A    /**%0A    
+return this.getMl().getNextExamples(size);%0A%09%7D%0A%0A%09/**%0A%09
  * @
@@ -1462,36 +1462,33 @@
 ap with results%0A
-    
+%09
  * @throws Unsup
@@ -1522,31 +1522,41 @@
 tion
- Exception%0A     */%0A    
+%0A%09 *             Exception%0A%09 */%0A%09
 publ
@@ -1624,39 +1624,38 @@
 Exception %7B%0A
-        
+%09%09
 return 
+this.
 getMl().acti
@@ -1669,31 +1669,18 @@
 ();%0A
-    %7D%0A    %0A    /**%0A    
+%09%7D%0A%0A%09/**%0A%09
  * @
@@ -1698,16 +1698,31 @@
 eMapping
+%0A%09 *           
  mapping
@@ -1738,20 +1738,17 @@
  oracle%0A
-    
+%09
  * @retu
@@ -1768,20 +1768,17 @@
 results%0A
-    
+%09
  * @thro
@@ -1816,16 +1816,32 @@
 xception
+%0A%09 *            
  if ML i
@@ -1875,20 +1875,14 @@
 ted%0A
-     */%0A    
+%09 */%0A%09
 publ
@@ -1980,23 +1980,22 @@
 n %7B%0A
-        
+%09%09
 return 
+this.
 getM
@@ -2030,14 +2030,10 @@
 g);%0A
-    %7D%0A
+%09%7D
 %0A%0A%7D%0A

Fix problem with UnsupportedMLImplementationException