Fetching data from PubMed RRS feed

  • Question

  • Hi!

    When I try to fetch from PUBMED in some cases I receive the following message:

    Zentity.Core.InvalidPropertyValueException: Length of property [Title] cannot be greater than 425.
       at Zentity.Core.Resource.OnTitleChanging(String value)
       at Zentity.Core.Resource.set_Title(String value)
       at ZentityDataImport.Repository.PubMedRepository.FetchDocuments(StringDictionary parameterCollection)
       at ZentityDataImport.BaseForm.ButtonFetchData_Click(Object sender, EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    I imagine that it is related to the lenght of the title.

    What is the best procedure to fix the problem? 



    Riccardo Colasanti
    Thursday, October 13, 2011 10:03 AM

All replies

  • Hi,


    Thanks for your post.


    Maximum length for diffrent properties/entitie has been defined in the Zenity.core project and it cannot be changed until and unless you are modifying the source code.


    One way of updating the same is to modify the maximum length in the Zentity.Core.MaxLengths.cs file, build the project and replace the old Zenity.Core.dll with this one in all places.


    Another way, which demands much more work but gives maximum flexibilty, is to read the maximum length from the app.config file in the MaxLengths class.But in this case the values cannot be defined as const. And also care should be taken to load all the values when the application starts else it can break the application. Not recommended.


    Another way of achieving the same (if it is not against your requirement) is to selectively remove those rows which title is more than the defined length. This can be done by placing appropriate conditions in the ButtonImportData_Click(object sender, EventArgs e) method in the ZentityDataImport.BaseForm class.


    The length restriction for different entities is defined as follows in the MaxLengths class. 


     // Association.

            internal const int AssociationName = 100;

            internal const int AssociationUri = 1024;


            //Resouce type Property

            internal const int ResourceTypePropertyName = 100;

            internal const int ResourceTypePropertyUri = 1024;

            internal const int ResourceTypePropertyDescription = 4000;


            // Predicate.

            internal const int PredicateName = 128;

            internal const int PredicateUri = 1024;


            // Property.

            internal const int PropertyName = 50;

            internal const int PropertyUri = 1024;


            // Resource.

            internal const int FileChecksum = 256;

            internal const int FileMimeType = 128;

            internal const int FileFileExtension = 128;

            internal const int Title = 425;

            internal const int Uri = 1024;


    Please let me know if this helps you in resolving your issue or of any furher issues.


    • Proposed as answer by Kalnemi Thursday, October 13, 2011 8:33 PM
    • Edited by Kalnemi Thursday, October 13, 2011 8:35 PM
    Thursday, October 13, 2011 8:33 PM
  • You might also consider adding an error handler in the import routine to truncate any titles longer than 425 to a smaller, valid value. It's probably very unusual to have a title longer than this and that is likely a rare exception.
    Friday, October 14, 2011 11:47 PM
  • The procedure worked perfectly. Now I can import smoothly  from PubMEd . Thanks.

    Monday, October 17, 2011 8:47 AM
  • If it is possible, could you give more details?


    Monday, October 17, 2011 8:53 AM
  • As per my understanding what Mike is saying can be done as follows.


    /// <summary>
            /// Handles the Click event of the ButtonImportData control.
            /// </summary>
            /// <param name="sender">The source of the event.</param>
            /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
            private void ButtonImportData_Click(object sender, EventArgs e)
                BindingSource bindingSource = this.DataGridRecords.DataSource as BindingSource;
                IEnumerable<Journal> researchDocuments = bindingSource.DataSource as IEnumerable<Journal>;
                using (ZentityContext zentityContext = new ZentityContext())
                    DateTime startTime = DateTime.Now;
                    foreach (Journal resDocument in researchDocuments)
                        if (resDocument.Title.Length > 425)
                           //Do Something to reduce the title length
                    foreach (Journal resDocument in researchDocuments)
                        foreach (File file in resDocument.Files)
                            if (file.Title.Length > 425)
                                //Do Something to reduce the title length
                                zentityContext.UploadFileContent(file, file.Uri);
                                zentityContext.UploadFileContent(file, file.Uri);
                    DateTime endTime = DateTime.Now;
                    TimeSpan elapsedTime = new TimeSpan(endTime.Ticks - startTime.Ticks);
                    this.StatusLabel.Text = string.Format("Records Imported to Zentity : {0}, Time taken for operation : {1} seconds", bindingSource.Count.ToString(), elapsedTime.TotalSeconds.ToString());
                this.DataGridRecords.DataSource = null;

    If I am wrong I would like Mike to correct it.


    Monday, October 17, 2011 11:43 AM