Package com.redhat.topicindex.rest.entities

Examples of com.redhat.topicindex.rest.entities.TopicV1


       Collections.sort(list, new Comparator<InjectionTopicData>()
          {
              @Override
        public int compare(final InjectionTopicData o1, final InjectionTopicData o2)
              {
                TopicV1 topic1 = null;
                TopicV1 topic2 = null;
               
                for (final TopicV1 topic : topics)
                {
                  if (topic.getId().equals(o1.topicId))
                    topic1 = topic;
                  if (topic.getId().equals(o2.topicId))
                    topic2 = topic;
                 
                  if (topic1 != null && topic2 != null)
                    break;
                }
               
                final boolean v1Exists = topic1 != null;
                final boolean v2Exists = topic2 != null;
               
                if (!v1Exists && !v2Exists)
                  return 0;
                if (!v1Exists)
                  return -1;
                if (!v2Exists)
                  return 1;
               
                final TopicV1 v1 = topic1;
                final TopicV1 v2 = topic2;
               
                if (v1 == null && v2 == null)
                  return 0;
               
                if (v1 == null)
                  return -1;
               
                if (v2 == null)
                  return 1;
               
                if (v1.getTitle() == null && v2.getTitle() == null)
                  return 0;
               
                if (v1.getTitle() == null)
                  return -1;
               
                if (v2.getTitle() == null)
                  return 1;
               
                return v1.getTitle().toLowerCase().compareTo(v2.getTitle().toLowerCase());
              }
          });
      }
View Full Code Here


            customInjectionIds.add(sequenceID.topicId);

            /*
             * Pull the topic out of the list of related topics
             */
            final TopicV1 relatedTopic = relatedTopicsDatabase.getTopic(sequenceID.topicId);

            /*
             * See if the topic is also available in the main
             * database (if the main database is available)
             */
            final boolean isInDatabase = database == null ? true : database.getTopic(sequenceID.topicId) != null;

            /*
             * It is possible that the topic id referenced in the
             * injection point has not been related, or has not been
             * included in the list of topics to process. This is a
             * validity error
             */
            if (relatedTopic != null && isInDatabase)
            {
              /*
               * build our list
               */
              List<List<Element>> list = new ArrayList<List<Element>>();

              /*
               * each related topic is added to a string, which is
               * stored in the customInjections collection. the
               * customInjections key is the custom injection text
               * from the source xml. this allows us to match the
               * xrefs we are generating for the related topic
               * with the text in the xml file that these xrefs
               * will eventually replace
               */
              if (customInjections.containsKey(comment))
                list = customInjections.get(comment).listItems;

              /* wrap the xref up in a listitem */
              final String url = getURLToInternalTopic(relatedTopic.getId());
              if (sequenceID.optional)
              {
                if (internal)
                {
                  list.add(DocbookUtils.buildEmphasisPrefixedULink(xmlDocument, OPTIONAL_LIST_PREFIX, url, relatedTopic.getTitle()));
                }
                else
                {
                  if (usedFixedUrls)
                  {
                    final PropertyTagV1 propTag = relatedTopic.getProperty(CommonConstants.FIXED_URL_PROP_TAG_ID);
                    if (propTag != null)
                    {
                      list.add(DocbookUtils.buildEmphasisPrefixedXRef(xmlDocument, OPTIONAL_LIST_PREFIX, propTag.getValue()));
                    }
                    else
                    {
                      list.add(DocbookUtils.buildEmphasisPrefixedXRef(xmlDocument, OPTIONAL_LIST_PREFIX, relatedTopic.getXRefID()));
                    }
                  }
                  else
                  {
                    list.add(DocbookUtils.buildEmphasisPrefixedXRef(xmlDocument, OPTIONAL_LIST_PREFIX, relatedTopic.getXRefID()));
                  }
                }
              }
              else
              {
                if (internal)
                {
                  list.add(DocbookUtils.buildULink(xmlDocument, url, relatedTopic.getTitle()));
                }
                else
                {
                  if (usedFixedUrls)
                  {
                    final PropertyTagV1 propTag = relatedTopic.getProperty(CommonConstants.FIXED_URL_PROP_TAG_ID);
                    if (propTag != null)
                    {
                      list.add(DocbookUtils.buildXRef(xmlDocument, propTag.getValue()));
                    }
                    else
                    {
                      list.add(DocbookUtils.buildXRef(xmlDocument, relatedTopic.getXRefID()));
                    }
                  }
                  else
                  {
                    list.add(DocbookUtils.buildXRef(xmlDocument, relatedTopic.getXRefID()));
                  }
                }
              }

              /*
 
View Full Code Here

             * make sure the topic we are trying to inject has been
             * related
             */
            if (topic.isRelatedTo(topicID))
            {
              final TopicV1 relatedTopic = topic.getRelatedTopicByID(topicID);
              final Document relatedTopicXML = XMLUtilities.convertStringToDocument(relatedTopic.getXml());
              if (relatedTopicXML != null)
              {
                final Node relatedTopicDocumentElement = relatedTopicXML.getDocumentElement();
                final Node importedXML = xmlDocument.importNode(relatedTopicDocumentElement, true);

View Full Code Here

             * make sure the topic we are trying to inject has been
             * related
             */
            if (topic.isRelatedTo(topicID))
            {
              final TopicV1 relatedTopic = topic.getRelatedTopicByID(topicID);
              final Element titleNode = xmlDocument.createElement("title");
              titleNode.setTextContent(relatedTopic.getTitle());
              replacements.put(comment, titleNode);
            }
            else if (docbookBuildingOptions != null && !docbookBuildingOptions.getIgnoreMissingCustomInjections())
            {
              retValue.add(Integer.parseInt(reMatch));
View Full Code Here

            customInjectionIds.add(sequenceID.topicId);

            /*
             * Pull the topic out of the list of related topics
             */
            final TopicV1 relatedTopic = relatedTopicsDatabase.getTopic(sequenceID.topicId);
           
            /*
             * See if the topic is also available in the main
             * database (if the main database is available)
             */
            final boolean isInDatabase = database == null ? true : database.getTopic(sequenceID.topicId) != null;

            /*
             * It is possible that the topic id referenced in the
             * injection point has not been related, or has not been
             * included in the list of topics to process. This is a
             * validity error
             */
            if (relatedTopic != null && isInDatabase)
            {
              /*
               * build our list
               */
              List<List<Element>> list = new ArrayList<List<Element>>();

              /*
               * each related topic is added to a string, which is
               * stored in the customInjections collection. the
               * customInjections key is the custom injection text
               * from the source xml. this allows us to match the
               * xrefs we are generating for the related topic
               * with the text in the xml file that these xrefs
               * will eventually replace
               */
              if (customInjections.containsKey(comment))
                list = customInjections.get(comment).listItems;

              /* wrap the xref up in a listitem */
              if (sequenceID.optional)
              {
                if (internal)
                {
                  final TranslatedTopicDataV1 relatedTranslatedTopicData = translatedTopicData.getLatestRelatedTranslationDataByTopicID(relatedTopic.getId());
                 
                  if (relatedTranslatedTopicData != null)
                  {
                    final String url = getURLToInternalTranslatedTopic(relatedTranslatedTopicData.getTranslatedTopic().getId(), relatedTranslatedTopicData.getTranslationLocale());
                   
                    /* Get the related translated data object and the title from the XML */
                    final String relatedTitle = DocBookUtilities.findTitle(relatedTranslatedTopicData.getTranslatedXml());
                   
                    list.add(DocbookUtils.buildEmphasisPrefixedULink(xmlDocument, XMLPreProcessor.OPTIONAL_LIST_PREFIX, url, relatedTitle));
                  }
                  else
                  {
                    final String url = getURLToInternalTopic(relatedTopic.getId());
                   
                    final String relatedTopicTitle = "[" + relatedTopic.getLocale() + "] " + relatedTopic.getTitle() + "*";
                   
                    list.add(DocbookUtils.buildEmphasisPrefixedULink(xmlDocument, XMLPreProcessor.OPTIONAL_LIST_PREFIX, url, relatedTopicTitle));
                   
                    /* Create an error note that is added at the bottom of the topic */
                  }
                }
                else
                {
                  if (usedFixedUrls)
                  {
                    final PropertyTagV1 propTag = relatedTopic.getProperty(CommonConstants.FIXED_URL_PROP_TAG_ID);
                    if (propTag != null)
                    {
                      list.add(DocbookUtils.buildEmphasisPrefixedXRef(xmlDocument, XMLPreProcessor.OPTIONAL_LIST_PREFIX, propTag.getValue()));
                    }
                    else
                    {
                      list.add(DocbookUtils.buildEmphasisPrefixedXRef(xmlDocument, XMLPreProcessor.OPTIONAL_LIST_PREFIX, relatedTopic.getXRefID()));
                    }
                  }
                  else
                  {
                    list.add(DocbookUtils.buildEmphasisPrefixedXRef(xmlDocument, XMLPreProcessor.OPTIONAL_LIST_PREFIX, relatedTopic.getXRefID()));
                  }
                }
              }
              else
              {
                if (internal)
                {
                  final TranslatedTopicDataV1 relatedTranslatedTopicData = translatedTopicData.getLatestRelatedTranslationDataByTopicID(relatedTopic.getId());
                 
                  if (relatedTranslatedTopicData != null)
                  {
                    final String url = getURLToInternalTranslatedTopic(relatedTranslatedTopicData.getTranslatedTopic().getId(), relatedTranslatedTopicData.getTranslationLocale());
                   
                    /* Get the related translated data object and the title from the XML */
                    final String relatedTitle = DocBookUtilities.findTitle(relatedTranslatedTopicData.getTranslatedXml());
                   
                    list.add(DocbookUtils.buildULink(xmlDocument, url, relatedTitle));
                  }
                  else
                  {
                    final String url = getURLToInternalTopic(relatedTopic.getId());
                   
                    final String relatedTopicTitle = "[" + relatedTopic.getLocale() + "] " + relatedTopic.getTitle() + "*";
                   
                    list.add(DocbookUtils.buildULink(xmlDocument, url, relatedTopicTitle));
                   
                    translatedTopicTitleErrors.addTitle(relatedTopic.getTitle());
                  }
                }
                else
                {
                  if (usedFixedUrls)
                  {
                    final PropertyTagV1 propTag = relatedTopic.getProperty(CommonConstants.FIXED_URL_PROP_TAG_ID);
                    if (propTag != null)
                    {
                      list.add(DocbookUtils.buildXRef(xmlDocument, propTag.getValue()));
                    }
                    else
                    {
                      list.add(DocbookUtils.buildXRef(xmlDocument, relatedTopic.getXRefID()));
                    }
                  }
                  else
                  {
                    list.add(DocbookUtils.buildXRef(xmlDocument, relatedTopic.getXRefID()));
                  }
                }
              }

              /*
 
View Full Code Here

              {
                titleNode.setTextContent(relatedTranslatedTopicData.getTranslatedTopicTitle());
              }
              else
              {
                final TopicV1 relatedTopic = topic.getRelatedTopicByID(topicID);
                titleNode.setTextContent(relatedTopic.getTitle());
               
                translatedTopicTitleErrors.addTitle(relatedTopic.getTitle());
              }
              replacements.put(comment, titleNode);
            }
            else if (docbookBuildingOptions != null && !docbookBuildingOptions.getIgnoreMissingCustomInjections())
            {
View Full Code Here

       Collections.sort(list, new Comparator<InjectionTopicData>()
          {
              @Override
        public int compare(final InjectionTopicData o1, final InjectionTopicData o2)
              {
                TopicV1 topic1 = null;
                TopicV1 topic2 = null;
               
                for (final TopicV1 topic : topics)
                {
                  if (topic.getId().equals(o1.topicId))
                    topic1 = topic;
                  if (topic.getId().equals(o2.topicId))
                    topic2 = topic;
                 
                  if (topic1 != null && topic2 != null)
                    break;
                }
               
                final boolean v1Exists = topic1 != null;
                final boolean v2Exists = topic2 != null;
               
                if (!v1Exists && !v2Exists)
                  return 0;
                if (!v1Exists)
                  return -1;
                if (!v2Exists)
                  return 1;
               
                final TopicV1 v1 = topic1;
                final TopicV1 v2 = topic2;
               
                if (v1 == null && v2 == null)
                  return 0;
               
                if (v1 == null)
                  return -1;
               
                if (v2 == null)
                  return 1;
               
                if (v1.getTitle() == null && v2.getTitle() == null)
                  return 0;
               
                if (v1.getTitle() == null)
                  return -1;
               
                if (v2.getTitle() == null)
                  return 1;
               
                return v1.getTitle().toLowerCase().compareTo(v2.getTitle().toLowerCase());
              }
          });
      }
View Full Code Here

        {
            client = ProxyFactory.create(
                            RESTInterfaceV1.class,
                            "http://localhost:8080/TopicIndex/seam/resource/rest");

      TopicV1 newTopic = new TopicV1();
      newTopic.setTitleExplicit("New Topic");
      newTopic.setXmlExplicit("");

      // Creating a new topic will work as it initialises all the collections for the REST Entity (via createRESTEntityFromDBEntity()) before committing the transaction.
      TopicV1 returnedTopic = client.createJSONTopic("", newTopic);
      if (returnedTopic == null) throw new Exception("Unable to create a new topic");

      returnedTopic.setTitleExplicit("Updated Topic");

      // Updating the topic will fail as it attempts to create the REST entity from un-initialised collections after the transaction has been committed.
      TopicV1 updatedTopic = client.updateJSONTopic("", returnedTopic);
      if (updatedTopic == null) throw new Exception("Unable to update an existing topic");
        }
        catch (final Exception ex)
        {
            System.out.println(ex.toString());
View Full Code Here

TOP

Related Classes of com.redhat.topicindex.rest.entities.TopicV1

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.