exploited the new common library

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/resource-sweeper@65429 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2012-12-28 19:56:47 +00:00
parent c819019e3e
commit e5240a5eba
7 changed files with 4 additions and 1090 deletions

View File

@ -9,7 +9,7 @@
<!-- <set-property name="user.agent" value="gecko1_8" /> -->
<!-- <inherits name='org.gcube.resourcemanagement.support.Resource_support' /> -->
<inherits name='org.gcube.resourcemanagement.support.Resource_support' />
<!-- Specify the app entry point class. -->
<entry-point
class='org.gcube.portlets.admin.resourcesweeper.client.Resource_sweeper' />

View File

@ -23,9 +23,9 @@ import org.gcube.portlets.admin.resourcesweeper.client.async.SweeperService;
import org.gcube.portlets.admin.resourcesweeper.client.async.SweeperServiceAsync;
import org.gcube.portlets.admin.resourcesweeper.client.clientlogs.ConsoleMessageBroker;
import org.gcube.portlets.admin.resourcesweeper.client.grids.ResourceGridFactory;
import org.gcube.portlets.admin.resourcesweeper.client.model.ResourceTypeDecorator;
import org.gcube.portlets.admin.resourcesweeper.shared.AtomicTreeNode;
import org.gcube.portlets.admin.resourcesweeper.shared.SweeperActions;
import org.gcube.resourcemanagement.support.client.views.ResourceTypeDecorator;
import org.gcube.resourcemanagement.support.shared.types.datamodel.AtomicTreeNode;
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.Style.SelectionMode;

View File

@ -20,7 +20,7 @@ import java.util.List;
import org.gcube.portlets.admin.resourcesweeper.client.Commands;
import org.gcube.portlets.admin.resourcesweeper.client.clientlogs.ConsoleMessageBroker;
import org.gcube.portlets.admin.resourcesweeper.client.model.ResourceDetailModel;
import org.gcube.resourcemanagement.support.shared.types.datamodel.ResourceDetailModel;
import com.extjs.gxt.ui.client.Style.SortDir;
import com.extjs.gxt.ui.client.data.BaseListLoader;

View File

@ -1,822 +0,0 @@
/****************************************************************************
* This software is part of the gCube Project.
* Site: http://www.gcube-system.org/
****************************************************************************
* The gCube/gCore software is licensed as Free Open Source software
* conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
* The software and documentation is provided by its authors/distributors
* "as is" and no expressed or
* implied warranty is given for its use, quality or fitness for a
* particular case.
****************************************************************************
* Filename: ResourceDetailDecorator.java
****************************************************************************
* @author <a href="mailto:daniele.strollo@isti.cnr.it">Daniele Strollo</a>
***************************************************************************/
package org.gcube.portlets.admin.resourcesweeper.client.model;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.NumberFormat;
/**
* @author Massimiliano Assante (ISTI-CNR)
* @author Daniele Strollo
*/
public class ResourceDetailModel {
private static boolean initialized = false;
public static final String SERVICE_INSTALL_KEY = "toDeploy";
private static HashMap<String, ColumnModel> RECORD_DEFINITION = null;
private static HashMap<String, ModelType> XML_MAPPING = null;
private static HashMap<String, String[]> REQUIRED_FIELDS = null;
private static void init() {
if (initialized) {
return;
}
initialized = true;
RECORD_DEFINITION = new HashMap<String, ColumnModel>();
XML_MAPPING = new HashMap<String, ModelType>();
/*********************************************
* GHN
********************************************/
// The column model for grid representation
List<ColumnConfig> modelColumns = new ArrayList<ColumnConfig>();
modelColumns.add(new ColumnConfig("Name", "Name", 250));
ColumnConfig status = new ColumnConfig("Status", "Status", 65);
GridCellRenderer<BaseModelData> statusRender = new GridCellRenderer<BaseModelData>() {
@Override
public String render(BaseModelData model, String property, ColumnData config,
int rowIndex, int colIndex, ListStore<BaseModelData> store, Grid<BaseModelData> grid) {
String statusToCheck = (String)model.get(property);
String style = "gray";
if (statusToCheck.compareTo("certified") == 0)
style = "green";
else if (statusToCheck.compareTo("ready") == 0)
style = "orange";
return "<span style='color:" + style + "'>" + statusToCheck + "</span>";
}
};
status.setRenderer(statusRender);
modelColumns.add(status);
modelColumns.add(new ColumnConfig("LastUpdate", "Last Updated", 130));
modelColumns.add(new ColumnConfig("gCoreVersion", "gCore v.", 50));
modelColumns.add(new ColumnConfig("ghnVersion", "ghn v.", 40));
ColumnConfig ramLeft = new ColumnConfig("VirtualAvailable", "V. Mem left", 70);
ramLeft.setAlignment(HorizontalAlignment.RIGHT);
ramLeft.setEditor(new CellEditor(new NumberField()));
final NumberFormat number = NumberFormat.getFormat("#,##0;(#,##0)");
GridCellRenderer<BaseModelData> ramRender = new GridCellRenderer<BaseModelData>() {
@Override
public String render(BaseModelData model, String property, ColumnData config,
int rowIndex, int colIndex, ListStore<BaseModelData> store, Grid<BaseModelData> grid) {
int val = Integer.parseInt((String)model.get(property));
int tot = Integer.parseInt((String) model.get("VirtualSize"));
int percentage = (val * 100) / tot;
String style = val < 100 ? "red" : "green";
String toDisplay = number.format(val).replaceAll(",", ".");
toDisplay += " MB";
return "<span style='color:" + style + "'>" + percentage + "% ("+toDisplay+")</span>";
}
};
ramLeft.setRenderer(ramRender);
modelColumns.add(ramLeft);
ColumnConfig localSpace = new ColumnConfig("LocalAvailableSpace", "HD Space left", 70);
localSpace.setAlignment(HorizontalAlignment.RIGHT);
localSpace.setEditor(new CellEditor(new NumberField()));
GridCellRenderer<BaseModelData> mbRender = new GridCellRenderer<BaseModelData>() {
@Override
public String render(BaseModelData model, String property, ColumnData config,
int rowIndex, int colIndex, ListStore<BaseModelData> store, Grid<BaseModelData> grid) {
int val = Integer.parseInt((String)model.get(property));
String style = val < 1000000 ? "red" : "green";
String toDisplay = number.format(val);
if (toDisplay.length() > 4)
toDisplay = toDisplay.substring(0, toDisplay.length()-4).replaceAll(",", ".");
toDisplay += " MB";
return "<span style='color:" + style + "'>" + toDisplay + "</span>";
}
};
localSpace.setRenderer(mbRender);
modelColumns.add(localSpace);
//Optional
ColumnConfig ramTotal = new ColumnConfig("VirtualSize", "V. Memory total", 70);
ramTotal.setAlignment(HorizontalAlignment.RIGHT);
ramTotal.setEditor(new CellEditor(new NumberField()));
GridCellRenderer<BaseModelData> ramTotRender = new GridCellRenderer<BaseModelData>() {
@Override
public String render(BaseModelData model, String property, ColumnData config,
int rowIndex, int colIndex, ListStore<BaseModelData> store, Grid<BaseModelData> grid) {
int val = Integer.parseInt((String)model.get(property));
String toDisplay = number.format(val).replaceAll(",", ".");
toDisplay += " MB";
return toDisplay;
}
};
ramTotal.setRenderer(ramTotRender);
modelColumns.add(ramTotal);
modelColumns.add(new ColumnConfig("ID", "ID", 220));
modelColumns.add(new ColumnConfig("Uptime", "Up Time", 100));
modelColumns.add(new ColumnConfig("LoadLast15Min", "Load Last 15 Min", 100));
modelColumns.add(new ColumnConfig("LoadLast1Min", "Load Last 1 Min", 100));
modelColumns.add(new ColumnConfig("LoadLast5Min", "Load Last 5 Min", 100));
modelColumns.add(new ColumnConfig("Scopes", "Scopes", 300));
modelColumns.add(new ColumnConfig("SubType", "SubType", 200));
// create the column model
ColumnModel cm = new ColumnModel(modelColumns);
// The hidden fields after the 5 column
for (int i = 7; i < modelColumns.size(); i++) {
cm.setHidden(i, true);
}
RECORD_DEFINITION.put(ResourceTypeDecorator.GHN.name(), cm);
// defines the xml structure
ModelType type = new ModelType();
type.setRoot("Resources");
type.setRecordName("Resource");
type.addField("ID");
type.addField("Status");
type.addField("Name");
type.addField("Uptime");
type.addField("LastUpdate");
type.addField("VirtualAvailable");
type.addField("VirtualSize");
type.addField("gCoreVersion", "gcf-version");
type.addField("ghnVersion", "ghn-version");
type.addField("LocalAvailableSpace");
type.addField("LoadLast15Min");
type.addField("LoadLast1Min");
type.addField("LoadLast5Min");
type.addField("Scopes");
// These fields are internally used and not showable
type.addField("SubType");
type.addField("Type");
XML_MAPPING.put(ResourceTypeDecorator.GHN.name(), type);
/*********************************************
* Collection
********************************************/
// The column model for grid representation
modelColumns = new ArrayList<ColumnConfig>();
modelColumns.add(new ColumnConfig("Name", "Name", 470));
modelColumns.add(new ColumnConfig("NumberOfMembers", "Cardinality", 70));
modelColumns.add(new ColumnConfig("LastUpdateTime", "Last Updated", 170));
modelColumns.add(new ColumnConfig("ID", "ID", 220));
//Optional
modelColumns.add(new ColumnConfig("CreationTime", "Creation Time", 170));
modelColumns.add(new ColumnConfig("Scopes", "Scopes", 300));
modelColumns.add(new ColumnConfig("SubType", "SubType", 200));
//modelColumns.add(new ColumnConfig("NumberOfMembers", "Number Of Members", 115)); //not available anymore
// create the column model
cm = new ColumnModel(modelColumns);
for (int i = 4; i < modelColumns.size(); i++) {
cm.setHidden(i, true);
}
RECORD_DEFINITION.put(ResourceTypeDecorator.Collection.name(), cm);
// defines the xml structure
type = new ModelType();
type.setRoot("Resources");
type.setRecordName("Resource");
type.addField("ID");
type.addField("Name");
type.addField("CreationTime");
type.addField("LastUpdateTime");
type.addField("NumberOfMembers");
type.addField("Scopes");
type.addField("SubType");
type.addField("Type");
XML_MAPPING.put(ResourceTypeDecorator.Collection.name(), type);
/*********************************************
* Service
********************************************/
// The column model for grid representation
modelColumns = new ArrayList<ColumnConfig>();
modelColumns.add(new ColumnConfig("ServiceClass", "Service Class", 200));
modelColumns.add(new ColumnConfig("ServiceName", "Service Name", 260));
modelColumns.add(new ColumnConfig("Version", "Main Package Version", 100));
//Optional
modelColumns.add(new ColumnConfig("Shareable", "Shareable", 100));
modelColumns.add(new ColumnConfig("Scopes", "Scopes", 300));
modelColumns.add(new ColumnConfig("ID", "ID", 220));
modelColumns.add(new ColumnConfig("SubType", "SubType", 200));
// create the column model
cm = new ColumnModel(modelColumns);
for (int i = 3; i < modelColumns.size(); i++) {
cm.setHidden(i, true);
}
RECORD_DEFINITION.put(ResourceTypeDecorator.Service.name(), cm);
// defines the xml structure
type = new ModelType();
type.setRoot("Resources");
type.setRecordName("Resource");
type.addField("ID");
type.addField("ServiceClass");
type.addField("ServiceName");
type.addField("Version");
type.addField("Shareable");
type.addField("Scopes");
// These fields are internally used and not showable
type.addField("SubType");
type.addField("Type");
XML_MAPPING.put(ResourceTypeDecorator.Service.name(), type);
/*********************************************
* InstallableSoftware
********************************************/
// The column model for grid representation
modelColumns = new ArrayList<ColumnConfig>();
// adds the checkbox to the model
CheckColumnConfig checkColumn =
new CheckColumnConfig(ResourceDetailModel.SERVICE_INSTALL_KEY, "Deploy", 60);
CellEditor checkBoxEditor = new CellEditor(new CheckBox());
checkColumn.setEditor(checkBoxEditor);
modelColumns.add(checkColumn);
modelColumns.add(new ColumnConfig("ServiceClass", "Service Class", 250));
modelColumns.add(new ColumnConfig("ServiceName", "Service Name", 250));
modelColumns.add(new ColumnConfig("Version", "Main Package Version", 100));
//Optional
modelColumns.add(new ColumnConfig("Scopes", "Scopes", 300));
modelColumns.add(new ColumnConfig("ID", "ID", 220));
modelColumns.add(new ColumnConfig("SubType", "SubType", 200));
// create the column model
cm = new ColumnModel(modelColumns);
for (int i = 3; i < modelColumns.size(); i++) {
cm.setHidden(i, true);
}
RECORD_DEFINITION.put(ResourceTypeDecorator.InstallableSoftware.name(), cm);
// defines the xml structure
type = new ModelType();
type.setRoot("Resources");
type.setRecordName("Resource");
type.addField("ID");
type.addField("ServiceClass");
type.addField("ServiceName");
type.addField("Version");
type.addField("Scopes");
// These fields are internally used and not showable
type.addField("SubType");
type.addField("Type");
XML_MAPPING.put(ResourceTypeDecorator.InstallableSoftware.name(), type);
/*********************************************
* RunningInstance
********************************************/
// The column model for grid representation
modelColumns = new ArrayList<ColumnConfig>();
modelColumns.add(new ColumnConfig("ServiceClass", "Service Class", 200));
modelColumns.add(new ColumnConfig("ServiceName", "Service Name", 260));
modelColumns.add(new ColumnConfig("Version", "Version", 100));
modelColumns.add(new ColumnConfig("Status", "Status", 65));
modelColumns.add(new ColumnConfig("GHN", "GHN", 300));
//Optional
modelColumns.add(new ColumnConfig("Scopes", "Scopes", 300));
modelColumns.add(new ColumnConfig("ID", "ID", 220));
modelColumns.add(new ColumnConfig("SubType", "SubType", 200));
// create the column model
cm = new ColumnModel(modelColumns);
for (int i = 5; i < modelColumns.size(); i++) {
cm.setHidden(i, true);
}
RECORD_DEFINITION.put(ResourceTypeDecorator.RunningInstance.name(), cm);
// defines the xml structure
type = new ModelType();
type.setRoot("Resources");
type.setRecordName("Resource");
type.addField("ID");
type.addField("ServiceClass");
type.addField("ServiceName");
type.addField("Version");
type.addField("Status");
// a) This is the GHNID type.addField("GHN", "/Profile/GHN/@UniqueID");
// b) While this is its name
type.addField("GHN", "ghn-name");
type.addField("Scopes");
// These fields are internally used and not showable
type.addField("SubType");
type.addField("Type");
XML_MAPPING.put(ResourceTypeDecorator.RunningInstance.name(), type);
/*********************************************
* VIEW
********************************************/
// The column model for grid representation
modelColumns = new ArrayList<ColumnConfig>();
modelColumns.add(new ColumnConfig("ViewName", "View Name", 200));
modelColumns.add(new ColumnConfig("SourceKey", "Source Key", 200));
modelColumns.add(new ColumnConfig("LastUpdate", "Last Update", 270));
modelColumns.add(new ColumnConfig("Cardinality", "Cardinality", 100));
//Optional
modelColumns.add(new ColumnConfig("ViewType", "View Type", 170));
modelColumns.add(new ColumnConfig("RelatedCollectionId", "Related Collection Id", 220));
modelColumns.add(new ColumnConfig("ServiceName", "Service Name", 170));
modelColumns.add(new ColumnConfig("Termination", "Termination Time", 270));
modelColumns.add(new ColumnConfig("Source", "Source", 230));
modelColumns.add(new ColumnConfig("ServiceClass", "Service Class", 170));
modelColumns.add(new ColumnConfig("Scopes", "Scopes", 300));
modelColumns.add(new ColumnConfig("RI", "RI", 220));
modelColumns.add(new ColumnConfig("SubType", "SubType", 200));
// create the column model
cm = new ColumnModel(modelColumns);
for (int i = 4; i < modelColumns.size(); i++) {
cm.setHidden(i, true);
}
RECORD_DEFINITION.put(ResourceTypeDecorator.VIEW.name(), cm);
// defines the xml structure
type = new ModelType();
type.setRoot("Resources");
type.setRecordName("Resource");
type.addField("ID");
type.addField("ViewName");
type.addField("Cardinality");
type.addField("ViewType");
type.addField("RelatedCollectionId");
type.addField("Source");
type.addField("SourceKey");
type.addField("ServiceClass");
type.addField("ServiceName");
type.addField("Termination", "TerminationTimeHuman");
type.addField("LastUpdate", "LastUpdateHuman");
type.addField("Scopes", "/scopes");
type.addField("SubType", "SubType");
type.addField("RI");
type.addField("Type");
GWT.log("VIew Name: " + ResourceTypeDecorator.VIEW.name());
XML_MAPPING.put(ResourceTypeDecorator.VIEW.name(), type);
/*********************************************
* GenericResource
********************************************/
// The column model for grid representation
modelColumns = new ArrayList<ColumnConfig>();
modelColumns.add(new ColumnConfig("Name", "Name", 500));
modelColumns.add(new ColumnConfig("Scopes", "Scopes", 300));
//Optional
modelColumns.add(new ColumnConfig("ID", "ID", 220));
modelColumns.add(new ColumnConfig("SubType", "Secondary Type", 170));
modelColumns.add(new ColumnConfig("SubType", "SubType", 200));
// create the column model
cm = new ColumnModel(modelColumns);
for (int i = 2; i < modelColumns.size(); i++) {
cm.setHidden(i, true);
}
RECORD_DEFINITION.put(ResourceTypeDecorator.GenericResource.name(), cm);
// defines the xml structure
type = new ModelType();
type.setRoot("Resources");
type.setRecordName("Resource");
type.addField("ID");
type.addField("Name");
type.addField("Scopes");
type.addField("SubType");
type.addField("Type");
XML_MAPPING.put(ResourceTypeDecorator.GenericResource.name(), type);
/*********************************************
* RuntimeResource
********************************************/
// The column model for grid representation
modelColumns = new ArrayList<ColumnConfig>();
modelColumns.add(new ColumnConfig("Name", "Name", 300));
modelColumns.add(new ColumnConfig("Scopes", "Scopes", 300));
//Optional
modelColumns.add(new ColumnConfig("ID", "ID", 220));
modelColumns.add(new ColumnConfig("SubType", "Category", 370));
// create the column model
cm = new ColumnModel(modelColumns);
for (int i = 3; i < modelColumns.size(); i++) {
cm.setHidden(i, true);
}
RECORD_DEFINITION.put(ResourceTypeDecorator.RuntimeResource.name(), cm);
// defines the xml structure
type = new ModelType();
type.setRoot("Resources");
type.setRecordName("Resource");
type.addField("ID");
type.addField("Name");
type.addField("Scopes");
type.addField("SubType");
type.addField("Type");
XML_MAPPING.put(ResourceTypeDecorator.RuntimeResource.name(), type);
/*********************************************
* WSResources
********************************************/
// The column model for grid representation
modelColumns = new ArrayList<ColumnConfig>();
modelColumns.add(new ColumnConfig("SourceKey", "Source Key", 230));
modelColumns.add(new ColumnConfig("ServiceName", "Service Name", 170));
modelColumns.add(new ColumnConfig("Termination", "Termination Time", 270));
modelColumns.add(new ColumnConfig("LastUpdate", "Last Update", 270));
//Optional
modelColumns.add(new ColumnConfig("ID", "ID", 220));
modelColumns.add(new ColumnConfig("Source", "Source", 230));
modelColumns.add(new ColumnConfig("ServiceClass", "Service Class", 170));
modelColumns.add(new ColumnConfig("Scopes", "Scopes", 300));
modelColumns.add(new ColumnConfig("RI", "RI", 220));
modelColumns.add(new ColumnConfig("SubType", "SubType", 200));
// create the column model
cm = new ColumnModel(modelColumns);
for (int i = 4; i < modelColumns.size(); i++) {
cm.setHidden(i, true);
}
RECORD_DEFINITION.put(ResourceTypeDecorator.WSResource.name(), cm);
// defines the xml structure
type = new ModelType();
type.setRoot("Resources");
type.setRecordName(ResourceTypeDecorator.WSResource.name());
type.addField("ID");
type.addField("Source");
type.addField("SourceKey");
type.addField("ServiceClass");
type.addField("ServiceName");
type.addField("Termination", "TerminationTimeHuman");
type.addField("LastUpdate", "LastUpdateHuman");
type.addField("Scopes", "/scopes");
type.addField("SubType", "SubType");
type.addField("RI");
type.addField("Type");
XML_MAPPING.put(ResourceTypeDecorator.WSResource.name(), type);
/*********************************************
* PROFILES OF RELATED RESOURCES: GHN
********************************************/
// The column model for grid representation
modelColumns = new ArrayList<ColumnConfig>();
modelColumns.add(new ColumnConfig("ServiceClass", "Service Class", 200));
modelColumns.add(new ColumnConfig("ServiceName", "Service Name", 260));
modelColumns.add(new ColumnConfig("ServiceVersion", "Service Version", 100));
modelColumns.add(new ColumnConfig("MainVersion", "Main Version", 100));
modelColumns.add(new ColumnConfig("Status", "Status", 65));
//Optional
modelColumns.add(new ColumnConfig("ID", "ID", 220));
// create the column model
cm = new ColumnModel(modelColumns);
for (int i = 5; i < modelColumns.size(); i++) {
cm.setHidden(i, true);
}
RECORD_DEFINITION.put(ResourceTypeDecorator.GHNRelated.name(), cm);
// defines the xml structure
type = new ModelType();
type.setRoot("Resources");
type.setRecordName("Resource");
type.addField("ID");
type.addField("ServiceClass");
type.addField("ServiceName");
type.addField("ServiceVersion");
type.addField("MainVersion");
type.addField("Status");
XML_MAPPING.put(ResourceTypeDecorator.GHNRelated.name(), type);
/*********************************************
* PROFILES OF RELATED RESOURCES: RunningInstance
********************************************/
// The column model for grid representation
modelColumns = new ArrayList<ColumnConfig>();
modelColumns.add(new ColumnConfig("Key", "Name", 200));
modelColumns.add(new ColumnConfig("Value", "Value", 260));
// create the column model
cm = new ColumnModel(modelColumns);
RECORD_DEFINITION.put(ResourceTypeDecorator.RunningInstanceRelated.name(), cm);
// defines the xml structure
type = new ModelType();
type.setRoot("Resources");
type.setRecordName("Resource");
type.addField("Key");
type.addField("Value");
XML_MAPPING.put(ResourceTypeDecorator.RunningInstanceRelated.name(), type);
/*********************************************
* PROFILES OF RELATED RESOURCES: Service
********************************************/
// The column model for grid representation
modelColumns = new ArrayList<ColumnConfig>();
modelColumns.add(new ColumnConfig("RIID", "RI ID", 90));
modelColumns.add(new ColumnConfig("ServiceStatus", "RI Status", 70));
modelColumns.add(new ColumnConfig("RIVersion", "Serv.Version", 70));
modelColumns.add(new ColumnConfig("ActivationTime", "RI ActivationTime", 170));
modelColumns.add(new ColumnConfig("GHNName", "GHN Name", 100));
modelColumns.add(new ColumnConfig("GHNStatus", "GHN Status", 70));
modelColumns.add(new ColumnConfig("GHNID", "GHN ID", 100));
modelColumns.add(new ColumnConfig("GHNSite", "GHN Site", 100));
modelColumns.add(new ColumnConfig("GHNLoad15Min", "GHNLoad15Min", 50));
modelColumns.add(new ColumnConfig("GHNLoad5Min", "GHNLoad5Min", 50));
modelColumns.add(new ColumnConfig("GHNLoad1Min", "GHNLoad1Min", 50));
modelColumns.add(new ColumnConfig("GHNActivationTime", "GHNActivationTime", 100));
modelColumns.add(new ColumnConfig("GHNLastUpdate", "GHNLastUpdate", 100));
// create the column model
cm = new ColumnModel(modelColumns);
for (int i = 6; i < modelColumns.size(); i++) {
cm.setHidden(i, true);
}
RECORD_DEFINITION.put(ResourceTypeDecorator.ServiceRelated.name(), cm);
// defines the xml structure
type = new ModelType();
type.setRoot("Resources");
type.setRecordName("Resource");
type.addField("RIID");
type.addField("ServiceStatus");
type.addField("ActivationTime");
type.addField("GHNID");
type.addField("RIVersion");
type.addField("GHNName");
type.addField("GHNSite");
type.addField("GHNStatus");
type.addField("GHNLoad15Min");
type.addField("GHNLoad5Min");
type.addField("GHNLoad1Min");
type.addField("GHNActivationTime");
type.addField("GHNLastUpdate");
XML_MAPPING.put(ResourceTypeDecorator.ServiceRelated.name(), type);
/*********************************************
* MODEL FOR SWEEPER GHN
********************************************/
// The column model for grid representation
modelColumns = new ArrayList<ColumnConfig>();
modelColumns.add(new ColumnConfig("Name", "Name", 130));
modelColumns.add(new ColumnConfig("Status", "Status", 50));
ColumnConfig minElapsed = (new ColumnConfig("UpdateMinutesElapsed", "Minutes from Update", 130));
minElapsed.setAlignment(HorizontalAlignment.CENTER);
modelColumns.add(minElapsed);
modelColumns.add(new ColumnConfig("AllocatedRI", "#RI", 40));
modelColumns.add(new ColumnConfig("LastUpdate", "LastUpdate", 130));
// hidden fields
modelColumns.add(new ColumnConfig("Actions", "Actions", 260));
modelColumns.add(new ColumnConfig("ID", "ID", 200));
modelColumns.add(new ColumnConfig("Type", "Type", 100));
modelColumns.add(new ColumnConfig("Location", "Location", 100));
modelColumns.add(new ColumnConfig("Domain", "Domain", 100));
modelColumns.add(new ColumnConfig("IPAddress", "IPAddress", 100));
modelColumns.add(new ColumnConfig("Scopes", "Scopes", 100));
// create the column model
cm = new ColumnModel(modelColumns);
for (int i = 5; i < modelColumns.size(); i++) {
cm.setHidden(i, true);
}
RECORD_DEFINITION.put(ResourceTypeDecorator.Sweeper_GHN.name(), cm);
// defines the xml structure
type = new ModelType();
type.setRoot("Resources");
type.setRecordName("Resource");
type.addField("ID");
type.addField("Name");
type.addField("Actions");
type.addField("Status");
type.addField("AllocatedRI");
type.addField("Type");
type.addField("Location");
type.addField("Domain");
type.addField("IPAddress");
type.addField("Scopes");
type.addField("LastUpdate");
type.addField("UpdateMinutesElapsed");
XML_MAPPING.put(ResourceTypeDecorator.Sweeper_GHN.name(), type);
/*********************************************
* MODEL FOR SWEEPER RI
********************************************/
// The column model for grid representation
modelColumns = new ArrayList<ColumnConfig>();
modelColumns.add(new ColumnConfig("ID", "ID", 120));
modelColumns.add(new ColumnConfig("ServiceClass", "ServiceClass", 100));
modelColumns.add(new ColumnConfig("ServiceName", "ServiceName", 100));
modelColumns.add(new ColumnConfig("ghnid", "GHN ID", 120));
// hidden fields
modelColumns.add(new ColumnConfig("Actions", "Actions", 260));
modelColumns.add(new ColumnConfig("ServiceStatus", "Status", 90));
modelColumns.add(new ColumnConfig("ActivationTime", "Activation Time", 140));
// create the column model
cm = new ColumnModel(modelColumns);
for (int i = 4; i < modelColumns.size(); i++) {
cm.setHidden(i, true);
}
RECORD_DEFINITION.put(ResourceTypeDecorator.Sweeper_RI.name(), cm);
// defines the xml structure
type = new ModelType();
type.setRoot("Resources");
type.setRecordName("Resource");
type.addField("ID");
type.addField("ServiceStatus");
type.addField("ServiceClass");
type.addField("ServiceName");
type.addField("ActivationTime");
type.addField("ghnid");
type.addField("Actions");
XML_MAPPING.put(ResourceTypeDecorator.Sweeper_RI.name(), type);
/*********************************************
* VALIDATORS
********************************************/
/*
* REQUIRED FIELDS
*/
REQUIRED_FIELDS = new HashMap<String, String[]>();
REQUIRED_FIELDS.put(
ResourceTypeDecorator.GHN.name(),
new String[] {
"Name",
"SubType",
"ID",
"Scopes"
});
REQUIRED_FIELDS.put(
ResourceTypeDecorator.Collection.name(),
new String[] {
"Name",
"SubType",
"ID",
"Scopes"
});
REQUIRED_FIELDS.put(
ResourceTypeDecorator.GenericResource.name(),
new String[] {
"Name",
"SubType",
"ID",
"Scopes"
});
REQUIRED_FIELDS.put(
ResourceTypeDecorator.RuntimeResource.name(),
new String[] {
"Name",
"SubType",
"ID",
"Scopes"
});
REQUIRED_FIELDS.put(
ResourceTypeDecorator.VIEW.name(),
new String[] {
"Name",
"SubType",
"ID",
"Scopes"
});
REQUIRED_FIELDS.put(
ResourceTypeDecorator.RunningInstance.name(),
new String[] {
"ServiceClass",
"ServiceName",
"ID",
"SubType",
"Scopes",
"GHN"
});
REQUIRED_FIELDS.put(
ResourceTypeDecorator.Service.name(),
new String[] {
"ServiceClass",
"ServiceName",
"ID",
"SubType",
"Scopes"
});
REQUIRED_FIELDS.put(
ResourceTypeDecorator.WSResource.name(),
new String[] {
"SourceKey",
"ServiceName",
"ID",
"SubType",
"Scopes"
});
}
public static final ColumnModel getRecordDefinition(final String nodeID) {
init();
return RECORD_DEFINITION.get(nodeID);
}
public static final ModelType getXMLMapping(final String nodeID) {
init();
return XML_MAPPING.get(nodeID);
}
public static final String[] getRequiredFields(final String type) {
init();
return REQUIRED_FIELDS.get(type);
}
}

View File

@ -1,83 +0,0 @@
/****************************************************************************
* This software is part of the gCube Project.
* Site: http://www.gcube-system.org/
****************************************************************************
* The gCube/gCore software is licensed as Free Open Source software
* conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
* The software and documentation is provided by its authors/distributors
* "as is" and no expressed or
* implied warranty is given for its use, quality or fitness for a
* particular case.
****************************************************************************
* Filename: ResourceTypeDecorator.java
****************************************************************************
* @author <a href="mailto:daniele.strollo@isti.cnr.it">Daniele Strollo</a>
***************************************************************************/
package org.gcube.portlets.admin.resourcesweeper.client.model;
/**
* @author Daniele Strollo
* @author Massimiliano Asssante (ISTI-CNR)
*
*/
public enum ResourceTypeDecorator {
/****************************************
* RESOURCES IN THE TREE
****************************************/
GHN("gCube Hosting Node", "ghn-icon"),
RunningInstance("Running Instances", "runninginstance-icon"),
Service("Software", "service-icon"),
VIEW("View", "metadatacollection-icon"),
GenericResource("Generic Resources", "genericresource-icon"),
Collection("Collection", "collection-icon"),
WSResource("WSResource", "wsresources-icon"),
Empty("Empty Tree", "empty-icon"),
RuntimeResource("Runtime Resources", "runtimeresource-icon"),
/****************************************
* Other components
****************************************/
// For deploying services - similar to the software but with an
// extension to handle checkbox for install
InstallableSoftware("InstallableSoftware", "empty-icon"),
// In the taskbar for handlig the refresh of deployment reports
DeployReport("Deploy Report", "report-big-icon"),
AddScopeReport("Add Scope Report", "report-big-icon"),
/****************************************
* Related resources
****************************************/
GHNRelated("Running Instances", "runninginstance-icon"),
ServiceRelated("Running Instances", "runninginstance-icon"),
RunningInstanceRelated("Running Instances", "runninginstance-icon"),
/****************************************
* Models for SWEEPER
***************************************/
Sweeper_GHN("gCube Hosting Node", "ghn-icon"),
Sweeper_RI("Running Instance", "runninginstance-icon"),
Sweeper_RI_Orphan("Orphan Running Instance", "orphan-runninginstance-icon"),
Sweeper_GHN_Expired("Expired gHN", "expired-ghn-icon"),
Sweeper_GHN_Dead("Dead gHN", "dead-ghn-icon");
private String label = null;
private String icon = null;
ResourceTypeDecorator(
final String label,
final String icon) {
this.label = label;
this.icon = icon;
}
public String getLabel() {
return this.label;
}
public String getIcon() {
return this.icon;
}
}

View File

@ -1,100 +0,0 @@
/****************************************************************************
* This software is part of the gCube Project.
* Site: http://www.gcube-system.org/
****************************************************************************
* The gCube/gCore software is licensed as Free Open Source software
* conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
* The software and documentation is provided by its authors/distributors
* "as is" and no expressed or
* implied warranty is given for its use, quality or fitness for a
* particular case.
****************************************************************************
* Filename: AtomicTreeNode.java
****************************************************************************
* @author <a href="mailto:daniele.strollo@isti.cnr.it">Daniele Strollo</a>
***************************************************************************/
package org.gcube.portlets.admin.resourcesweeper.shared;
import com.extjs.gxt.ui.client.data.BaseTreeModel;
/**
* @author Daniele Strollo (ISTI-CNR)
*
*/
public class AtomicTreeNode extends BaseTreeModel {
private static final long serialVersionUID = 5094327834701967591L;
private static int ID = 0;
/**
* @deprecated fr serialization only
*/
public AtomicTreeNode() {
set("id", ID++);
}
public AtomicTreeNode(final String node) {
this(node, null);
}
/**
* The node is used as original node of the element useful to retrieve it from the IS.
* The name is instead used for pretty printing (aliasing).
* @param node the corresponding IS node
* @param name if null the node will be used instead
*/
public AtomicTreeNode(final String node, final String name) {
set("id", ID++);
set("node", node);
if (name == null) {
set("name", node);
} else {
set("name", name);
}
}
public AtomicTreeNode(final String node, final String name, final String icon) {
this(node, name);
set("icon", icon);
}
public AtomicTreeNode(final String node, final String name, final AtomicTreeNode[] children) {
this(node, name);
for (int i = 0; i < children.length; i++) {
add(children[i]);
}
}
public AtomicTreeNode(final String node, final String name, final String icon, final AtomicTreeNode[] children) {
this(node, name, children);
set("icon", icon);
}
public final Integer getId() {
return (Integer) get("id");
}
public final String getName() {
return (String) get("name");
}
public final String getNode() {
return (String) get("node");
}
public final String getLabel() {
return (String) get("label");
}
public final String toString() {
return getName();
}
public final String getSubType() {
if (this.isLeaf() && this.getParent() != null) {
return this.getNode();
}
return null;
}
}

View File

@ -1,81 +0,0 @@
/****************************************************************************
* This software is part of the gCube Project.
* Site: http://www.gcube-system.org/
****************************************************************************
* The gCube/gCore software is licensed as Free Open Source software
* conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
* The software and documentation is provided by its authors/distributors
* "as is" and no expressed or
* implied warranty is given for its use, quality or fitness for a
* particular case.
****************************************************************************
* Filename: ResourceProfile.java
****************************************************************************
* @author <a href="mailto:daniele.strollo@isti.cnr.it">Daniele Strollo</a>
***************************************************************************/
package org.gcube.portlets.admin.resourcesweeper.shared;
import java.io.Serializable;
import org.gcube.portlets.admin.resourcesweeper.client.model.ResourceTypeDecorator;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* The profile of resources is represented by its
* xml and html representations and its title (the name
* or the ID) and the type (GHN, RI, ...).
* @author Daniele Strollo (ISTI-CNR)
*
*/
public class CompleteResourceProfile implements Serializable, IsSerializable {
private static final long serialVersionUID = 1L;
private String xmlRepresentation = null;
private String htmlRepresentation = null;
private ResourceTypeDecorator type = null;
private String title = null;
private String ID = null;
/**
* @deprecated for serialization only
*/
public CompleteResourceProfile() {
}
public CompleteResourceProfile(String ID, ResourceTypeDecorator type, String title, String xmlRepresentation,
String htmlRepresentation) {
super();
this.ID = ID;
this.type = type;
this.title = title;
this.xmlRepresentation = xmlRepresentation;
this.htmlRepresentation = htmlRepresentation;
}
public String getXmlRepresentation() {
return xmlRepresentation;
}
public String getHtmlRepresentation() {
return htmlRepresentation;
}
public ResourceTypeDecorator getType() {
return type;
}
public String getTitle() {
return title;
}
public String getID() {
return ID;
}
}