public MetaMetadataOneLevelNestingEnumerator(MetaMetadataField firstObject, MetadataNS.Metadata firstMetadata) : base(firstObject, CreateMixinCollectionIterator(firstMetadata.Mixins)) { _currentMetadata = firstMetadata; if (firstMetadata.Mixins != null) { _nextMetadatas = firstMetadata.Mixins.GetEnumerator(); } }
/** * For the root, compare the meta-metadata from the binding with the one we started with. Down the * hierarchy, try to perform similar bindings. */ public void DeserializationPreHook(MetadataNS.Metadata deserializedMetadata, MetadataFieldDescriptor mfd) { if (deserializingRoot) { deserializingRoot = false; Document document = GetDocument(); MetaMetadataCompositeField preMM = document.MetaMetadata; MetadataClassDescriptor mcd = (MetadataClassDescriptor)ClassDescriptor.GetClassDescriptor(deserializedMetadata);; MetaMetadataCompositeField metaMetadata; String tagName = mcd.TagName; if (preMM.GetTagForTranslationScope().Equals(tagName)) { metaMetadata = preMM; } else { // just match in translation scope //TODO use local TranslationScope if there is one metaMetadata = SemanticsSessionScope.MetaMetadataRepository.GetMMByName(tagName); } deserializedMetadata.MetaMetadata = metaMetadata; currentMMstack.Push(metaMetadata); } else { String mmName = mfd.MmName; MetaMetadataNestedField currentMM = currentMMstack.Peek(); MetaMetadataNestedField childMMNested = (MetaMetadataNestedField)currentMM.LookupChild(mmName); // this fails for collections :-( if (childMMNested == null) { throw new Exception("Can't find composite child meta-metadata for " + mmName + " amidst " + mfd + "\n\tThis probably means there is a conflict between the meta-metadata repository and the runtime." + "\n\tProgrammer: Have you Changed the fields in built-in Metadata subclasses without updating primitives.xml???!"); } MetaMetadataCompositeField childMMComposite = null; if (childMMNested.IsPolymorphicInherently) { String tagName = ClassDescriptor.GetClassDescriptor(deserializedMetadata).TagName; childMMComposite = SemanticsSessionScope.MetaMetadataRepository.GetMMByName(tagName); } else { childMMComposite = childMMNested.GetMetaMetadataCompositeField(); } deserializedMetadata.MetaMetadata = childMMComposite; currentMMstack.Push(childMMComposite); } }
public override bool MoveNext() { bool result = false; bool newMetadata = (_currentIterator == null && _firstIterator.Current == null) || (_currentIterator != null && _currentIterator.Current == null); if (newMetadata && _nextMetadatas != null) { _nextMetadatas.MoveNext(); _currentMetadata = _nextMetadatas.Current; } result = base.MoveNext(); return(result); }
public MetadataNS.Metadata ConstructMetadata(SimplTypesScope metadataTScope = null) { if (metadataTScope == null) { metadataTScope = Repository.MetadataTScope; } MetadataNS.Metadata result = null; Type metadataClass = GetMetadataClass(metadataTScope); if (metadataClass != null) { Type[] argClasses = new Type[] { typeof(MetaMetadataCompositeField) }; object[] argObjects = new object[] { this }; //result = metadataClass.GetConstructor(argClasses).Invoke(argObjects) as Metadata.Metadata; //result = SemanticsPlatformSpecifics.Get().InvokeInstance(metadataClass, argClasses, argObjects) as MetadataNS.Metadata; result = ReflectionTools.GetInstance <Metadata>(metadataClass, argObjects); // TODO handle mixins. } return(result); }
public override Object Perform(Object obj) { if (obj != null && obj is MetadataNS.Metadata) { MetadataNS.Metadata metadata = (MetadataNS.Metadata)obj; String name = GetReturnObjectName(); /* Metadata linkedMetadata = metadata.GetLinkedMetadata(name); * if (linkedMetadata == null) * { * if (metadata.MetaMetadata is MetaMetadata) * { * MetaMetadata thisMmd = (MetaMetadata) metadata.MetaMetadata; * LinkWith linkWith = thisMmd.LinkWiths.Get(name); * MetaMetadata linkedMmd = sessionScope.getMetaMetadataRepository().getMMByName(name); * if (linkedMmd != null) * { * String id = linkWith.getById(); * ParsedURL purl = linkedMmd.generateUrl(id, metadata.getNaturalIdValue(id)); * // the generated purl may not be associated with linkedMmd! e.g. linkedMmd is a * // citeseerx_summary, while generated purl is a citeseerx search. * Document linkedDocument = (Document) sessionScope.getOrConstructDocument(purl); * * linkedDocument.setSemanticsSessionScope(sessionScope); * if (linkedDocument != null) * { * linkedDocument.queueDownload(); * metadata.pendingSemanticActionHandler = semanticActionHandler; * semanticActionHandler.requestWaiting = true; * } * } * } * } * return linkedMetadata;*/ } return(null); }
public void TakeSemanticOperations(MetaMetadata metaMetadata, Metadata metadata, List <SemanticOperation> semanticActions) { if (semanticActions == null) { Debug.WriteLine("warning: no semantic actions exist"); return; } if (requestWaiting) { requestWaiting = false; } else { this.metaMetadata = metaMetadata; this.metadata = metadata; //FIXME -- should not have SemanticOperationsKeyWords && SemanticOperationsNamedArguments as separate sets !!! semanticOperationVariableMap.Put(DocumentType, documentParser); semanticOperationVariableMap.Put(SemanticOperationKeyWords.Metadata, metadata); //edit semanticOperationVariableMap.Add(TRUE_PURL, documentParser.getTruePURL()); PreSemanticOperationsHook(metadata); } for (int i = 0; i < semanticActions.Count; i++) { SemanticOperation action = semanticActions[i]; HandleSemanticOperation(action, documentParser, semanticsScope); if (requestWaiting) { return; } } PostSemanticOperationsHook(metadata); Recycle(); }
public Document GetOrCreateDocument(DocumentParser documentParser /*, LinkType linkType*/) { Document result = (Document)GetArgumentObject(SemanticOperationNamedArguments.Document); // get the ancestor container Document sourceDocument = ResolveSourceDocument(); // get the seed. Non null only for search types . //Seed seed = documentParser.getSeed(); if (result == null) { Object outlinkPurlObject = GetArgumentObject(SemanticOperationNamedArguments.Location); if (outlinkPurlObject != null) { ParsedUri outlinkPurl = ((MetadataParsedURL)outlinkPurlObject).Value; //result = sessionScope.GetOrConstructDocument(outlinkPurl); } } if (result == null) { result = sourceDocument; //direct binding?! } if (result != null /*&& !result.IsRecycled()*/ && (result.Location != null)) { result.SemanticsSessionScope = (SemanticsSessionScope)sessionScope; MetadataNS.Metadata mixin = (MetadataNS.Metadata)GetArgumentObject(SemanticOperationNamedArguments.Mixin); if (mixin != null) { result.AddMixin(mixin); } /* if (seed != null) * { * seed.bindToDocument(result); * } */ MetadataString anchorText = (MetadataString)GetArgumentObject(SemanticOperationNamedArguments.AnchorText); // create anchor text from Document title if there is none passed in directly, and we won't // be setting metadata // if (anchorText == null) // anchorText = result.Title; // work to avoid honey pots! MetadataString anchorContextString = (MetadataString)GetArgumentObject(SemanticOperationNamedArguments.AnchorContext); bool citationSignificance = GetArgumentBoolean(SemanticOperationNamedArguments.CitationSignificance, false); float significanceVal = GetArgumentFloat(SemanticOperationNamedArguments.SignificanceValue, 1); bool traversable = GetArgumentBoolean(SemanticOperationNamedArguments.Traversable, true); bool ignoreContextForTv = GetArgumentBoolean(SemanticOperationNamedArguments.IgnoreContextForTv, false); ParsedUri location = result.Location.Value; /* if (traversable) * { * Seeding seeding = sessionScope.getSeeding(); * if (seeding != null) * seeding.traversable(location); * } * bool anchorIsInSource = false; * if (sourceDocument != null) * { * // Chain the significance from the ancestor * SemanticInLinks sourceInLinks = sourceDocument.getSemanticInlinks(); * if (sourceInLinks != null) * { * significanceVal *= sourceInLinks.meanSignificance(); * anchorIsInSource = sourceInLinks.containsKey(location); * } * } * if(! anchorIsInSource) * { * //By default use the boost, unless explicitly stated in this site's MMD * SemanticsSite site = result.GetSite; * boolean useSemanticBoost = !site.ignoreSemanticBoost(); * if (citationSignificance) * linkType = LinkType.CITATION_SEMANTIC_ACTION; * else if (useSemanticBoost && linkType == LinkType.OTHER_SEMANTIC_ACTION) * linkType = LinkType.SITE_BOOSTED_SEMANTIC_ACTION; * SemanticAnchor semanticAnchor = new SemanticAnchor(linkType, location, null, * sourceDocument.getLocation(), significanceVal);// this is not fromContentBody, * // but is fromSemanticActions * if(ignoreContextForTv) * semanticAnchor.addAnchorContextToTV(anchorText, null); * else * semanticAnchor.addAnchorContextToTV(anchorText, anchorContextString); * result.addSemanticInlink(semanticAnchor, sourceDocument); * } * else * { * Console.WriteLine("Ignoring inlink, because ancestor contains the same, we don't want cycles in the graph just yet: sourceContainer -- outlinkPurl :: " + sourceDocument + " -- " + location); * }*/ } // adding the return value to map Scope <Object> semanticActionVariableMap = SemanticOperationHandler.SemanticOperationVariableMap; if (semanticActionVariableMap != null) { if (GetReturnObjectName() != null) { semanticActionVariableMap.Put(GetReturnObjectName(), result); } } else { Debug.WriteLine("semanticActionVariableMap is null !! Not frequently reproducible either. Place a breakpoint here to try fixing it next time."); } // set flags if any // setFlagIfAny(action, localContainer); // return the value. Right now no need for it. Later it might be used. return(result); }
public void deserializationPostHook(MetadataNS.Metadata deserializedMetadata, MetadataFieldDescriptor mfd) { currentMMstack.Pop(); }
public void PostSemanticOperationsHook(MetadataNS.Metadata metadata) { }