IPersistenceManager persistenceManager = getPersistenceManager();
persistenceManager.begin();
// Widget
boolean initializing = true;
IWidget widget = persistenceManager.findWidgetByGuid("http://notsupported");
if (widget == null)
{
// required: always create if not found
widget = persistenceManager.newInstance(IWidget.class);
widget.setHeight(350);
widget.setWidth(500);
widget.setGuid("http://notsupported");
widget.setWidgetAuthor("Paul Sharples");
widget.setWidgetAuthorEmail("p.sharples@bolton.ac.uk");
widget.setWidgetAuthorHref("http://iec.bolton.ac.uk");
widget.setVersion("v1.0");
IName widgetName = persistenceManager.newInstance(IName.class);
widgetName.setName("Unsupported widget widget");
widgetName.setShortName("Unsupported");
widget.getNames().add(widgetName);
IDescription widgetDescription = persistenceManager.newInstance(IDescription.class);
widgetDescription.setContent("This widget is a placeholder for when no corresponding widget is found for a given type");
widget.getDescriptions().add(widgetDescription);
IStartFile widgetStartFile = persistenceManager.newInstance(IStartFile.class);
widgetStartFile.setUrl(WidgetRuntimeHelper.getWebContextPath() + "/wservices/notsupported/index.htm");
widget.getStartFiles().add(widgetStartFile);
IStartFile widgetBUStartFile = persistenceManager.newInstance(IStartFile.class);
widgetBUStartFile.setUrl(WidgetRuntimeHelper.getWebContextPath() + "/wservices/notsupported/locales/bu/index.htm");
widgetBUStartFile.setLang("bu");
widget.getStartFiles().add(widgetBUStartFile);
IStartFile widgetFRStartFile = persistenceManager.newInstance(IStartFile.class);
widgetFRStartFile.setUrl(WidgetRuntimeHelper.getWebContextPath() + "/wservices/notsupported/locales/fr/index.htm");
widgetFRStartFile.setLang("fr");
widget.getStartFiles().add(widgetFRStartFile);
IStartFile widgetENStartFile = persistenceManager.newInstance(IStartFile.class);
widgetENStartFile.setUrl(WidgetRuntimeHelper.getWebContextPath() + "/wservices/notsupported/locales/en/index.htm");
widgetENStartFile.setLang("en");
widget.getStartFiles().add(widgetENStartFile);
IWidgetIcon widgetIcon = persistenceManager.newInstance(IWidgetIcon.class);
widgetIcon.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/shared/images/defaultwidget.png");
widgetIcon.setHeight(80);
widgetIcon.setWidth(80);
widgetIcon.setLang("en");
widget.getWidgetIcons().add(widgetIcon);
persistenceManager.save(widget);
}
else
{
initializing = false;