/**
 *  Copyright (c) 2012, 2015 Sme.UP and others.
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  which accompanies this distribution, and is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 *
 *
 * Contributors:
 *   Franco Lombardo - Initial API and implementation
 */
package org.smeup.sys.os.lib.base.api;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import org.smeup.sys.il.data.QCharacter;
import org.smeup.sys.il.data.QEnum;
import org.smeup.sys.il.data.QScroller;
import org.smeup.sys.il.data.annotation.DataDef;
import org.smeup.sys.il.data.annotation.Main;
import org.smeup.sys.il.data.annotation.Program;
import org.smeup.sys.os.core.QExceptionManager;
import org.smeup.sys.os.core.jobs.QJob;
import org.smeup.sys.os.core.jobs.QJobLogManager;
import org.smeup.sys.os.lib.QLibraryManager;
import org.smeup.sys.os.lib.base.api.tools.CurrentLibraryChangeHelper;

@Program(name = "QLICHLIB")
public class LibraryListChanger {

	public static enum QCPFMSG {
		CPF2110
	}

	@Inject
	private QExceptionManager exceptionManager;
	@Inject
	private QJob job;
	@Inject
	private QLibraryManager libraryManager;
	@Inject
	private QJobLogManager jobLogManager;

	@Main
	public void main(@DataDef(dimension = 250, length = 10) QScroller<QEnum<LIBRARIESFORCURRENTTHREADEnum, QCharacter>> librariesForCurrentThread,
			@DataDef(length = 10) QEnum<CURRENTLIBRARYEnum, QCharacter> currentLibrary) {

		switch (librariesForCurrentThread.first().asEnum()) {
		case SAME:
			break;

		case NONE:
			job.getLibraries().clear();
			job.getLibraries().add(job.getSystem().getSystemLibrary());
			break;

		case OTHER:
			List<String> newLibList = new ArrayList<String>();
			for (QEnum<LIBRARIESFORCURRENTTHREADEnum, QCharacter> libEnum : librariesForCurrentThread) {
				String lib = libEnum.asData().trimR();
				if (!lib.isEmpty()) 
					newLibList.add(lib);
			}
			if (newLibList.size() > 0) {
				job.getLibraries().clear();
				job.getLibraries().add(job.getSystem().getSystemLibrary());
				job.getLibraries().addAll(newLibList);
			}
			break;
		}

		new CurrentLibraryChangeHelper(job, libraryManager, jobLogManager, exceptionManager).changeCurrentLibrary(currentLibrary);
	}

	public static enum LIBRARIESFORCURRENTTHREADEnum {
		SAME, NONE, OTHER
	}
}

@@ -778,24 +778,71 @@
 n.Program;%0D%0A
+import org.smeup.sys.il.memo.QResourceReader;%0D%0A
 import org.s
@@ -962,32 +962,71 @@
 JobLogManager;%0D%0A
+import org.smeup.sys.os.lib.QLibrary;%0D%0A
 import org.smeup
@@ -1890,18 +1890,109 @@
 e OTHER:
+ %7B%0D%0A%09%09%09QResourceReader%3CQLibrary%3E libraryReader = libraryManager.getLibraryReader(job);%0D%0A%09%09%09
 %0D%0A
-
 %09%09%09List%3C
@@ -2191,9 +2191,8 @@
 if (
-!
 lib.
@@ -2201,17 +2201,67 @@
 Empty())
- 
+%0D%0A%09%09%09%09%09continue;%0D%0A%09%09%09%09if(libraryReader.exists(lib))
 %0D%0A%09%09%09%09%09n
@@ -2468,16 +2468,16 @@
 %0D%0A%09%09%09%7D%0D%0A
-
 %09%09%09break
@@ -2483,16 +2483,21 @@
 k;%0D%0A%09%09%7D%0D
+%0A%09%09%7D%0D
 %0A%0D%0A%09%09new

Patch per librerie mancanti