Package org.apache.wookie.beans

Examples of org.apache.wookie.beans.IWidget


    // check if instance is valid
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
        IWidgetInstance widgetInstance = persistenceManager.findWidgetInstanceByIdKey(id_key);
    if(widgetInstance==null) return map;
    // Add in metadata
    IWidget widget = widgetInstance.getWidget();
    map.put("id", String.valueOf(widget.getGuid()))//$NON-NLS-1$
    map.put("author", String.valueOf(widget.getWidgetAuthor()))//$NON-NLS-1$
    map.put("authorEmail", String.valueOf(widget.getWidgetAuthorEmail()));//$NON-NLS-1$
    map.put("authorHref", String.valueOf(widget.getWidgetAuthorHref()));//$NON-NLS-1$
    map.put("name", String.valueOf(widget.getWidgetTitle()));//$NON-NLS-1$
    map.put("description", String.valueOf(widget.getWidgetDescription()));//$NON-NLS-1$ 
    map.put("shortName", String.valueOf(widget.getWidgetShortName())); //$NON-NLS-1$
    map.put("version", widget.getVersion());//$NON-NLS-1$
    map.put("width", String.valueOf(widget.getWidth()));//$NON-NLS-1$
    map.put("height", String.valueOf(widget.getHeight()));//$NON-NLS-1$
    return map;
  }
View Full Code Here


   * @param file the .wgt file the Widget was loaded from
   * @param grantAccessRequests whether to automatically grant access requests for the widget
   * @return the widget
   */
  public static IWidget addNewWidget(W3CWidget model, File file, boolean grantAccessRequests) {
    IWidget widget = addNewWidget(model, grantAccessRequests);
    widget.setPackagePath(file.getPath());
    return widget;
  }
View Full Code Here

   * @param grantAccessRequests whether to grant access requests created for the widget
   * @return the widget
   */
  public static IWidget addNewWidget(W3CWidget model, boolean grantAccessRequests) {
      IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidget widget = createWidget(persistenceManager, model);
    createAuthor(persistenceManager, model, widget);
    createStartFiles(persistenceManager, model,widget);
    createNames(persistenceManager, model,widget);
    createDescriptions(persistenceManager, model,widget);
    createIcons(persistenceManager, model, widget);
View Full Code Here

   
    return widget;        
  }

  private static IWidget createWidget(IPersistenceManager persistenceManager, W3CWidget model){
    IWidget widget;
    widget = persistenceManager.newInstance(IWidget.class);   
    widget.setDir(model.getDir());
    widget.setLang(model.getLang());
    widget.setDefaultLocale(model.getDefaultLocale());
    widget.setGuid(model.getIdentifier());
    widget.setHeight(model.getHeight());
    widget.setWidth(model.getWidth());
    widget.setVersion(model.getVersion());
    widget.setUpdateLocation(model.getUpdate());
    return widget;
  }
View Full Code Here

                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;
View Full Code Here

    String cloneSharedDataKey = request.getParameter("cloneshareddatakey");
    if (sharedDataKey == null || sharedDataKey.trim().equals("") || cloneSharedDataKey == null || cloneSharedDataKey.trim().equals("")){//$NON-NLS-1$ //$NON-NLS-2$
      throw new InvalidParametersException();
    }
    String cloneKey = SharedDataHelper.getInternalSharedDataKey(instance, cloneSharedDataKey);
        IWidget widget = instance.getWidget();
        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    for (ISharedData sharedData : new SharedContext(instance).getSharedData())
    {
        ISharedData clone = persistenceManager.newInstance(ISharedData.class);
            clone.setDkey(sharedData.getDkey());
View Full Code Here

   * @param locale the locale of the widget instance
   * @return an XML representation of the Widget Instance as a String
   */
  public static String createXMLWidgetInstanceDocument(IWidgetInstance instance, String url, String locale){
    String xml = XMLDECLARATION;
    IWidget widget = instance.getWidget();
   
    // Return a default width and height where the original value is either not provided
    // or of an invalid range (<0)
    String width = String.valueOf(IW3CXMLConfiguration.DEFAULT_WIDTH_LARGE);
    String height = String.valueOf(IW3CXMLConfiguration.DEFAULT_HEIGHT_LARGE);
    if (widget.getWidth()!=null && widget.getWidth()>0) width = widget.getWidth().toString();
    if (widget.getHeight()!=null && widget.getHeight()>0) height = widget.getHeight().toString();
       
    xml += "<widgetdata>"; //$NON-NLS-1$
    xml += "\t<url>"+url+"</url>"; //$NON-NLS-1$ //$NON-NLS-2$
    xml += "\t<identifier>"+instance.getIdKey()+"</identifier>\n"; //$NON-NLS-1$ //$NON-NLS-2$
    xml += "\t<title>"+StringEscapeUtils.escapeXml(widget.getWidgetTitle(locale))+"</title>\n"; //$NON-NLS-1$ //$NON-NLS-2$
    xml += "\t<height>"+height+"</height>\n"; //$NON-NLS-1$ //$NON-NLS-2$
    xml += "\t<width>"+width+"</width>\n"; //$NON-NLS-1$ //$NON-NLS-2$
    xml += "</widgetdata>"; //$NON-NLS-1$
   
    return xml;
View Full Code Here

   
    return xml;
  }
 
  public static String toJson(IWidgetInstance instance, String url, String locale) {
    IWidget widget = instance.getWidget();
    String width = String.valueOf(IW3CXMLConfiguration.DEFAULT_WIDTH_LARGE);
    String height = String.valueOf(IW3CXMLConfiguration.DEFAULT_HEIGHT_LARGE);
    if (widget.getWidth() != null && widget.getWidth() > 0)
      width = widget.getWidth().toString();
    if (widget.getHeight() != null && widget.getHeight() > 0)
      height = widget.getHeight().toString();
    JSONObject json = new JSONObject();
    try {
      json.put("url", url);
      json.put("identifier", instance.getIdKey());
      json.put("title", widget.getWidgetTitle(locale));
      json.put("height", height);
      json.put("width", width);
    } catch (JSONException e) {
      logger.error("Problem rendering instance using JSON",e);
    }
View Full Code Here

   * @param widgetId
   * @return a new WidgetInstance, or null if the instance cannot be created
   */
  public IWidgetInstance newInstance(String apiKey, String userId, String sharedDataKey, String serviceType, String widgetId, String lang){
    try {
      IWidget widget = null;
      IWidgetInstance widgetInstance;
      // Widget ID or Widget Type?
          IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
      if (widgetId != null){
        widget = persistenceManager.findWidgetByGuid(widgetId);
View Full Code Here

      HttpServletResponse response) throws ResourceNotFoundException,
      UnauthorizedAccessException, IOException {
    // attempt to get specific widget by id; note that this is the internal
    // widget integer ID and not the widget URI
    IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
    IWidget widget = persistenceManager.findById(IWidget.class, resourceId);
    if (widget == null) throw new ResourceNotFoundException();
    // redirect to the UDD
    if (widget.getUpdateLocation() ==  null) throw new ResourceNotFoundException();
    response.sendRedirect(widget.getUpdateLocation());
  }
View Full Code Here

TOP

Related Classes of org.apache.wookie.beans.IWidget

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.