diff --git a/ucc/ucc.api/pom.xml b/ucc/ucc.api/pom.xml index 0e14ef2f91f2fd03fbf021ff01da4980f5debe03..60e2c6bb3bf7ae50b750011b2243851382c07ba9 100644 --- a/ucc/ucc.api/pom.xml +++ b/ucc/ucc.api/pom.xml @@ -22,6 +22,11 @@ <artifactId>qtjambi</artifactId> <version>4.5.2_01</version> </dependency> + <dependency> + <groupId>org.universAAL.middleware</groupId> + <artifactId>mw.managers.api</artifactId> + <version>1.0.0-SNAPSHOT</version> + </dependency> </dependencies> <build> <plugins> diff --git a/ucc/ucc.api/src/main/java/org/universAAL/ucc/api/core/IInstaller.java b/ucc/ucc.api/src/main/java/org/universAAL/ucc/api/core/IInstaller.java index 2737e90d07f6e0a0b69f1cd0b0e9dc9b6df47941..5bffa9911a006e745fcd6c257aed3df1acd92963 100644 --- a/ucc/ucc.api/src/main/java/org/universAAL/ucc/api/core/IInstaller.java +++ b/ucc/ucc.api/src/main/java/org/universAAL/ucc/api/core/IInstaller.java @@ -1,9 +1,13 @@ package org.universAAL.ucc.api.core; import java.io.File; +import java.net.URI; import java.util.ArrayList; +import java.util.List; +import java.util.Map; import org.osgi.framework.Bundle; +import org.universAAL.middleware.managers.api.InstallationResults; public interface IInstaller { @@ -11,5 +15,6 @@ public interface IInstaller { public ArrayList<Bundle> getInstalledBundles(); public void resetBundles(); public void revertInstallation(File folder); - + public Map getPeers(); + public InstallationResults requestToInstall(URI deployFolder, Map layout); } diff --git a/ucc/ucc.core/pom.xml b/ucc/ucc.core/pom.xml index bda57620fde69044d93ed7e278178a69c77e0009..d42ce34c05f44fb75d95d4952c188cfc879f3516 100644 --- a/ucc/ucc.core/pom.xml +++ b/ucc/ucc.core/pom.xml @@ -42,6 +42,16 @@ <artifactId>com.hp.hpl.jena.tdb</artifactId> <version>0.3-incubating</version> </dependency> + <dependency> + <groupId>org.universAAL.middleware</groupId> + <artifactId>mw.interfaces</artifactId> + <version>1.0.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.universAAL.middleware</groupId> + <artifactId>mw.managers.api</artifactId> + <version>1.0.0-SNAPSHOT</version> + </dependency> </dependencies> diff --git a/ucc/ucc.core/src/main/java/org/universAAL/ucc/core/installation/Installer.java b/ucc/ucc.core/src/main/java/org/universAAL/ucc/core/installation/Installer.java index 475f25398e8ebb5bec156a4b8ba2ad4ccfe9c307..be2eaafea48f3e1593ad59a30ed9870d559f0543 100644 --- a/ucc/ucc.core/src/main/java/org/universAAL/ucc/core/installation/Installer.java +++ b/ucc/ucc.core/src/main/java/org/universAAL/ucc/core/installation/Installer.java @@ -8,9 +8,14 @@ import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; +import java.net.URI; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Enumeration; +import java.util.HashMap; import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.zip.ZipEntry; @@ -22,10 +27,18 @@ import java.util.zip.ZipInputStream; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; +import org.universAAL.middleware.container.ModuleContext; +import org.universAAL.middleware.container.osgi.uAALBundleContainer; +import org.universAAL.middleware.interfaces.PeerCard; +import org.universAAL.middleware.interfaces.PeerRole; +import org.universAAL.middleware.managers.api.DeployManager; +import org.universAAL.middleware.managers.api.AALSpaceManager; +import org.universAAL.middleware.managers.api.InstallationResults; import org.universAAL.ucc.api.core.IInstaller; import org.universAAL.ucc.core.Activator; + /** * @author Alex * @version 1.0 @@ -39,6 +52,9 @@ public class Installer extends ApplicationManager implements IInstaller { private BundleContext context; private ArrayList<Bundle> installedBundles=new ArrayList<Bundle>(); private boolean mpa = false; // flag to indicate if the application is MPA + private boolean initialized = false; + private DeployManager deployManager; + private AALSpaceManager aalSpaceManager; public Installer(BundleContext con) { context=con; @@ -59,9 +75,11 @@ public class Installer extends ApplicationManager implements IInstaller { */ public String installApplication(String path) throws Exception { //Activator.getModel().getApplicationRegistration().writeToConfigFile("test"); - + //System.out.println("[Installer.installApplication] the path for install is: " + path); String exdir=extractBundles(path); if(exdir==null)throw new Exception("Error extracting uaal Package"); + // convert "/" to "\" + exdir = exdir.replaceAll("/", "\\"); File appDir=new File(exdir); checkApplicationForInstall(appDir); if (!mpa) { @@ -77,7 +95,7 @@ public class Installer extends ApplicationManager implements IInstaller { installedBundles.add(temp); } } - } + } return exdir; } @@ -105,7 +123,11 @@ public class Installer extends ApplicationManager implements IInstaller { if(!jarok) throw new Exception("There is no installable jar File in uaal Package!"); if(!configok) throw new Exception("config.owl file not found!"); //if(!eulaok) throw new Exception("No License agreement found!"); - if(mpa) System.out.println("This is a multi-part application..."); + if(mpa) { + System.out.println("This is a multi-part application, initialing..."); + // initialization: get references to DeployManager and AALSpaceManager + initMpaInstallation(); + } } @@ -156,11 +178,14 @@ public class Installer extends ApplicationManager implements IInstaller { private String extractBundles(String path) { - - String destDir = path.substring(path.lastIndexOf(File.separator) + 1,path.lastIndexOf(".")); - //destDir =Activator.getInformation().getBundleDir()+"/"+ destDir; Does this work only on Linux/Unix? - destDir =Activator.getInformation().getBundleDir()+"\\"+ destDir; // For windows version + String destDir = path.substring(path.lastIndexOf(File.separator) + 1,path.lastIndexOf(".")); + destDir =Activator.getInformation().getBundleDir() +"/"+ destDir; //Does this work only on Linux/Unix? + //System.out.println("[Installer.extractBundles] destDir is " + destDir); + destDir =destDir.replace("/", "\\"); // For windows version + //System.out.println("[Installer.extractBundles] destDir2 is " + destDir); File appDir=new File(destDir); + System.out.println("[Installer.extractBundles] the path for zip file is: " + path + + " and the destination path is: " + destDir); int suffix=1; int slength=0; while(appDir.exists()){ @@ -199,7 +224,7 @@ public void revertInstallation(File folder){ static public void extractFolder(String zipFile, String destdir) throws ZipException, IOException { - System.out.println(zipFile); + //System.out.println("[Installer.extractFolder] the zip file is: " + zipFile); int BUFFER = 2048; File file = new File(zipFile); @@ -244,7 +269,110 @@ static public void extractFolder(String zipFile, String destdir) throws ZipExcep is.close(); } - } + } } + + /** + * initiation for MPA installation + * - get AALSpaceManager + * - get DeployManager + */ + private boolean initMpaInstallation() { + System.out.println("[Installer.initMpaInstallation]"); + ModuleContext moduleContext = uAALBundleContainer.THE_CONTAINER.registerModule(new Object[] { context }); + + Object[] aalManagers = (Object[]) moduleContext.getContainer().fetchSharedObject(moduleContext,new Object[]{AALSpaceManager.class.getName().toString()}); + if(aalManagers != null){ + moduleContext.logDebug("AALSpaceManagers found...", null); + System.out.println("[MpaParser] AALSpaceManagers found..."); + if(aalManagers[0] instanceof AALSpaceManager){ + aalSpaceManager = (AALSpaceManager)aalManagers[0]; + } + + else{ + moduleContext.logWarn("No AALSpaceManagers found", null); + System.out.println("[Installer.initMpaInstallation]No AALSpaceManagers found"); + initialized = false; + return initialized; + } + }else{ + moduleContext.logWarn("No AALSpaceManagers found", null); + System.out.println("[MpaParser]No AALSpaceManagers found"); + initialized = false; + return initialized; + } + + + Object refs = moduleContext.getContainer().fetchSharedObject(moduleContext,new Object[]{DeployManager.class.getName().toString()}); + if(refs != null){ + deployManager = (DeployManager)refs; + // -- just for testing + URI mpaUri = null; + try { + mpaUri = new URI("http://aaloa.isti.cnr.it/Ping-Pong-mpa.xml"); + Map layout = new HashMap(); + PeerCard card1= new PeerCard("DeployNode1", PeerRole.PEER); + layout.put(card1, "Part1"); + System.out.println("[Installer] call deploy manager to install " + mpaUri.toString() + " for " + + layout.toString()); + deployManager.requestToInstall(mpaUri, layout); + } catch (URISyntaxException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + // -- end for testing + + initialized = true; + return initialized; + }else{ + moduleContext.logWarn("No DeployManager found", null); + System.out.println("No DeployManager found"); + initialized = false; + return initialized; + } + } + + /** + * call DeployManager to install MPA using the specified layout + * + */ + public InstallationResults requestToInstall(URI deployFolder, Map layout) { + System.out.println("[Installer.requestToInstall] deployFolder: " + deployFolder); + if (deployManager==null) { + System.out.println("[Installer.requestToInstall] No deploy manager exists!"); + return InstallationResults.FAILED; + } + System.out.println("[Installer.requestToInstall] Call deploy manager to install..."); + return deployManager.requestToInstall(deployFolder, layout); + } + + /** + * get peers in AALSpace from the AALSpaceManager + * + */ + public Map<String, PeerCard> getPeers() { + Map peers = new HashMap(); + if (aalSpaceManager!=null) { + peers = aalSpaceManager.getPeers(); + System.out.println("[Installer.getPeers()]" + peers.toString()); + } else { + // use faked data to test without really connected to DeployManager + PeerCard card= new PeerCard(PeerRole.PEER, "karaf", "Java"); + System.out.println("[Installer.getPeers] peerCard1 for testing: " + card.getPeerID() + "/" + + card.getOS() + "/" + card.getPLATFORM_UNIT() + "/" + card.getCONTAINER_UNIT() + "/" + card.getRole()); + peers.put("Node1", card); + card= new PeerCard(PeerRole.PEER, "karaf", "Java"); // to have a different unique PeerId + peers.put("Node2", card); + System.out.println("[Installer.getPeers] peerCard2 for testing: " + card.getPeerID() + "/" + + card.getOS() + "/" + card.getPLATFORM_UNIT() + "/" + card.getCONTAINER_UNIT() + "/" + card.getRole()); + card= new PeerCard(PeerRole.PEER, "karaf", "C++"); // to have a different unique PeerId + peers.put("Node3", card); + System.out.println("[Installer.getPeers] peerCard3 for testing: " + card.getPeerID() + "/" + + card.getOS() + "/" + card.getPLATFORM_UNIT() + "/" + card.getCONTAINER_UNIT() + "/" + card.getRole()); + } + return peers; + } + } \ No newline at end of file diff --git a/ucc/ucc.viewjambi/pom.xml b/ucc/ucc.viewjambi/pom.xml index 57221be94ce07be703944c602bbd916c3d26127c..6e18d0b2aaae8506709e7c04b2639bbcf2b4f8f7 100644 --- a/ucc/ucc.viewjambi/pom.xml +++ b/ucc/ucc.viewjambi/pom.xml @@ -27,6 +27,16 @@ <artifactId>qtjambi</artifactId> <version>4.5.2_01</version> </dependency> + <dependency> + <groupId>org.universAAL.middleware</groupId> + <artifactId>mw.interfaces</artifactId> + <version>1.0.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.universAAL.middleware</groupId> + <artifactId>mw.connectors.api</artifactId> + <version>1.0.0-SNAPSHOT</version> + </dependency> </dependencies> <build> <plugins> diff --git a/ucc/ucc.viewjambi/src/main/java/org/universAAL/ucc/viewjambi/impl/MainWindow.java b/ucc/ucc.viewjambi/src/main/java/org/universAAL/ucc/viewjambi/impl/MainWindow.java index 00bd512ec7300f8779f8576af4c54dd1b7ba37d9..5007b981fb8f4b5ef783fa4b554e222d27aa3085 100644 --- a/ucc/ucc.viewjambi/src/main/java/org/universAAL/ucc/viewjambi/impl/MainWindow.java +++ b/ucc/ucc.viewjambi/src/main/java/org/universAAL/ucc/viewjambi/impl/MainWindow.java @@ -2,6 +2,7 @@ package org.universAAL.ucc.viewjambi.impl; import java.io.IOException; import java.util.HashMap; +import java.util.Map; import org.universAAL.ucc.api.core.IDeinstaller; import org.universAAL.ucc.api.view.IMainWindow; @@ -11,8 +12,10 @@ import org.universAAL.ucc.viewjambi.information.InformationView; import org.universAAL.ucc.viewjambi.install.ConfigView; import org.universAAL.ucc.viewjambi.install.DeinstallView; import org.universAAL.ucc.viewjambi.install.DeployConfigView; +import org.universAAL.ucc.viewjambi.install.DeployStrategyView; import org.universAAL.ucc.viewjambi.install.InstallView; import org.universAAL.ucc.viewjambi.install.LicenseView; +import org.universAAL.ucc.viewjambi.install.MpaParser; import org.universAAL.ucc.viewjambi.juic.Ui_MainWindow; import org.universAAL.ucc.viewjambi.overview.OverviewView; @@ -112,8 +115,11 @@ public class MainWindow extends QMainWindow implements IMainWindow { public void deinstallApp(){ new DeinstallView(); } - public void deployConfigure(String path){ - new DeployConfigView(path); + public void deployConfigure(String path, MpaParser mpa, Map peers){ + new DeployConfigView(path, mpa, peers); + } + public void deployStrategy(String path){ + new DeployStrategyView(path); } protected void uninstallApp() { diff --git a/ucc/ucc.viewjambi/src/main/java/org/universAAL/ucc/viewjambi/install/DeployConfigView.java b/ucc/ucc.viewjambi/src/main/java/org/universAAL/ucc/viewjambi/install/DeployConfigView.java index fdc96713c0a256d6ca090d5ecaf65c9718238006..641c956c3259bfa490cd1eaf9a6050fac05f54c3 100644 --- a/ucc/ucc.viewjambi/src/main/java/org/universAAL/ucc/viewjambi/install/DeployConfigView.java +++ b/ucc/ucc.viewjambi/src/main/java/org/universAAL/ucc/viewjambi/install/DeployConfigView.java @@ -1,226 +1,203 @@ package org.universAAL.ucc.viewjambi.install; +import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Vector; +import java.util.Map; +import java.util.Set; +import org.universAAL.middleware.connectors.deploy.model.Part; +import org.universAAL.middleware.interfaces.PeerCard; import org.universAAL.ucc.viewjambi.common.SubWindow; +import org.universAAL.ucc.viewjambi.impl.Activator; import org.universAAL.ucc.viewjambi.impl.MainWindow; import org.universAAL.ucc.viewjambi.juic.Ui_DeployConfigView; - -import com.trolltech.qt.core.QModelIndex; import com.trolltech.qt.gui.*; public class DeployConfigView extends SubWindow { - private static Ui_DeployConfigView ui = new Ui_DeployConfigView(); - - String[] deployNodes = {"node1", "node2", "node3", "node4"}; - HashMap layout/*<String, List>*/ = new HashMap(); /* <ApplicationPartId, deployNodesId> */ - //HashMap deployConfig = new HashMap(); // user selected configuration - // when the final screen "next" is pressed, the layout contains the updated config - - QStringListModel listModel = new QStringListModel(this); + private static Ui_DeployConfigView ui = new Ui_DeployConfigView(); int currentScreen = 0; // pointer to the application part; one part has one screen - ArrayList screens = new ArrayList(); // index - appId - + ArrayList screens = new ArrayList(); // index - Part + String deployPath; + MpaParser mpa; + Map<String, PeerCard> peers; + Map<PeerCard, Part> mpaLayout = new HashMap<PeerCard, Part>(); // the layout selected by the user - final version and sent to the MW for installation (one peer only for one part) + Map<Part, String> layout = new HashMap<Part, String>(); // layout selected by the user <Part, PeerId>- working version: ensures that each part has only one peer - /** - * - * @param path The path of the extracted files from .uaal - */ - public DeployConfigView(String path) { - super(DeployConfigView.ui); - - // call MW Deploy Manager to get the deploy layout based on the MPA manifest - // To integrate with MW: layout = checkDeployLayout - layout = getDeployLayout(path); - - // create screens for the list of app part ID - Iterator itr = layout.keySet().iterator(); - while (itr.hasNext()) { - screens.add((String)itr.next()); - } - - // test - for (int i=0; i<screens.size(); i++) - System.out.println("the " + i + "th screen is for " + screens.get(i)); - - - - // initialization of the ui components - ui.radioButton_all.clicked.connect(this, "onAllNodes()"); - //ui.radioButton_all.setChecked(true); - //onAllNodes(); - ui.radioButton_selected.clicked.connect(this, "onSelectedNodes()"); - - - ui.pushButton_add.setCheckable(true); - ui.pushButton_add.clicked.connect(this, "addNode()"); - ui.pushButton_remove.setCheckable(true); - ui.pushButton_remove.clicked.connect(this, "removeNode()"); - - ui.pushButton_cancel.clicked.connect(this, "cancel()"); - ui.pushButton_next.clicked.connect(this, "nextScreen()"); - ui.pushButton_previous.clicked.connect(this, "previousScreen()"); - - // initialize the first screen - initGuiForAppPart(0); - + public DeployConfigView(String path, MpaParser mpa, Map peers) { + super(DeployConfigView.ui); + this.deployPath = path; + this.mpa = mpa; + this.peers = peers; + + // get Parts and associate them with ScreenId + List<Part> parts = mpa.getApplicationPart().getPart(); + for (int i=0; i<parts.size(); i++) + screens.add(parts.get(i)); + + // initialization of the ui components + ui.pushButton_cancel.clicked.connect(this, "cancel()"); + ui.pushButton_previous.clicked.connect(this, "previousScreen()"); + ui.pushButton_next.clicked.connect(this, "nextScreen()"); + // initialize the ComboBox using data from peers (peer Id/String?) + Set keys = peers.keySet(); + for (Iterator i = keys.iterator(); i.hasNext();) { + String peerId = (String) i.next(); + ui.comboBox.addItem(peerId); + } + ui.comboBox.highlighted.connect(this, "peerSelected(String)"); + // initialize the first screen + initGuiForAppPart(0); + } - + /** * initialize the GUI for one part * */ private void initGuiForAppPart(int screenId) { - ui.lineEdit_appId.setText((String) screens.get(screenId)); + ui.lineEdit.setText(((Part) screens.get(screenId)).getPartId()); currentScreen = screenId; - ui.lineEdit_appId.setReadOnly(true); // disable text input (display only) - ui.radioButton_all.setChecked(true); + ui.lineEdit.setReadOnly(true); // disable text input (display only) + if (screenId==0) ui.pushButton_previous.setDisabled(true); else ui.pushButton_previous.setDisabled(false); - onAllNodes(); + // set the previously selected value to the screen if exists + Part cPart = (Part) screens.get(currentScreen); + if (layout.containsKey(cPart)) { + String peerId = layout.get(cPart); + int cIndex=0; + for (int i=0; i<ui.comboBox.count(); i++) { + if (ui.comboBox.itemText(i).equals(peerId)) { + cIndex = i; + break; + } + } + ui.comboBox.setCurrentIndex(cIndex); + } + + + } + + private void cancel() { + MainWindow.getInstance().removeSubWindow(this); + } + + private void nextScreen() { + // save the current screen value + layout.put((Part) screens.get(currentScreen), ui.comboBox.currentText()); + //show the saved results + System.out.println("[DeployConfigView.nextScreen] save a selection: " + ((Part)(screens.get(currentScreen))).getPartId() + + "/" + ui.comboBox.currentText()); + // initialize the next screen if any + if (currentScreen==screens.size()-1) { + // already the last screen - start to call DeployManager! + String[] options = {"YES - continue to deploy", "NO - Go back"}; + String op = QInputDialog.getItem(this, "Deploy", "This is the last application part to configure. Start deploying?", Arrays.asList(options), 0, false); + if (options[0].equals(op)) { + // check the validity of the configuration layout + if (!checkLayout()) { + // the selection is not valid + QMessageBox.information(this, "Configure error", "The configuration is not valid. Please try again!"); + return; + } + MainWindow.getInstance().removeSubWindow(this); + System.out.println("Start deploying..."); + QMessageBox.information(this, "Deploy", "start deploying the multi-part application..."); + //save the deploy configuration + for(Part part : layout.keySet()){ + PeerCard card = peers.get(layout.get(part)); + System.out.println("[DeployConfigView.nextScreen] save the layouts: " + card.getPeerID() + + ":" + layout.get(part) + "/" + part.getPartId()); + mpaLayout.put(card, part); + } + // call MW deploy manager requestToInstall + Activator.getInstaller().requestToInstall((new File(deployPath)).toURI(), mpaLayout); + } + + return; + } + initGuiForAppPart(currentScreen+1); + + } + + private void previousScreen() { + if (currentScreen==0) { + // already the first screen + QMessageBox.information(this, "Info", "Already the first screen - can not go back!"); + return; + } + initGuiForAppPart(currentScreen-1); + } + + + private void peerSelected(String peerId) { + Part part = (Part) screens.get(currentScreen); + //PeerCard card = peers.get(peerId); + System.out.println("[DedployConfigView.peerSelected] the selected peer is: " + peerId + "/" + + peers.get(peerId).getPeerID() + " for part: " + part.getPartId()); + // TODO: do we need to check validity of the selection here? + // save to the layout: each part appears just once in the layout + layout.put(part, peerId); + } + + /** + * check the layout: + * - each Application part needs one peer to install + * - each peer is compatible with the part DeploymentUnit specification + * - each peer can only install one part + * @return + */ + private boolean checkLayout() { + boolean valid = true; + + if (layout.size()==0) { + System.out.println("[DeployConfigView.checkLayout] You have not selected any node to deploy!"); + QMessageBox.information(this, "Validity check", "You have not selected any node to deploy!"); + return false; + } + // check if the peer is compatible with the part DeploymentUnit + for(Part part: mpa.getApplicationPart().getPart()){ + if (!layout.containsKey(part)) { + System.out.println("[DeployConfigView.checkLayout] You have not selected a node to deploy part " + part.getPartId() + "!"); + QMessageBox.information(this, "Validity check", "[DeployConfigView.checkLayout] You have not selected a node to deploy part " + part.getPartId() + "!"); + valid = false; + } else + if (!DeployStrategyView.checkDeployementUnit(part.getDeploymentUnit(), peers.get(layout.get(part)))) { + QMessageBox.information(this, "Validity check", "The part " + part.getPartId() + " can not be installed on the peer " + layout.get(part) + "!"); + System.out.println("[DeployConfigView.checkLayout] The part " + part.getPartId() + " can not be installed on the peer " + layout.get(part) + "!"); + valid = false; + } + else System.out.println("[DeployConfigView.checkLayout] The part " + part.getPartId() + " can be installed on the peer " + layout.get(part)); + } + // check if a peer is associated with more than one part + for (String peerId: layout.values()) { + System.out.println("[DeployConfigView.checkLayout] check for peer " + peerId); + if (countPeer(peerId)>1) { + System.out.println("[DeployConfigView.checkLayout] " + peerId + " has been associated with more than one part!"); + QMessageBox.information(this, "Validity check", peerId + " has been associated with more than one part!"); + valid = false; + } + } + return valid; + } + + private int countPeer(String peerId) { + int count = 0; + for (Part part: layout.keySet()) { + if (layout.get(part).equals(peerId)) { + System.out.println("[DeployConfigView.countPeer] part "+ part.getPartId() + " is associated with " + peerId); + count++; + } + } + return count; } - - private void addNode() { - String nodeId = QInputDialog.getItem(this, "Add node", "Please select a node to add", Arrays.asList(deployNodes)); - // check the uniqueness of the node (i.e., if the nodeId already exists) - if (exists(nodeId)) { - QMessageBox.warning(this, "Error", "The node " + nodeId + " already added!"); - return; - } - addSelectedNode(nodeId); - } - - private void addSelectedNode(String nodeId) { - System.out.println("add a selected node: " + nodeId); - int row; - - if (listModel.rowCount()==0) row = 0; - else { - if (ui.listView.currentIndex()==null) - row = listModel.rowCount(); - else row = ui.listView.currentIndex().row(); - } - - listModel.insertRow(row); - - QModelIndex index = listModel.index(row, 0); - listModel.setData(index, nodeId); - System.out.println("The list view after insert - the number of items: " + listModel.rowCount()); - ui.listView.setCurrentIndex(index); - } - - private void removeNode() { - if (ui.listView.currentIndex()==null) { - QMessageBox.warning(this, "Error", "You should select one node to remove!"); - return; - } - int row = ui.listView.currentIndex().row(); - System.out.println("remove a node at row: " + row + " with id: " + listModel.data(row, 0)); - listModel.removeRow(row); - } - - private void onAllNodes() { - listModel.setStringList((List<String>) layout.get(screens.get(currentScreen))); - ui.listView.setModel(listModel); - ui.listView.show(); - } - - private void onSelectedNodes() { - List<String> list = new Vector<String>(); - listModel.setStringList(list); - ui.listView.setModel(listModel); - } - - private boolean exists(String nodeId) { - List data = listModel.stringList(); - Iterator itr = data.iterator(); - while(itr.hasNext()) { - String element = (String) itr.next(); - if (element.equals(nodeId)) { - return true; - } - } - - return false; - } - - private void cancel() { - MainWindow.getInstance().removeSubWindow(this); - } - - private void nextScreen() { - // save the current screen value first - layout.put(screens.get(currentScreen), listModel.stringList()); - //TODO: show the saved results - // initialize the next screen if any - if (currentScreen==screens.size()-1) { - // already the last screen - start to call DeployManager! - String[] options = {"YES - continue to deploy", "NO - Go back"}; - String op = QInputDialog.getItem(this, "Deploy", "This is the last application part to configure. Start deploying?", Arrays.asList(options), 0, false); - if (options[0].equals(op)) { - MainWindow.getInstance().removeSubWindow(this); - System.out.println("Start deploying..."); - QMessageBox.information(this, "Deploy", "start deploying the multi-part application..."); - //TODO write all the deploy configure setting to a configFile or use just the HashMap? - // saveDeployConfigToFile(); - //TODO call MW deploy manager requestToInstall(zip, configFile) or requestToInstall(zip, HashMap configs) - - } - - return; - } - initGuiForAppPart(currentScreen+1); - } - - private void previousScreen() { - if (currentScreen==0) { - // already the first screen - QMessageBox.information(this, "Info", "Already the first screen - can not go back!"); - return; - } - initGuiForAppPart(currentScreen-1); - } - - /** - * call DeployManager to check deploy layout and - * @param path - * @return - */ - private HashMap getDeployLayout(String path) { - HashMap layouts = new HashMap(); - // TODO: get the mpa file - - - // TO integrate with the MW use: - // layout = checkDeployLayout(mpaFile); - // create screens using the layout (the list of appId) - - // here only initialize data for test - String appId = "ApplicationPart1"; - String[] deployNode1 = {"node1", "node2", "node3", "node4"}; - layouts.put(appId, Arrays.asList(deployNode1)); - //screens.add(appId); - - appId = "ApplicationPart2"; - String[] deployNode2 = {"node1", "node2", "node3", "node4", "node5"}; - layouts.put(appId, Arrays.asList(deployNode2)); - //screens.add(appId); - - appId = "ApplicationPart3"; - String[] deployNode3 = {"node2", "node5", "node6"}; - layouts.put(appId, Arrays.asList(deployNode3)); - //screens.add(appId); - - return layouts; - } } diff --git a/ucc/ucc.viewjambi/src/main/java/org/universAAL/ucc/viewjambi/install/LicenseView.java b/ucc/ucc.viewjambi/src/main/java/org/universAAL/ucc/viewjambi/install/LicenseView.java index 6245317584736993ddce0790353f6b915433c40a..aa0c61d988d365b5b6ea82137f382641ae1c106c 100644 --- a/ucc/ucc.viewjambi/src/main/java/org/universAAL/ucc/viewjambi/install/LicenseView.java +++ b/ucc/ucc.viewjambi/src/main/java/org/universAAL/ucc/viewjambi/install/LicenseView.java @@ -34,7 +34,7 @@ public class LicenseView extends SubWindow { protected void accept() { MainWindow.getInstance().removeSubWindow(this); // check if this is MPA - if (mpa) MainWindow.getInstance().deployConfigure(appDir); + if (mpa) MainWindow.getInstance().deployStrategy(appDir); else MainWindow.getInstance().configureApp(appDir); } diff --git a/ucc/ucc.viewjambi/src/main/java/org/universAAL/ucc/viewjambi/juic/Ui_DeployConfigView.java b/ucc/ucc.viewjambi/src/main/java/org/universAAL/ucc/viewjambi/juic/Ui_DeployConfigView.java index d747496ebaed2bab9ace67a768d9b9770203d947..be1313bf1d3384113447940450585b6940fce714 100644 --- a/ucc/ucc.viewjambi/src/main/java/org/universAAL/ucc/viewjambi/juic/Ui_DeployConfigView.java +++ b/ucc/ucc.viewjambi/src/main/java/org/universAAL/ucc/viewjambi/juic/Ui_DeployConfigView.java @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading ui file 'DeployConfigView.jui' ** -** Created: to 31. mai 11:14:45 2012 +** Created: fr 3. aug 12:15:16 2012 ** by: Qt User Interface Compiler version 4.5.2 ** ** WARNING! All changes made in this file will be lost when recompiling ui file! @@ -14,161 +14,105 @@ import com.trolltech.qt.gui.*; public class Ui_DeployConfigView implements com.trolltech.qt.QUiForm<QWidget> { - public QVBoxLayout verticalLayout_4; + public QGridLayout gridLayout_2; public QGridLayout gridLayout; - public QVBoxLayout verticalLayout_3; - public QRadioButton radioButton_all; - public QRadioButton radioButton_selected; - public QVBoxLayout verticalLayout_2; - public QLabel label; - public QListView listView; - public QVBoxLayout verticalLayout; - public QSpacerItem verticalSpacer_4; - public QPushButton pushButton_add; - public QSpacerItem verticalSpacer; - public QPushButton pushButton_remove; - public QSpacerItem verticalSpacer_3; - public QHBoxLayout horizontalLayout; public QLabel label_2; - public QLineEdit lineEdit_appId; - public QSpacerItem horizontalSpacer; + public QLabel label; public QLabel label_3; - public QSplitter splitter; + public QSpacerItem horizontalSpacer; + public QLineEdit lineEdit; + public QComboBox comboBox; + public QHBoxLayout horizontalLayout; public QPushButton pushButton_previous; public QPushButton pushButton_next; public QPushButton pushButton_cancel; + public QSpacerItem verticalSpacer; + public QSpacerItem verticalSpacer_2; public Ui_DeployConfigView() { super(); } - public void setupUi(QWidget ListTest) + public void setupUi(QWidget DeployConfigView) { - ListTest.setObjectName("ListTest"); - ListTest.resize(new QSize(384, 422).expandedTo(ListTest.minimumSizeHint())); - verticalLayout_4 = new QVBoxLayout(ListTest); - verticalLayout_4.setObjectName("verticalLayout_4"); + DeployConfigView.setObjectName("DeployConfigView"); + DeployConfigView.resize(new QSize(340, 206).expandedTo(DeployConfigView.minimumSizeHint())); + gridLayout_2 = new QGridLayout(DeployConfigView); + gridLayout_2.setObjectName("gridLayout_2"); gridLayout = new QGridLayout(); gridLayout.setObjectName("gridLayout"); - verticalLayout_3 = new QVBoxLayout(); - verticalLayout_3.setObjectName("verticalLayout_3"); - radioButton_all = new QRadioButton(ListTest); - radioButton_all.setObjectName("radioButton_all"); - - verticalLayout_3.addWidget(radioButton_all); - - radioButton_selected = new QRadioButton(ListTest); - radioButton_selected.setObjectName("radioButton_selected"); - - verticalLayout_3.addWidget(radioButton_selected); - + label_2 = new QLabel(DeployConfigView); + label_2.setObjectName("label_2"); - gridLayout.addLayout(verticalLayout_3, 1, 1, 1, 2); + gridLayout.addWidget(label_2, 0, 0, 1, 2); - verticalLayout_2 = new QVBoxLayout(); - verticalLayout_2.setObjectName("verticalLayout_2"); - label = new QLabel(ListTest); + label = new QLabel(DeployConfigView); label.setObjectName("label"); - verticalLayout_2.addWidget(label); - - listView = new QListView(ListTest); - listView.setObjectName("listView"); - - verticalLayout_2.addWidget(listView); - - - gridLayout.addLayout(verticalLayout_2, 2, 0, 1, 2); + gridLayout.addWidget(label, 2, 0, 1, 1); - verticalLayout = new QVBoxLayout(); - verticalLayout.setObjectName("verticalLayout"); - verticalSpacer_4 = new QSpacerItem(20, 40, com.trolltech.qt.gui.QSizePolicy.Policy.Minimum, com.trolltech.qt.gui.QSizePolicy.Policy.Expanding); - - verticalLayout.addItem(verticalSpacer_4); - - pushButton_add = new QPushButton(ListTest); - pushButton_add.setObjectName("pushButton_add"); - - verticalLayout.addWidget(pushButton_add); - - verticalSpacer = new QSpacerItem(20, 40, com.trolltech.qt.gui.QSizePolicy.Policy.Minimum, com.trolltech.qt.gui.QSizePolicy.Policy.Expanding); + label_3 = new QLabel(DeployConfigView); + label_3.setObjectName("label_3"); - verticalLayout.addItem(verticalSpacer); + gridLayout.addWidget(label_3, 2, 1, 1, 1); - pushButton_remove = new QPushButton(ListTest); - pushButton_remove.setObjectName("pushButton_remove"); + horizontalSpacer = new QSpacerItem(40, 20, com.trolltech.qt.gui.QSizePolicy.Policy.Expanding, com.trolltech.qt.gui.QSizePolicy.Policy.Minimum); - verticalLayout.addWidget(pushButton_remove); + gridLayout.addItem(horizontalSpacer, 2, 2, 1, 1); - verticalSpacer_3 = new QSpacerItem(20, 40, com.trolltech.qt.gui.QSizePolicy.Policy.Minimum, com.trolltech.qt.gui.QSizePolicy.Policy.Expanding); + lineEdit = new QLineEdit(DeployConfigView); + lineEdit.setObjectName("lineEdit"); - verticalLayout.addItem(verticalSpacer_3); + gridLayout.addWidget(lineEdit, 3, 0, 1, 1); + comboBox = new QComboBox(DeployConfigView); + comboBox.setObjectName("comboBox"); - gridLayout.addLayout(verticalLayout, 2, 2, 1, 1); + gridLayout.addWidget(comboBox, 3, 1, 1, 2); horizontalLayout = new QHBoxLayout(); horizontalLayout.setObjectName("horizontalLayout"); - label_2 = new QLabel(ListTest); - label_2.setObjectName("label_2"); + pushButton_previous = new QPushButton(DeployConfigView); + pushButton_previous.setObjectName("pushButton_previous"); - horizontalLayout.addWidget(label_2); + horizontalLayout.addWidget(pushButton_previous); - lineEdit_appId = new QLineEdit(ListTest); - lineEdit_appId.setObjectName("lineEdit_appId"); + pushButton_next = new QPushButton(DeployConfigView); + pushButton_next.setObjectName("pushButton_next"); - horizontalLayout.addWidget(lineEdit_appId); + horizontalLayout.addWidget(pushButton_next); - horizontalSpacer = new QSpacerItem(40, 20, com.trolltech.qt.gui.QSizePolicy.Policy.Expanding, com.trolltech.qt.gui.QSizePolicy.Policy.Minimum); + pushButton_cancel = new QPushButton(DeployConfigView); + pushButton_cancel.setObjectName("pushButton_cancel"); - horizontalLayout.addItem(horizontalSpacer); + horizontalLayout.addWidget(pushButton_cancel); - gridLayout.addLayout(horizontalLayout, 0, 0, 1, 3); + gridLayout.addLayout(horizontalLayout, 5, 0, 1, 3); - label_3 = new QLabel(ListTest); - label_3.setObjectName("label_3"); + verticalSpacer = new QSpacerItem(20, 40, com.trolltech.qt.gui.QSizePolicy.Policy.Minimum, com.trolltech.qt.gui.QSizePolicy.Policy.Expanding); - gridLayout.addWidget(label_3, 1, 0, 1, 1); + gridLayout.addItem(verticalSpacer, 4, 0, 1, 1); + verticalSpacer_2 = new QSpacerItem(20, 40, com.trolltech.qt.gui.QSizePolicy.Policy.Minimum, com.trolltech.qt.gui.QSizePolicy.Policy.Expanding); - verticalLayout_4.addLayout(gridLayout); + gridLayout.addItem(verticalSpacer_2, 1, 1, 1, 1); - splitter = new QSplitter(ListTest); - splitter.setObjectName("splitter"); - splitter.setOrientation(com.trolltech.qt.core.Qt.Orientation.Horizontal); - pushButton_previous = new QPushButton(splitter); - pushButton_previous.setObjectName("pushButton_previous"); - splitter.addWidget(pushButton_previous); - pushButton_next = new QPushButton(splitter); - pushButton_next.setObjectName("pushButton_next"); - splitter.addWidget(pushButton_next); - pushButton_cancel = new QPushButton(splitter); - pushButton_cancel.setObjectName("pushButton_cancel"); - splitter.addWidget(pushButton_cancel); - verticalLayout_4.addWidget(splitter); + gridLayout_2.addLayout(gridLayout, 0, 0, 1, 1); - retranslateUi(ListTest); + retranslateUi(DeployConfigView); - ListTest.connectSlotsByName(); + DeployConfigView.connectSlotsByName(); } // setupUi - void retranslateUi(QWidget ListTest) + void retranslateUi(QWidget DeployConfigView) { - ListTest.setWindowTitle(com.trolltech.qt.core.QCoreApplication.translate("ListTest", "Deploy Configure", null)); - radioButton_all.setText(com.trolltech.qt.core.QCoreApplication.translate("ListTest", "On all deployable nodes (default)", null)); - radioButton_selected.setText(com.trolltech.qt.core.QCoreApplication.translate("ListTest", "On selected nodes", null)); - label.setText(com.trolltech.qt.core.QCoreApplication.translate("ListTest", "Nodes to deploy", null)); - pushButton_add.setText(com.trolltech.qt.core.QCoreApplication.translate("ListTest", "Add", null)); - pushButton_remove.setText(com.trolltech.qt.core.QCoreApplication.translate("ListTest", "Remove", null)); - label_2.setText(com.trolltech.qt.core.QCoreApplication.translate("ListTest", "Application Part", null)); - label_3.setText(com.trolltech.qt.core.QCoreApplication.translate("ListTest", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"+ -"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"+ -"p, li { white-space: pre-wrap; }\n"+ -"</style></head><body style=\" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"+ -"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">Deploy strategy</span></p></body></html>", null)); - pushButton_previous.setText(com.trolltech.qt.core.QCoreApplication.translate("ListTest", "previous", null)); - pushButton_next.setText(com.trolltech.qt.core.QCoreApplication.translate("ListTest", "next", null)); - pushButton_cancel.setText(com.trolltech.qt.core.QCoreApplication.translate("ListTest", "cancel", null)); + DeployConfigView.setWindowTitle(com.trolltech.qt.core.QCoreApplication.translate("DeployConfigView", "Deploy configure", null)); + label_2.setText(com.trolltech.qt.core.QCoreApplication.translate("DeployConfigView", "Please select a node to deploy an application part:", null)); + label.setText(com.trolltech.qt.core.QCoreApplication.translate("DeployConfigView", "Application Part", null)); + label_3.setText(com.trolltech.qt.core.QCoreApplication.translate("DeployConfigView", "Node to deploy", null)); + pushButton_previous.setText(com.trolltech.qt.core.QCoreApplication.translate("DeployConfigView", "previous", null)); + pushButton_next.setText(com.trolltech.qt.core.QCoreApplication.translate("DeployConfigView", "next", null)); + pushButton_cancel.setText(com.trolltech.qt.core.QCoreApplication.translate("DeployConfigView", "cancel", null)); } // retranslateUi } diff --git a/ucc/ucc.viewjambi/src/main/resources/forms/org/universAAL/ucc/viewjambi/juic/DeployConfigView.jui b/ucc/ucc.viewjambi/src/main/resources/forms/org/universAAL/ucc/viewjambi/juic/DeployConfigView.jui index be244faa3c8d27c131daf71598a3dc23ced75b6a..1ea1f92e50675b0f43acfa88fa9e15a7a58a23ae 100644 --- a/ucc/ucc.viewjambi/src/main/resources/forms/org/universAAL/ucc/viewjambi/juic/DeployConfigView.jui +++ b/ucc/ucc.viewjambi/src/main/resources/forms/org/universAAL/ucc/viewjambi/juic/DeployConfigView.jui @@ -1,172 +1,114 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0" language="jambi"> - <class>ListTest</class> - <widget class="QWidget" name="ListTest"> + <class>DeployConfigView</class> + <widget class="QWidget" name="DeployConfigView"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>384</width> - <height>422</height> + <width>340</width> + <height>206</height> </rect> </property> <property name="windowTitle"> - <string>Deploy Configure</string> + <string>Deploy configure</string> </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <item> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> <layout class="QGridLayout" name="gridLayout"> - <item row="1" column="1" colspan="2"> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QRadioButton" name="radioButton_all"> - <property name="text"> - <string>On all deployable nodes (default)</string> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="radioButton_selected"> - <property name="text"> - <string>On selected nodes</string> - </property> - </widget> - </item> - </layout> + <item row="0" column="0" colspan="2"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Please select a node to deploy an application part:</string> + </property> + </widget> </item> - <item row="2" column="0" colspan="2"> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Nodes to deploy</string> - </property> - </widget> - </item> - <item> - <widget class="QListView" name="listView"/> - </item> - </layout> + <item row="2" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Application Part</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Node to deploy</string> + </property> + </widget> </item> <item row="2" column="2"> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <spacer name="verticalSpacer_4"> - <property name="orientation"> - <enum>com.trolltech.qt.core.Qt.Orientation.Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>com.trolltech.qt.core.Qt.Orientation.Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="3" column="0"> + <widget class="QLineEdit" name="lineEdit"/> + </item> + <item row="3" column="1" colspan="2"> + <widget class="QComboBox" name="comboBox"/> + </item> + <item row="5" column="0" colspan="3"> + <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <widget class="QPushButton" name="pushButton_add"> + <widget class="QPushButton" name="pushButton_previous"> <property name="text"> - <string>Add</string> + <string>previous</string> </property> </widget> </item> <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>com.trolltech.qt.core.Qt.Orientation.Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pushButton_remove"> + <widget class="QPushButton" name="pushButton_next"> <property name="text"> - <string>Remove</string> + <string>next</string> </property> </widget> </item> <item> - <spacer name="verticalSpacer_3"> - <property name="orientation"> - <enum>com.trolltech.qt.core.Qt.Orientation.Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="0" column="0" colspan="3"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="label_2"> + <widget class="QPushButton" name="pushButton_cancel"> <property name="text"> - <string>Application Part</string> + <string>cancel</string> </property> </widget> </item> - <item> - <widget class="QLineEdit" name="lineEdit_appId"/> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>com.trolltech.qt.core.Qt.Orientation.Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> </layout> </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Deploy strategy</span></p></body></html></string> + <item row="4" column="0"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>com.trolltech.qt.core.Qt.Orientation.Vertical</enum> </property> - </widget> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="1"> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>com.trolltech.qt.core.Qt.Orientation.Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> </item> </layout> </item> - <item> - <widget class="QSplitter" name="splitter"> - <property name="orientation"> - <enum>com.trolltech.qt.core.Qt.Orientation.Horizontal</enum> - </property> - <widget class="QPushButton" name="pushButton_previous"> - <property name="text"> - <string>previous</string> - </property> - </widget> - <widget class="QPushButton" name="pushButton_next"> - <property name="text"> - <string>next</string> - </property> - </widget> - <widget class="QPushButton" name="pushButton_cancel"> - <property name="text"> - <string>cancel</string> - </property> - </widget> - </widget> - </item> </layout> </widget> <resources/>