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.setIdentifier("http://notsupported");
IAuthor author = persistenceManager.newInstance(IAuthor.class);
author.setAuthorName("Paul Sharples");
author.setEmail("p.sharples@bolton.ac.uk");
author.setHref("http://iec.bolton.ac.uk");
widget.setAuthor(author);
widget.setVersion("v1.0");
IName widgetName = persistenceManager.newInstance(IName.class);
widgetName.setName("Unsupported widget widget");
widgetName.setShort("Unsupported");
widget.getNames().add(widgetName);
IDescription widgetDescription = persistenceManager.newInstance(IDescription.class);
widgetDescription.setDescription("This widget is a placeholder for when no corresponding widget is found for a given type");
widget.getDescriptions().add(widgetDescription);
IContent widgetStartFile = persistenceManager.newInstance(IContent.class);
widgetStartFile.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/wservices/notsupported/index.htm");
widget.getContentList().add(widgetStartFile);
IContent widgetBUStartFile = persistenceManager.newInstance(IContent.class);
widgetBUStartFile.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/wservices/notsupported/locales/bu/index.htm");
widgetBUStartFile.setLang("bu");
widget.getContentList().add(widgetBUStartFile);
IContent widgetFRStartFile = persistenceManager.newInstance(IContent.class);
widgetFRStartFile.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/wservices/notsupported/locales/fr/index.htm");
widgetFRStartFile.setLang("fr");
widget.getContentList().add(widgetFRStartFile);
IContent widgetENStartFile = persistenceManager.newInstance(IContent.class);
widgetENStartFile.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/wservices/notsupported/locales/en/index.htm");
widgetENStartFile.setLang("en");
widget.getContentList().add(widgetENStartFile);
IIcon widgetIcon = persistenceManager.newInstance(IIcon.class);
widgetIcon.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/shared/images/defaultwidget.png");
widgetIcon.setHeight(80);
widgetIcon.setWidth(80);
widgetIcon.setLang("en");
widget.getIcons().add(widgetIcon);
persistenceManager.save(widget);
}
else
{
initializing = false;