Exemple #1
0
        public void it_returns_full_build_field_Links()
        {
            var        tempBuildConfig = m_client.BuildConfigs.All().First();
            LinkField  linkField       = LinkField.WithFields(type: true, url: true, relativeUrl: true);
            LinksField linksField      = LinksField.WithFields(link: linkField);
            var        buildField      = BuildField.WithFields(links: linksField);
            var        tempBuild       = m_client.Builds.LastBuildByBuildConfigId(tempBuildConfig.Id);
            var        build           = m_client.Builds.GetFields(buildField.ToString()).ById(tempBuild.Id);

            Assert.IsNotNull(build);
        }
Exemple #2
0
        public void it_returns_full_build_field_2()
        {
            var                            tempBuildConfig                = m_client.BuildConfigs.All().First();
            ItemsField                     itemsField                     = ItemsField.WithFields(item: true);
            BuildsField                    buildsField                    = BuildsField.WithFields();
            RelatedField                   relatedField                   = RelatedField.WithFields(builds: buildsField);
            RelatedIssuesField             relatedIssuesField             = RelatedIssuesField.WithFields(href: true);
            ArtifactDependenciesField      artifactDependenciesField      = ArtifactDependenciesField.WithFields();
            BuildArtifactDependenciesField buildArtifactDependenciesField = BuildArtifactDependenciesField.WithFields();
            BuildSnapshotDependenciesField buildSnapshotDependenciesField = BuildSnapshotDependenciesField.WithFields();
            DatasField                     datasField                     = DatasField.WithFields();
            StatisticsField                statisticsField                = StatisticsField.WithFields();
            EntriesField                   entriesField                   = EntriesField.WithFields();
            PropertiesField                propertiesField                = PropertiesField.WithFields();
            ArtifactsField                 artifactsField                 = ArtifactsField.WithFields(href: true);
            ProblemOccurrencesField        problemOccurrences             = ProblemOccurrencesField.WithFields();
            TestOccurrencesField           testOccurrencesField           = TestOccurrencesField.WithFields();
            AgentField                     agentField                     = AgentField.WithFields(id: true);
            CompatibleAgentsField          compatibleAgentsField          = CompatibleAgentsField.WithFields(agent: agentField, href: true);
            BuildField                     buildField1                    = BuildField.WithFields(id: true);
            BuildChangeField               buildChangeField               = BuildChangeField.WithFields(nextBuild: buildField1, prevBuild: buildField1);
            BuildChangesField              buildChangesField              = BuildChangesField.WithFields(buildChange: buildChangeField);
            RevisionField                  revisionField                  = RevisionField.WithFields(version: true);
            RevisionsField                 revisionsField                 = RevisionsField.WithFields();
            LastChangesField               lastChangesField               = LastChangesField.WithFields();
            ChangesField                   changesField                   = ChangesField.WithFields();
            TriggeredField                 triggeredField                 = TriggeredField.WithFields(type: true);
            ProgressInfoField              progressInfoField              = ProgressInfoField.WithFields(currentStageText: true);
            TagsField                      tagsField             = TagsField.WithFields();
            UserField                      userField             = UserField.WithFields(id: true);
            CommentField                   commentField          = CommentField.WithFields(text: true);
            BuildTypeField                 buildTypeField        = BuildTypeField.WithFields(id: true);
            BuildTypeWrapperField          buildTypeWrapperField = BuildTypeWrapperField.WithFields(buildType: buildTypeField);
            LinkField                      linkField             = LinkField.WithFields(type: true);
            LinksField                     linksField            = LinksField.WithFields(link: linkField);
            var                            buildField            = BuildField.WithFields(links: linksField, buildType: buildTypeField, comment: commentField,
                                                                                         tags: tagsField, pinInfo: commentField, user: userField, running_info: progressInfoField,
                                                                                         canceledInfo: commentField, triggered: triggeredField, lastChanges: lastChangesField, changes: changesField,
                                                                                         revisions: revisionsField, versionedSettingsRevision: revisionField,
                                                                                         artifactDependencyChanges: buildChangesField, agent: agentField, compatibleAgents: compatibleAgentsField,
                                                                                         testOccurrences: testOccurrencesField, problemOccurrences: problemOccurrences, artifacts: artifactsField,
                                                                                         properties: propertiesField, resultingProperties: propertiesField, attributes: entriesField,
                                                                                         statistics: statisticsField, metadata: datasField, snapshotDependencies: buildSnapshotDependenciesField,
                                                                                         artifactDependencies: buildArtifactDependenciesField, customArtifactDependencies: artifactDependenciesField,
                                                                                         statusChangeComment: commentField, relatedIssues: relatedIssuesField, replacementIds: itemsField,
                                                                                         related: relatedField);

            var tempBuild = m_client.Builds.LastBuildByBuildConfigId(tempBuildConfig.Id);
            var build     = m_client.Builds.GetFields(buildField.ToString()).ById(tempBuild.Id);

            Assert.IsNotNull(build);
        }
		//////////////////////////////////////////////////////////////////////////////

		//
		// Dealing with documents
		//

		static protected void BuildDocuments (Indexable indexable,
						      out Document primary_doc,
						      out Document secondary_doc)
		{
			primary_doc = new Document ();
			secondary_doc = null;

			Field f;

			// During querying, we retrieve a lucene document with only certain fields
			// like Uri and Timestamp and quickly check if the document is a good one
			// The field specified document constructor runs faster if the fields that
			// are asked for are located at the beginning of the document.
			// Hence it is better to keep "Uri" and "Timestamp" at the beginning.
			f = new Field ("Uri", UriFu.UriToEscapedString (indexable.Uri),
				       Field.Store.YES, Field.Index.NO_NORMS);
			primary_doc.Add (f);

			if (indexable.ParentUri != null) {
				f = new Field ("ParentUri", UriFu.UriToEscapedString (indexable.ParentUri),
					       Field.Store.YES, Field.Index.NO_NORMS);
				primary_doc.Add (f);
			}
			
			if (indexable.ValidTimestamp) {
				// Note that we also want to search in the
				// Timestamp field when we do a wildcard date
				// query, so that's why we also add a wildcard
				// field for each item here.

				string wildcard_field = TypeToWildcardField (PropertyType.Date);

				string str = StringFu.DateTimeToString (indexable.Timestamp);
				f = new Field ("Timestamp", str, Field.Store.YES, Field.Index.NO_NORMS);
				primary_doc.Add (f);
				f = new Field (wildcard_field, str, Field.Store.NO, Field.Index.NO_NORMS);
				primary_doc.Add (f);

				// Create an inverted timestamp so that we can
				// sort by timestamp at search-time.
				long timeval = Convert.ToInt64 (str);
				// Pad the inverted timestamp with zeroes for proper string comparison during termenum enumeration
				f = new Field ("InvertedTimestamp", (Int64.MaxValue - timeval).ToString ("d19"),
					       Field.Store.NO, Field.Index.NO_NORMS);
				primary_doc.Add (f);

				str = StringFu.DateTimeToYearMonthString (indexable.Timestamp);
				f = new Field ("Timestamp(YM)", str, Field.Store.YES, Field.Index.NO_NORMS);
				primary_doc.Add (f);
				f = new Field (wildcard_field + "(YM)", str,
					       Field.Store.NO, Field.Index.NO_NORMS);
				primary_doc.Add (f);

				str = StringFu.DateTimeToDayString (indexable.Timestamp);
				f = new Field ("Timestamp(D)", str, Field.Store.YES, Field.Index.NO_NORMS);
				primary_doc.Add (f);
				f = new Field (wildcard_field + "(D)", str,
					       Field.Store.NO, Field.Index.NO_NORMS);
				primary_doc.Add (f);
			}

			if (indexable.NoContent) {
				// If there is no content, make a note of that
				// in a special property.
				Property prop;
				prop = Property.NewBool ("beagle:NoContent", true);
				AddPropertyToDocument (prop, primary_doc);
				
			} else {

				// Since we might have content, add our text
				// readers.

				TextReader reader;
				
				// Add the field "Text" first
				// It is important that the order is preserved
				reader = indexable.GetTextReader ();
				if (reader != null) {
					f = new Field ("Text", reader);
					primary_doc.Add (f);
				}
			
				// FIXME: HotText is ignored for now!
				// Then add "HotText"
				//reader = indexable.GetHotTextReader ();
				//if (reader != null) {
				//	f = new Field ("HotText", reader);
				//	primary_doc.Add (f);
				//}
			}

			// Store the Type and MimeType in special properties

			if (indexable.HitType != null) {
				Property prop;
				prop = Property.NewUnsearched ("beagle:HitType", indexable.HitType);
				AddPropertyToDocument (prop, primary_doc);
			}

			if (indexable.MimeType != null) {
				Property prop;
				prop = Property.NewUnsearched ("beagle:MimeType", indexable.MimeType);
				AddPropertyToDocument (prop, primary_doc);
			}

			if (indexable.Source != null) {
				Property prop;
				prop = Property.NewUnsearched ("beagle:Source", indexable.Source);
				AddPropertyToDocument (prop, primary_doc);
			}

			{
				Property prop;
				prop = Property.NewBool (Property.IsChildPropKey, indexable.IsChild);
				AddPropertyToDocument (prop, primary_doc);
			}

			// Store the other properties
				
			foreach (Property prop in indexable.Properties) {
				Document target_doc = primary_doc;
				if (prop.IsMutable) {
					if (secondary_doc == null)
						secondary_doc = CreateSecondaryDocument (indexable.Uri, indexable.ParentUri);

					target_doc = secondary_doc;
				}
					
				AddPropertyToDocument (prop, target_doc);
			}
#if ENABLE_RDF_ADAPTER

			// Now add the whitespace separated list of links extracted from the document of the text
			// Add the property to the primary document. Why primary ?
			// Because it stays with the "Text" property
			Fieldable links_field = new LinksField (indexable.Links);
			primary_doc.Add (links_field);

			// Finally add a field containing a whitespace separated list of other fields in the document
			AddFieldProperies (primary_doc);
			if (secondary_doc != null)
				AddFieldProperies (secondary_doc);
#endif
		}