// END HERZUM SPRINT 1.0 /// <summary> /// Attempts to create the primitive component. Component is created only if definition is a ComponentMetadataDefinition. /// Otherwise method returns false, and null node. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition which component is created based on.</param> /// <param name="data">The data containing position of new vertex</param> /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a ComponentMetadataDefinition</param> /// <returns> /// true if metadatadefinition was a ComponentMetadataDefinition and node has been created, otherwise false /// </returns> private static bool TryCreateComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; ComponentMetadataDefinition componentMetadataDefinition = metadataDefinition as ComponentMetadataDefinition; if (componentMetadataDefinition != null) { data.Metadata = new ComponentMetadata(componentMetadataDefinition, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath)); string componentNodeId = Guid.NewGuid().ToString(); newCreatedNode = new ComponentNode(componentNodeId, data); experiment.AddVertex(newCreatedNode); //set the log settings of the new component experiment.SetLogLevelSettings(newCreatedNode); isCreated = true; } return(isCreated); }
// HERZUM SPRINT 1.0 private static bool TryCreateComment(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; CommentMetadataDefinition commentMetadataDefinition = metadataDefinition as CommentMetadataDefinition; if (commentMetadataDefinition != null) { data.Metadata = new CommentMetadata(commentMetadataDefinition.Label); string commentNodeId = Guid.NewGuid().ToString(); // HERZUM SPRINT 1.2 COMMENT // newCreatedNode = new CommentNode(commentNodeId, data); var data_with_size = new SerializedVertexDataWithSize(); data_with_size.X = data.X; data_with_size.Y = data.Y; data_with_size.Metadata = data.Metadata; data_with_size.Width = 160; data_with_size.Height = 160; data_with_size.WidgetStatus = "normal"; newCreatedNode = new CommentNode(commentNodeId, data_with_size); // END SPRINT 1.2 COMMENT experiment.AddVertex(newCreatedNode); //set the log settings of the new component experiment.SetLogLevelSettings(newCreatedNode); isCreated = true; } return(isCreated); }
public virtual void Initialize(IList <MetadataBase> metabaseProviders) { Logger.Debug("Initializing metabases. Count {0}", metabaseProviders.Count); _metadataProviders = metabaseProviders; var currentNotifiers = All(); foreach (var notificationProvider in metabaseProviders) { MetadataBase metadataProviderLocal = notificationProvider; if (!currentNotifiers.Exists(c => c.MetadataProviderType == metadataProviderLocal.GetType().ToString())) { var settings = new MetadataDefinition { Enable = false, MetadataProviderType = metadataProviderLocal.GetType().ToString(), Name = metadataProviderLocal.Name }; SaveSettings(settings); } } }
private void PopulateInheritance(MetadataDefinition metadataTypeDefinition) { var derivedTypeDefinition = metadataTypeDefinition.Type; var interfaceImplHandles = derivedTypeDefinition.GetInterfaceImplementations(); if (derivedTypeDefinition.BaseType.IsNil && interfaceImplHandles.Count == 0) { return; } var derivedTypeSimpleName = metadataTypeDefinition.Name; PopulateInheritance(derivedTypeSimpleName, derivedTypeDefinition.BaseType); foreach (var interfaceImplHandle in interfaceImplHandles) { if (!interfaceImplHandle.IsNil) { var interfaceImpl = _metadataReader.GetInterfaceImplementation(interfaceImplHandle); PopulateInheritance(derivedTypeSimpleName, interfaceImpl.Interface); } } }
public MetadataFormatValidationError(urakawa.metadata.Metadata target, MetadataDefinition definition, IEventAggregator eventAggregator) : base(target, definition, eventAggregator) { }
public AbstractMetadataValidationError(MetadataDefinition definition, IEventAggregator eventAggregator) { Definition = definition; m_EventAggregator = eventAggregator; }
private void UpdateSelection() { MetadataDefinition mdDef = (MetadataDefinition)comboBoxName.SelectedItem; //MetadataDefinition mdDef = (MetadataDefinition)listBoxMdValues.SelectedItem; if (mdDef != null) { listBoxMdValues.Items.Clear(); UpdateRichTextBoxValue("", true); if (mdDef.ValueList != null && mdDef.ValueList.Count > 0) { foreach (string mdValue in mdDef.ValueList) { if (!string.IsNullOrEmpty(mdValue)) { listBoxMdValues.Items.Add(mdValue); } } if (_SelectedMetadataDef == null) { if (listBoxMdValues.Items.Count > 0) { listBoxMdValues.SelectedIndex = 0; } } else { listBoxMdValues.SelectedIndex = -1; } } if (listBoxMdValues.Items.Count > 0) { buttonAddMdValue.Enabled = true; } else { buttonAddMdValue.Enabled = false; } if (mdDef.CanEditName) { comboBoxName.DropDownStyle = ComboBoxStyle.DropDown; } else { comboBoxName.DropDownStyle = ComboBoxStyle.DropDownList; } if (mdDef.CanEditValue) { richTextBoxMetadataData.Enabled = true; btnAddMetadataBrowse.Enabled = true; } else { richTextBoxMetadataData.Enabled = false; btnAddMetadataBrowse.Enabled = false; } textBoxDescription.Text = mdDef.Description; UpdateRichTextBoxValue(listBoxMdValues.Text); } }
private void transformBook() { //FileInfo DTBFilePathInfo = new FileInfo(m_Book_FilePath); //switch (DTBFilePathInfo.Extension) int indexOfDot = m_Book_FilePath.LastIndexOf('.'); if (indexOfDot < 0 || indexOfDot == m_Book_FilePath.Length - 1) { return; } string fileExt = m_Book_FilePath.Substring(indexOfDot).ToLower(); switch (fileExt) { case ".opf": { XmlDocument opfXmlDoc = readXmlDocument(m_Book_FilePath); parseOpf(opfXmlDoc); break; } case ".xml": { XmlDocument contentXmlDoc = readXmlDocument(m_Book_FilePath); parseMetadata(contentXmlDoc); parseContentDocument(contentXmlDoc, null, m_Book_FilePath); break; } case ".epub": { unzipEPubAndParseOpf(); break; } default: break; } if (!String.IsNullOrEmpty(m_PublicationUniqueIdentifier)) { Metadata meta = addMetadata("dc:Identifier", m_PublicationUniqueIdentifier, m_PublicationUniqueIdentifierNode); meta.IsMarkedAsPrimaryIdentifier = true; } //if no unique publication identifier could be determined, see how many identifiers there are //if there is only one, then make that the unique publication identifier //this code assumes that all metadata parsing has been completed, which seems to be the case //at the moment. however, should additional documents start getting parsed for metadata, //then this code should be moved to a spot after that parsing has finished. else { if (m_Project.Presentations.Count > 0) { List <Metadata> identifiers = new List <Metadata>(); foreach (Metadata md in m_Project.Presentations.Get(0).Metadatas.ContentsAs_YieldEnumerable) { //get this metadata's definition (and search synonyms too) MetadataDefinition definition = SupportedMetadata_Z39862005.DefinitionSet.GetMetadataDefinition( md.NameContentAttribute.Name, true); //if this is a dc:identifier, then add it to our list if (definition.Name == "dc:Identifier") { identifiers.Add(md); } } //if there is only one identifier, then make it the publication UID if (identifiers.Count == 1) { identifiers[0].IsMarkedAsPrimaryIdentifier = true; } } } }
private static void LookupMetadataDefinitions( MetadataReader reader, MetadataDefinition definition, OrderPreservingMultiDictionary<string, MetadataDefinition> definitionMap) { switch (definition.Kind) { case MetadataDefinitionKind.Namespace: LookupMetadataDefinitions(reader, definition.Namespace, definitionMap); break; case MetadataDefinitionKind.Type: LookupMetadataDefinitions(reader, definition.Type, definitionMap); break; } }
public ComponentsLibraryNode(String label, MetadataDefinition data = null) { Label = label; Data = data; }
private void ensureCorrectMetadataIdentifier(string book_FilePath, Project project) { Presentation presentation = project.Presentations.Get(0); string name = presentation.RootNode.GetXmlElementLocalName(); bool isEPUB = @"body".Equals(name, StringComparison.OrdinalIgnoreCase) || @"spine".Equals(name, StringComparison.OrdinalIgnoreCase); if (!String.IsNullOrEmpty(m_PublicationUniqueIdentifier)) { string id = SupportedMetadata_Z39862005.DC_Identifier; if (isEPUB) { id = id.ToLower(); } Metadata meta = addMetadata(book_FilePath, project, id, m_PublicationUniqueIdentifier, m_PublicationUniqueIdentifierNode); meta.IsMarkedAsPrimaryIdentifier = true; } //if no unique publication identifier could be determined, see how many identifiers there are //if there is only one, then make that the unique publication identifier else { if (!isEPUB) { List <Metadata> identifiers = new List <Metadata>(); foreach (Metadata md in project.Presentations.Get(0).Metadatas.ContentsAs_Enumerable) { //get this metadata's definition (and search synonyms too) MetadataDefinition definition = SupportedMetadata_Z39862005.DefinitionSet.GetMetadataDefinition( md.NameContentAttribute.Name, true); //if this is a dc:identifier, then add it to our list if (SupportedMetadata_Z39862005.DC_Identifier.Equals(definition.Name, StringComparison.OrdinalIgnoreCase)) { identifiers.Add(md); } } //if there is only one identifier, then make it the publication UID if (identifiers.Count == 1) { identifiers[0].IsMarkedAsPrimaryIdentifier = true; //if dtb:uid is our only identifier, rename it dc:identifier /*if (identifiers[0].NameContentAttribute.Name == "dtb:uid") * identifiers[0].NameContentAttribute.Name = "dc:Identifier";*/ } } else { List <Metadata> identifiers = new List <Metadata>(); foreach (Metadata md in presentation.Metadatas.ContentsAs_Enumerable) { if (SupportedMetadata_Z39862005.DC_Identifier.Equals(md.NameContentAttribute.Name, StringComparison.OrdinalIgnoreCase)) { identifiers.Add(md); } } if (identifiers.Count == 0) { // NOP return; } else if (identifiers.Count == 1) { if (identifiers[0].IsMarkedAsPrimaryIdentifier) { return; } identifiers[0].IsMarkedAsPrimaryIdentifier = true; return; } else if (identifiers.Count > 1) { foreach (Metadata md in identifiers) { if (md.IsMarkedAsPrimaryIdentifier) { return; } } foreach (Metadata md in identifiers) { Metadata toMark = null; foreach (MetadataAttribute metadataAttribute in md.OtherAttributes.ContentsAs_Enumerable) { if (@"id".Equals(metadataAttribute.Name, StringComparison.OrdinalIgnoreCase) || @"xml:id".Equals(metadataAttribute.Name, StringComparison.OrdinalIgnoreCase)) { toMark = md; break; } } if (toMark != null) { toMark.IsMarkedAsPrimaryIdentifier = true; return; } } } #if DEBUG Debugger.Break(); #endif } } }
private bool _validateAsSet() //IEnumerable<urakawa.metadata.Metadata> metadatas) { bool isValid = true; //make sure all the required items are there foreach (MetadataDefinition metadataDefinition in MetadataDefinitions.Definitions) { if (!metadataDefinition.IsReadOnly && metadataDefinition.Occurrence == MetadataOccurrence.Required) { //string name = metadataDefinition.Name.ToLower(); bool found = false; foreach (urakawa.metadata.Metadata item in m_Session.DocumentProject.Presentations.Get(0).Metadatas.ContentsAs_Enumerable) { if (item.NameContentAttribute.Name.Equals(metadataDefinition.Name, StringComparison.Ordinal)) //OrdinalIgnoreCase { found = true; break; } } if (!found) { MetadataMissingItemValidationError err = new MetadataMissingItemValidationError(metadataDefinition, m_EventAggregator); ReportError(err); isValid = false; } } } //make sure repetitions are ok List <urakawa.metadata.Metadata> list = new List <urakawa.metadata.Metadata>(); foreach (urakawa.metadata.Metadata metadata in m_Session.DocumentProject.Presentations.Get(0).Metadatas.ContentsAs_Enumerable) { MetadataDefinition metadataDefinition = MetadataDefinitions.GetMetadataDefinition(metadata.NameContentAttribute.Name); if (metadataDefinition != null && !metadataDefinition.IsRepeatable) { //string name = metadata.NameContentAttribute.Name.ToLower(); list.Clear(); foreach (urakawa.metadata.Metadata item in m_Session.DocumentProject.Presentations.Get(0).Metadatas.ContentsAs_Enumerable) { if (item.NameContentAttribute.Name.Equals(metadata.NameContentAttribute.Name, StringComparison.Ordinal)) //OrdinalIgnoreCase { list.Add(item); } } if (list.Count > 1) { isValid = false; foreach (urakawa.metadata.Metadata item in list) { MetadataDuplicateItemValidationError err = new MetadataDuplicateItemValidationError(item, metadataDefinition, m_EventAggregator); ReportError(err); } } } } return(isValid); }
public void SaveMetadataTest() { var client = ClientFactory.GetSdkClient(); //Yuck! Metadata handling is ugly so far. //create or find the metadata definition that you want to store //here we create the one we need if it isn't found var template = new MetadataDefinition { MetadataDefinitionType = MetadataDefinitionTypes.User, Name = "Test", MetadataType = MetadataTypes.String }; var mds = client.CreateChannel <IMetadataDefinitionService>(); //first find all metadata definitions of the same def type and type as the one requested and that matches the name. var definition = mds.Find(new MetadataDefinitionQuery { Filter = { MetadataDefinitionType = template.MetadataDefinitionType, MetadataType = template.MetadataType } }).FirstOrDefault(d => d.Name == template.Name); if (definition == null) { //if no match was found, create the template instead var id = mds.Save(template); definition = template; definition.Id = id; } //create the metadata itself by setting the id of the definition and the value (important to create a metadata of //the same sort as the defined MetadataType. var m = new MetadataString { MetadataDefinitionId = definition.Id, StringValue = "test value" }; //get the media item to which we should attach the metadata to. (We inlcude all user metadata) var mi = client.Query <MediaItem>() .Include(x => x.Metadata.Where(md => md.DefinitionType == MetadataDefinitionTypes.User)) .Take(1).FirstOrDefault(); //when we save the metadata we only want to modify the new one //when we clear the metadata, this will not clear the metadata stored in the db only for this copy mi.Metadata.Clear(); //add the new/modified metadata mi.Metadata.Add(m); var ms = client.CreateChannel <IMediaService>(); //supply the Metadata save option flag to indicate that medatata should be saved as well. //as stated above, we cannot delete any metadata. Any metadata passed to the save function will only //be added/modified for now. ms.Save(new List <MediaItem> { mi }, MediaServiceSaveOptions.Metadata); }
/// <summary> /// Adds a new component at the specified coordinates /// </summary> /// <exception cref="System.ArgumentNullException">Thrown if the component definition is null</exception> public ExperimentNode AddComponentFromDefinition(MetadataDefinition metadataDefinition, double positionX, double positionY) { ExperimentNode newNode = ComponentFactory.AddComponentFromDefinitionToExperiment(this, metadataDefinition, positionX, positionY); return(newNode); }
public Node(String label, MetadataDefinition data = null) { Label = label; Data = data; }
public void SaveMetadataTest() { var client = ClientFactory.GetSdkClient(); //Yuck! Metadata handling is ugly so far. //create or find the metadata definition that you want to store //here we create the one we need if it isn't found var template = new MetadataDefinition { MetadataDefinitionType = MetadataDefinitionTypes.User, Name = "Test", MetadataType = MetadataTypes.String }; var mds = client.CreateChannel<IMetadataDefinitionService>(); //first find all metadata definitions of the same def type and type as the one requested and that matches the name. var definition = mds.Find(new MetadataDefinitionQuery { Filter = { MetadataDefinitionType = template.MetadataDefinitionType, MetadataType = template.MetadataType } }).FirstOrDefault(d => d.Name == template.Name); if (definition == null) { //if no match was found, create the template instead var id = mds.Save(template); definition = template; definition.Id = id; } //create the metadata itself by setting the id of the definition and the value (important to create a metadata of //the same sort as the defined MetadataType. var m = new MetadataString { MetadataDefinitionId = definition.Id, StringValue = "test value" }; //get the media item to which we should attach the metadata to. (We inlcude all user metadata) var mi = client.Query<MediaItem>() .Include(x => x.Metadata.Where(md => md.DefinitionType == MetadataDefinitionTypes.User)) .Take(1).FirstOrDefault(); //when we save the metadata we only want to modify the new one //when we clear the metadata, this will not clear the metadata stored in the db only for this copy mi.Metadata.Clear(); //add the new/modified metadata mi.Metadata.Add(m); var ms = client.CreateChannel<IMediaService>(); //supply the Metadata save option flag to indicate that medatata should be saved as well. //as stated above, we cannot delete any metadata. Any metadata passed to the save function will only //be added/modified for now. ms.Save(new List<MediaItem> { mi }, MediaServiceSaveOptions.Metadata); }
private bool _validateDate(urakawa.metadata.Metadata metadata, MetadataDefinition definition) { MetadataFormatValidationError err = new MetadataFormatValidationError(metadata, definition, m_EventAggregator); err.Hint = m_DateHint; string date = metadata.NameContentAttribute.Value; //Require at least the year field //The max length of the entire datestring is 10 if (date.Length < 4 || date.Length > 10) { m_ParentValidator.ReportError(err); return(false); } string[] dateArray = date.Split('-'); //the year has to be 4 digits if (dateArray[0].Length != 4) { m_ParentValidator.ReportError(err); return(false); } //the year has to be digits try { int year = Convert.ToInt32(dateArray[0]); } catch { m_ParentValidator.ReportError(err); return(false); } //check for a month value (it's optional) if (dateArray.Length >= 2) { //the month has to be numeric int month = 0; try { month = Convert.ToInt32(dateArray[1]); } catch { m_ParentValidator.ReportError(err); return(false); } //the month has to be in this range if (month < 1 || month > 12) { m_ParentValidator.ReportError(err); return(false); } } //check for a day value (it's optional but only if a month is specified) if (dateArray.Length == 3) { //the day has to be a number int day = 0; try { day = Convert.ToInt32(dateArray[2]); } catch { m_ParentValidator.ReportError(err); return(false); } //it has to be in this range if (day < 1 || day > 31) { m_ParentValidator.ReportError(err); return(false); } } return(true); }
private void PopulateInheritance(MetadataDefinition metadataTypeDefinition) { var derivedTypeDefinition = metadataTypeDefinition.Type; var interfaceImplHandles = derivedTypeDefinition.GetInterfaceImplementations(); if (derivedTypeDefinition.BaseType.IsNil && interfaceImplHandles.Count == 0) { return; } var derivedTypeSimpleName = metadataTypeDefinition.Name; PopulateInheritance(derivedTypeSimpleName, derivedTypeDefinition.BaseType); foreach (var interfaceImplHandle in interfaceImplHandles) { if (!interfaceImplHandle.IsNil) { var interfaceImpl = _metadataReader.GetInterfaceImplementation(interfaceImplHandle); PopulateInheritance(derivedTypeSimpleName, interfaceImpl.Interface); } } }
static SupportedMetadata_Z39862005() { MATHML_XSLT_METADATA = FileDataProvider.EliminateForbiddenFileNameCharacters(MATHML_XSLT_METADATA); m_IdentifierSynonyms = new List <string>(); m_IdentifierSynonyms.Add(DTB_UID); m_TitleSynonyms = new List <string>(); m_TitleSynonyms.Add(DTB_TITLE); m_UnrecognizedItem = new MetadataDefinition( "", MetadataDataType.String, MetadataOccurrence.Optional, false, true, UrakawaSDK_core_Lang.Metadata_desc_unrecognized, null); m_MetadataDefinitions = new List <MetadataDefinition>(); m_MetadataDefinitions.Add(new MetadataDefinition( DC_Date, MetadataDataType.Date, MetadataOccurrence.Required, false, true, UrakawaSDK_core_Lang.Metadata_desc_dcDate, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DC_Title, MetadataDataType.String, MetadataOccurrence.Required, false, true, UrakawaSDK_core_Lang.Metadata_desc_dcTitle, new List <string>(m_TitleSynonyms))); m_MetadataDefinitions.Add(new MetadataDefinition( DC_Publisher, MetadataDataType.String, MetadataOccurrence.Required, false, true, UrakawaSDK_core_Lang.Metadata_desc_dcPublisher, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DC_Language, MetadataDataType.LanguageCode, MetadataOccurrence.Required, false, true, UrakawaSDK_core_Lang.Metadata_desc_dcLanguage, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DC_Identifier, MetadataDataType.String, MetadataOccurrence.Required, false, true, UrakawaSDK_core_Lang.Metadata_desc_dcIdentifier, new List <string>(m_IdentifierSynonyms))); m_MetadataDefinitions.Add(new MetadataDefinition( DC_Creator, MetadataDataType.String, MetadataOccurrence.Recommended, false, true, UrakawaSDK_core_Lang.Metadata_desc_dcCreator, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DC_Subject, MetadataDataType.String, MetadataOccurrence.Recommended, false, true, UrakawaSDK_core_Lang.Metadata_desc_dcSubject, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DC_Description, MetadataDataType.String, MetadataOccurrence.Optional, false, true, UrakawaSDK_core_Lang.Metadata_desc_dcDescription, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DC_Contributor, MetadataDataType.String, MetadataOccurrence.Optional, false, true, UrakawaSDK_core_Lang.Metadata_desc_dcContributor, null)); m_MetadataDefinitions.Add(new MetadataDefinition( D_Source, MetadataDataType.String, MetadataOccurrence.Recommended, false, true, UrakawaSDK_core_Lang.Metadata_desc_dcSource, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DC_Relation, MetadataDataType.String, MetadataOccurrence.Optional, false, true, UrakawaSDK_core_Lang.Metadata_desc_dcRelation, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DC_Coverage, MetadataDataType.String, MetadataOccurrence.Optional, false, true, UrakawaSDK_core_Lang.Metadata_desc_dcCoverage, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DC_Rights, MetadataDataType.String, MetadataOccurrence.Optional, false, true, UrakawaSDK_core_Lang.Metadata_desc_dcRights, null)); //read-only: Tobi should fill them in for the user //things such as audio format might not be known until export m_MetadataDefinitions.Add(new MetadataDefinition( DC_Format, MetadataDataType.String, MetadataOccurrence.Required, true, true, UrakawaSDK_core_Lang.Metadata_desc_dcFormat, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DC_Type, MetadataDataType.String, MetadataOccurrence.Optional, true, true, UrakawaSDK_core_Lang.Metadata_desc_dcType, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DTB_SOURCE_DATE, MetadataDataType.Date, MetadataOccurrence.Recommended, false, false, UrakawaSDK_core_Lang.Metadata_desc_dtbSourceDate, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DTB_PRODUCED_DATE, MetadataDataType.Date, MetadataOccurrence.Optional, false, false, UrakawaSDK_core_Lang.Metadata_desc_dtbProducedDate, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DTB_REVISION_DATE, MetadataDataType.Date, MetadataOccurrence.Optional, false, false, UrakawaSDK_core_Lang.Metadata_desc_dtbRevisionDate, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DTB_SOURCE_EDITION, MetadataDataType.String, MetadataOccurrence.Recommended, false, false, UrakawaSDK_core_Lang.Metadata_desc_dtbSourceEdition, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DTB_SOURCE_PUBLISHER, MetadataDataType.String, MetadataOccurrence.Recommended, false, false, UrakawaSDK_core_Lang.Metadata_desc_dtbSourcePublisher, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DTB_SOURCE_RIGHTS, MetadataDataType.String, MetadataOccurrence.Recommended, false, false, UrakawaSDK_core_Lang.Metadata_desc_dtbSourceRights, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DTB_SOURCE_TITLE, MetadataDataType.String, MetadataOccurrence.Optional, false, false, UrakawaSDK_core_Lang.Metadata_desc_dtbSourceTitle, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DTB_NARRATOR, MetadataDataType.String, MetadataOccurrence.Recommended, false, true, UrakawaSDK_core_Lang.Metadata_desc_dtbNarrator, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DTB_PRODUCER, MetadataDataType.String, MetadataOccurrence.Optional, false, true, UrakawaSDK_core_Lang.Metadata_desc_dtbProducer, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DTB_REVISION_DESCRIPTION, MetadataDataType.String, MetadataOccurrence.Optional, false, false, UrakawaSDK_core_Lang.Metadata_desc_dtbRevisionDescription, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DTB_REVISION, MetadataDataType.Number, MetadataOccurrence.Optional, false, false, UrakawaSDK_core_Lang.Metadata_desc_dtbRevision, null)); //from mathML m_MetadataDefinitions.Add(new MetadataDefinition( _z39_86_extension_version, MetadataDataType.Number, MetadataOccurrence.Optional, false, false, UrakawaSDK_core_Lang.Metadata_desc_z3986ExtensionVersion, null)); m_MetadataDefinitions.Add(new MetadataDefinition( MATHML_XSLT_METADATA, MetadataDataType.FileUri, MetadataOccurrence.Optional, false, false, UrakawaSDK_core_Lang.Metadata_desc_dtbookXsltFallback, null)); //audioOnly, audioNCX, audioPartText, audioFullText, textPartAudio, textNCX m_MetadataDefinitions.Add(new MetadataDefinition( DTB_MULTIMEDIA_TYPE, MetadataDataType.String, MetadataOccurrence.Required, true, false, UrakawaSDK_core_Lang.Metadata_desc_dtbMultimediaType, null)); //audio, text, and image m_MetadataDefinitions.Add(new MetadataDefinition( DTB_MULTIMEDIA_CONTENT, MetadataDataType.String, MetadataOccurrence.Required, true, false, UrakawaSDK_core_Lang.Metadata_desc_dtbMultimediaContent, null)); m_MetadataDefinitions.Add(new MetadataDefinition( DTB_TOTAL_TIME, MetadataDataType.ClockValue, MetadataOccurrence.Required, true, false, UrakawaSDK_core_Lang.Metadata_desc_dtbTotalTime, null)); //MP4-AAC, MP3, WAV m_MetadataDefinitions.Add(new MetadataDefinition( DTB_AUDIO_FORMAT, MetadataDataType.String, MetadataOccurrence.Recommended, true, true, UrakawaSDK_core_Lang.Metadata_desc_dtbAudioFormat, null)); DefinitionSet = new MetadataDefinitionSet(); DefinitionSet.UnrecognizedItemFallbackDefinition = m_UnrecognizedItem; DefinitionSet.Definitions = m_MetadataDefinitions; }
private bool _validateClockValue(urakawa.metadata.Metadata metadata, MetadataDefinition definition) { return(true); }
/// <summary> /// Attempts to create the composite component. Component is created only if definition is a DecisionMetadataDefinition. /// Otherwise method returns false, and null node. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition which component is created based on.</param> /// <param name="data">The data containing position of new vertex</param> /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a DecisionMetadataDefinition</param> /// <returns> /// true if metadatadefinition was a DecisionMetadataDefinition and node has been created, otherwise false /// </returns> private static bool TryCreateDecisionComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; DecisionMetadataDefinition decisionMetadataDefinition = metadataDefinition as DecisionMetadataDefinition; if (decisionMetadataDefinition != null) { newCreatedNode = CreateDecisionComponent(experiment, decisionMetadataDefinition, data); isCreated = true; } return(isCreated); }
private bool _validateString(urakawa.metadata.Metadata metadata, MetadataDefinition definition) { return(true); }
/// <summary> /// Adds the component from definition to experiment. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition that defines newly added component.</param> /// <param name="positionX">The position X at where new component is added</param> /// <param name="positionY">The position Y at where new comopnent is added</param> /// <returns>The newly constucted node</returns> public static ExperimentNode AddComponentFromDefinitionToExperiment(IEditableExperiment experiment, MetadataDefinition metadataDefinition, double positionX, double positionY) { if (metadataDefinition == null) { throw new ArgumentNullException("metadataDefinition"); } ExperimentNode newNode = null; SerializedVertexData data = new SerializedVertexData(); data.X = positionX; data.Y = positionY; // case 1. Primitive Component bool isCreated = TryCreateComponent(experiment, metadataDefinition, data, out newNode); // case 2. Composite Component if (!isCreated) { isCreated = TryCreateCompositeComponent(experiment, metadataDefinition, data, out newNode); } // case 3. Decision if (!isCreated) { isCreated = TryCreateDecisionComponent(experiment, metadataDefinition, data, out newNode); } // case 4. Loop if (!isCreated) { isCreated = TryCreateLoopComponent(experiment, metadataDefinition, data, out newNode); } // HERZUM SPRINT 0.0 // case 5. Scope if (!isCreated) { isCreated = TryCreateScopeComponent(experiment, metadataDefinition, data, out newNode); } // END HERZUM 0.0 // HERZUM SPRINT 1.0 if (!isCreated) { isCreated = TryCreateComment(experiment, metadataDefinition, data, out newNode); } // END HERZUM SPRINT 1.0 // HERZUM SPRINT 2.0: TLAB-65 // case 5. Challenge if (!isCreated) { isCreated = TryCreateChallengeComponent(experiment, metadataDefinition, data, out newNode); } // END HERZUM SPRINT 2.0: TLAB-65 return(newNode); }
/// <summary> /// Adds a new component at the specified coordinates /// </summary> /// <param name="metadataDefinition"></param> /// <param name="positionX"></param> /// <param name="positionY"></param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">Thrown if the component definition is null</exception> public ExperimentNode AddComponentFromDefinition(MetadataDefinition metadataDefinition, double positionX, double positionY) { return(m_experiment.AddComponentFromDefinition(metadataDefinition, positionX, positionY)); }
// END HERZUM 0.0 // HERZUM SPRINT 2.0: TLAB-65 CLASS /// <summary> /// Attempts to create the composite component. Component is created only if definition is a ChallengeMetadataDefinition. /// Otherwise method returns false, and null node. /// </summary> /// <param name="experiment">The experiment to which new component is added.</param> /// <param name="metadataDefinition">The metadata definition which component is created based on.</param> /// <param name="data">The data containing position of new vertex</param> /// <param name="newCreatedNode">Output of new created node; null if metadatadefinition was not a LoopMetadataDefinition</param> /// <returns> /// true if metadatadefinition was a ChallengeMetadataDefinition and node has been created, otherwise false /// </returns> private static bool TryCreateChallengeComponent(IEditableExperiment experiment, MetadataDefinition metadataDefinition, SerializedVertexData data, out ExperimentNode newCreatedNode) { bool isCreated = false; newCreatedNode = null; ChallengeMetadataDefinition challengeMetadataDefinition = metadataDefinition as ChallengeMetadataDefinition; if (challengeMetadataDefinition != null) { newCreatedNode = CreateChallengeNode(challengeMetadataDefinition.Label, experiment, data.X, data.Y); isCreated = true; } return(isCreated); }
private static void LookupMetadataDefinitions( MetadataReader reader, TypeDefinition typeDefinition, OrderPreservingMultiDictionary<string, MetadataDefinition> definitionMap) { // Only bother looking for extension methods in static types. if ((typeDefinition.Attributes & TypeAttributes.Abstract) != 0 && (typeDefinition.Attributes & TypeAttributes.Sealed) != 0) { foreach (var child in typeDefinition.GetMethods()) { var method = reader.GetMethodDefinition(child); if ((method.Attributes & MethodAttributes.SpecialName) != 0 || (method.Attributes & MethodAttributes.RTSpecialName) != 0) { continue; } // SymbolTreeInfo is only searched for types and extension methods. // So we don't want to pull in all methods here. As a simple approximation // we just pull in methods that have attributes on them. if ((method.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Public && (method.Attributes & MethodAttributes.Static) != 0 && method.GetCustomAttributes().Count > 0) { var definition = new MetadataDefinition( MetadataDefinitionKind.Member, reader.GetString(method.Name)); definitionMap.Add(definition.Name, definition); } } } foreach (var child in typeDefinition.GetNestedTypes()) { var type = reader.GetTypeDefinition(child); // We don't include internals from metadata assemblies. It's less likely that // a project would have IVT to it and so it helps us save on memory. It also // means we can avoid loading lots and lots of obfuscated code in the case the // dll was obfuscated. if (IsPublic(type.Attributes)) { var definition = MetadataDefinition.Create(reader, type); definitionMap.Add(definition.Name, definition); } } }
public MetadataMissingItemValidationError(MetadataDefinition definition, IEventAggregator eventAggregator) : base(definition, eventAggregator) { }
/// <summary>生成映射</summary> public static void BuildMapper(MetadataDefinition tag) { var mapper = tag.Items.ToDictionary(e => e.Text.Trim(), StringComparer.OrdinalIgnoreCase); tag.Items.ForEach(e => mapper[e.Value.Trim()] = e); Mapper = mapper; }
private void AddNodeTag(MetadataDefinition component) { var node = new CLVComponentNode(component, this); node.AddTag("All Components"); }