public static string BuildIdentifier(Book book) { StringBuilder buf = new StringBuilder(); if (book.IsBookTypeBook || book.IsBookTypeSocietyAbstract || book.IsBookTypeReport || book.IsBookTypeOther) { //書籍、学会妙録、報告書、その他 //pp. 開始ページ-終了ページ buf.Append(BuildPageIdentifier(book)); } else if (book.IsBookTypeBookChapter) { //書籍(章など) //書籍名, 章: pp. 開始ページ-終了ページ buf.Append(BuildBookIdentifier(book)); buf.Append(BuildPageIdentifier(book)); } else if (book.IsBookTypeTreatiseWithPeerReview || book.IsBookTypeTreatiseWithoutPeerReview) { //査読付き学術論文、査読なし学術論文 //雑誌名, 巻(号): pp. 開始ページ-終了ページ buf.Append(BuildMagazineIdentifier(book)); buf.Append(BuildPageIdentifier(book)); } else if (book.IsBookTypeThesis) { //学位論文 //大学名 学部・専攻名, pp. 開始ページ-終了ページ buf.Append(BuildUniversityIdentifier(book)); buf.Append(BuildPageIdentifier(book)); } return buf.ToString(); }
public BookFieldVM(Book book, string label, string propertyName) { this.book = book; this.label = label; this.propertyInfo = book.GetType().GetProperty(propertyName); Debug.Assert(propertyInfo != null); this.v= (string)propertyInfo.GetValue(book, null); }
public static string BuildPublisher(Book book) { if (string.IsNullOrEmpty(book.Publisher) && string.IsNullOrEmpty(book.City)) { return ""; } return book.Publisher + ", " + book.City; }
public EditBookWindowVM(Book book) { if (book == null) { book = new Book() { BookTypeCode = Options.BOOK_TYPE_BOOK }; } else { book = book.DeepCopy(true); } Book = book; bookTypes = Options.BookTypes; bookFields = new ObservableCollection<BookFieldVM>(); InitBookFiels(); bookRelations = new ObservableCollection<BookRelationVM>(); }
private static string BuildUniversityIdentifier(Book book) { if (string.IsNullOrEmpty(book.UniversityName) && string.IsNullOrEmpty(book.DepartmentName)) { return ""; } return book.UniversityName + " " + book.DepartmentName + ", "; }
private static string BuildPageIdentifier(Book book) { if (string.IsNullOrEmpty(book.StartPage) && string.IsNullOrEmpty(book.EndPage)) { return ""; } return "pp. " + book.StartPage + "-" + book.EndPage; }
private static string BuildMagazineIdentifier(Book book) { if (string.IsNullOrEmpty(book.MagazineName) && string.IsNullOrEmpty(book.Volume) && string.IsNullOrEmpty(book.Number)) { return ""; } return book.MagazineName + ", " + book.Volume + "(" + book.Number + "): "; }
private static Book CreateBook(XElement citationElem) { XElement titlStmtElem = citationElem.Element(cb + TAG_TITL_STMT); if (titlStmtElem == null) { return null; } string title = (string)titlStmtElem.Element(cb + TAG_TITL); if (string.IsNullOrEmpty(title)) { return null; } Book book = new Book(); book.BookTypeCode = Options.BOOK_TYPE_TREATISE_WITH_PEER_REVIEW; book.Title = title; XElement rspStmtElem = citationElem.Element(cb + TAG_RSP_STMT); if (rspStmtElem != null) { //著者 book.Author = (string)rspStmtElem.Element(cb + TAG_AUTH_ENTY); //編者 book.Editor = (string)rspStmtElem.Element(cb + TAG_OTH_ID); } //XElement prodStmtElem = citationElem.Element(cb + TAG_PROD_STMT); //if (prodStmtElem != null) //{ // //出版社 // book.Publisher = (string)prodStmtElem.Element(cb + TAG_PRODUCER); //} XElement distStmtElem = citationElem.Element(cb + TAG_DIST_STMT); if (distStmtElem != null) { //発表日 book.AnnouncementDate = (string)distStmtElem.Element(cb + TAG_DIST_DATE); } ParseIdentifier((string)citationElem.Element(cb + TAG_BIBL_CIT), book); XElement holdingsElem = citationElem.Element(cb + TAG_HOLDINGS); if (holdingsElem != null) { book.Url = (string)holdingsElem.Attribute(ATTR_URI); } book.Summary = (string)citationElem.Element(terms + TAG_ABSTRACT); book.Language = (string)citationElem.Element(dc + TAG_LANGUAGE); ParsePublisher((string)citationElem.Element(dc + TAG_PUBLISHER), book); return book; }
private XElement CreateOtherMaterial(Book book, BookRelationType type) { XElement otherMaterial = new XElement(r + TAG_OTHER_MATERIAL, CreateIDAttribute(book.GetBookId(type)), new XAttribute(ATTR_TYPE,GetDDIBookType(book.BookTypeCode))); XElement citation = new XElement(r + TAG_CITATION, new XElement(r + TAG_TITLE, book.Title) ); otherMaterial.Add(citation); if (!string.IsNullOrEmpty(book.Author)) { citation.Add(new XElement(r + TAG_CREATOR, book.Author)); } string publisher = BuildPublisher(book); if (!string.IsNullOrEmpty(publisher)) { citation.Add(new XElement(r + TAG_PUBLISHER, publisher)); } if (!string.IsNullOrEmpty(book.Editor)) { citation.Add(new XElement(r + TAG_CONTRIBUTOR, book.Editor)); } string simpleDate = ToSimpleDate(book.AnnouncementDate); if (!string.IsNullOrEmpty(simpleDate)) { citation.Add( new XElement(r + TAG_PUBLICATION_DATE, new XElement(r + TAG_SIMPLE_DATE, simpleDate))); } if (!string.IsNullOrEmpty(book.Language)) { citation.Add(new XElement(r + TAG_LANGUAGE, book.Language)); } string identifier = BuildIdentifier(book); XElement identifierElement = null; if (!string.IsNullOrEmpty(identifier)) { identifierElement = new XElement(dc + TAG_DC_IDENTIFIER, identifier); } XElement descriptionElement = null; if (!string.IsNullOrEmpty(book.Summary)) { descriptionElement = new XElement(dc + TAG_DC_DESCRIPTION, book.Summary); } if (identifierElement != null || descriptionElement != null) { XElement dcelements = new XElement(dce + TAG_DCELEMENTS); citation.Add(dcelements); dcelements.Add(identifierElement); dcelements.Add(descriptionElement); } if (!string.IsNullOrEmpty(book.Url)) { otherMaterial.Add(new XElement(r + TAG_EXTERNAL_URL_REFERENCE, book.Url)); } foreach (BookRelation relation in book.BookRelations) { string schemeId = null; string metaDataId = relation.MetadataId; if (relation.IsBookRelationTypeAbstract) { schemeId = studyUnit.Id; metaDataId = studyUnit.Id; otherMaterial.Add(new XElement(r + TAG_RELATIONSHIP, CreateReferenceModuleID(r + TAG_RELATED_TO_REFERENCE, metaDataId, schemeId))); } else { if (relation.IsBookRelationTypeConcept) { ConceptScheme conceptScheme = studyUnit.StudyUnitModel.FindConceptSchemeByConceptId(metaDataId); schemeId = conceptScheme.Id; } else if (relation.IsBookRelationTypeQuestion) { schemeId = studyUnit.StudyUnitModel.QuestionSchemeId; } else if (relation.IsBookRelationTypeVariable) { schemeId = studyUnit.StudyUnitModel.VariableScheme.Id; } otherMaterial.Add(new XElement(r + TAG_RELATIONSHIP, CreateReferenceID(r + TAG_RELATED_TO_REFERENCE, relation.MetadataId, schemeId))); } } return otherMaterial; }
public static void ParseMagazineIdentifier(string str, Book book) { //book.MagazineName + ", " + book.Volume + "(" + book.Number + "): "; Regex regex = new Regex(@"^(.*):\s*"); Match m = regex.Match(str); if (!m.Success) { return; } List<string> elems = SplitAndTrim(m.Groups[1].Value, ','); if (elems.Count != 2) { return; } book.MagazineName = elems[0]; string rest = elems[1]; regex = new Regex(@"^(.*)\((.*)\)$"); m = regex.Match(rest); if (!m.Success) { return; } book.Volume = TrimToNull(m.Groups[1].Value); book.Number = TrimToNull(m.Groups[2].Value); }
public static void ParseIdentifier(string identifier, Book book) { if (string.IsNullOrEmpty(identifier)) { return; } if (book.IsBookTypeBook || book.IsBookTypeSocietyAbstract || book.IsBookTypeReport || book.IsBookTypeOther) { string rest = ParsePageIdentifier(identifier, book); } else if (book.IsBookTypeBookChapter) { string rest = ParsePageIdentifier(identifier, book); ParseBookIdentifier(rest, book); } else if (book.IsBookTypeTreatiseWithPeerReview || book.IsBookTypeTreatiseWithoutPeerReview) { string rest = ParsePageIdentifier(identifier, book); ParseMagazineIdentifier(rest, book); } else if (book.IsBookTypeThesis) { string rest = ParsePageIdentifier(identifier, book); ParseUniversityIdentifier(rest, book); } }
public static void ParseBookIdentifier(string str, Book book) { // return book.BookName + ", " + book.Chapter + ": "; Regex regex = new Regex(@"^(.*):\s*"); Match m = regex.Match(str); if (!m.Success) { return; } List<string> elems = SplitAndTrim(m.Groups[1].Value, ','); if (elems.Count != 2) { return; } book.BookName = elems[0]; book.Chapter = elems[1]; }
private static Book CreateBook(XElement otherMaterialElem, StudyUnit studyUnit) { string bookId = (string)otherMaterialElem.Attribute(ATTR_ID); if (bookId == null) { return null; } string type = (string)otherMaterialElem.Attribute(ATTR_TYPE); if (type == null) { return null; } XElement citationElem = otherMaterialElem.Element(r + TAG_CITATION); if (citationElem == null) { return null; } string title = (string)citationElem.Element(r + TAG_TITLE); if (title == null) { return null; } Book bookModel = new Book(); bookModel.BookTypeCode = GetBookTypeCode(type); bookModel.Id = bookId; bookModel.Title = title; bookModel.Author = (string)citationElem.Element(r + TAG_CREATOR); // PublisherとCityをセット ParsePublisher((string)citationElem.Element(r + TAG_PUBLISHER), bookModel); bookModel.Editor = (string)citationElem.Element(r + TAG_CONTRIBUTOR); bookModel.AnnouncementDate = ReadDateUnitAsString(citationElem, r + TAG_PUBLICATION_DATE); bookModel.Language = (string)citationElem.Element(r + TAG_LANGUAGE); XElement dcelements = citationElem.Element(dce + TAG_DCELEMENTS); if (dcelements != null) { bookModel.Summary = (string)dcelements.Element(dc + TAG_DC_DESCRIPTION); ParseIdentifier((string)dcelements.Element(dc + TAG_DC_IDENTIFIER), bookModel); } bookModel.Url = (string)otherMaterialElem.Element(r + TAG_EXTERNAL_URL_REFERENCE); IEnumerable<XElement> relationshipElems = otherMaterialElem.Elements(r + TAG_RELATIONSHIP); foreach (XElement relationshipElem in relationshipElems) { string id = ReadReferenceID(relationshipElem, r + TAG_RELATED_TO_REFERENCE); BookRelation relation = new BookRelation(); relation.BookRelationType = GetBookRelationType(studyUnit, id); if (relation.IsBookRelationTypeAbstract) { id = null; } relation.MetadataId = id; bookModel.BookRelations.Add(relation); } return bookModel; }
private XElement CreateRspStmt(Book book) { XElement rspStmt = new XElement(cb + TAG_RSP_STMT); //著者名 rspStmt.Add(CreateNullable(cb + TAG_AUTH_ENTY, book.Author)); //編者 if (!string.IsNullOrEmpty(book.Editor)) { XElement othId = new XElement(cb + TAG_OTH_ID, new XAttribute(ATTR_ROLE, "editor"), book.Editor); rspStmt.Add(othId); } return EmptyToNull(rspStmt); }
private XElement CreateProdStmt(Book book) { //出版社 XElement prodStmt = new XElement(cb + TAG_PROD_STMT); string publisher = BuildPublisher(book); prodStmt.Add(CreateNullable(cb + TAG_PRODUCER, publisher)); return EmptyToNull(prodStmt); }
private XElement CreateDistStmt(Book book) { //発表日 XElement distStmt = new XElement(cb + TAG_DIST_STMT); if (!string.IsNullOrEmpty(book.AnnouncementDate)) { XElement distDate = new XElement(cb + TAG_DIST_DATE, book.AnnouncementDate); distStmt.Add(distDate); } return EmptyToNull(distStmt); }
public static string ParsePageIdentifier(string str, Book book) { // return "pp. " + book.StartPage + "-" + book.EndPage; Regex regex = new Regex(@"pp\. (\d+)-(\d+)$"); Match m = regex.Match(str); if (!m.Success) { return str; } book.StartPage = m.Groups[1].Value; book.EndPage = m.Groups[2].Value; return str.Substring(0, m.Index); }
public static void ParsePublisher(string str, Book book) { if (string.IsNullOrEmpty(str)) { return; } List<string> elems = SplitAndTrim(str, ','); if (elems.Count != 2) { return; } book.Publisher = elems[0]; book.City = elems[1]; }
private static ObservableCollection<BookFieldVM> CreateBookFields(Book book) { ObservableCollection<BookFieldVM> fields = new ObservableCollection<BookFieldVM>(); BookFieldVM title = new BookFieldVM(book, Resources.Title, "Title"); BookFieldVM author = new BookFieldVM(book, Resources.Author, "Author"); BookFieldVM editor = new BookFieldVM(book, Resources.Editor, "Editor"); BookFieldVM announcementDate = new BookFieldVM(book, Resources.AnnouncementDate, "AnnouncementDate"); BookFieldVM startPage = new BookFieldVM(book, Resources.StartPage, "StartPage"); BookFieldVM endPage = new BookFieldVM(book, Resources.EndPage, "EndPage"); BookFieldVM publisher = new BookFieldVM(book, Resources.Publisher, "Publisher"); BookFieldVM city = new BookFieldVM(book, Resources.City, "City"); BookFieldVM bookName = new BookFieldVM(book, Resources.BookName, "BookName"); BookFieldVM magazineName = new BookFieldVM(book, Resources.MagazineName, "MagazineName"); BookFieldVM volume = new BookFieldVM(book, Resources.Volume, "Volume"); BookFieldVM number = new BookFieldVM(book, Resources.BookNumber, "Number"); BookFieldVM chapter = new BookFieldVM(book, Resources.Chapter, "Chapter"); BookFieldVM universityName = new BookFieldVM(book, Resources.UniversityName, "UniversityName"); BookFieldVM departmentName = new BookFieldVM(book, Resources.DepartmentName, "DepartmentName"); BookFieldVM summary = new BookFieldVM(book, Resources.Summary, "Summary"); BookFieldVM url = new BookFieldVM(book, "URL", "Url"); BookFieldVM language = new BookFieldVM(book, Resources.Language, "Language"); if (book.IsBookTypeBook) { fields.Add(title); fields.Add(author); fields.Add(editor); fields.Add(announcementDate); fields.Add(startPage); fields.Add(endPage); fields.Add(publisher); fields.Add(city); fields.Add(summary); fields.Add(url); fields.Add(language); } else if (book.IsBookTypeBookChapter) { fields.Add(title); fields.Add(author); fields.Add(editor); fields.Add(announcementDate); fields.Add(startPage); fields.Add(endPage); fields.Add(publisher); fields.Add(city); fields.Add(bookName); fields.Add(chapter); fields.Add(summary); fields.Add(url); fields.Add(language); } else if (book.IsBookTypeTreatiseWithPeerReview) { fields.Add(title); fields.Add(author); fields.Add(announcementDate); fields.Add(startPage); fields.Add(endPage); fields.Add(publisher); fields.Add(city); fields.Add(magazineName); fields.Add(volume); fields.Add(number); fields.Add(summary); fields.Add(url); fields.Add(language); } else if (book.IsBookTypeTreatiseWithoutPeerReview) { fields.Add(title); fields.Add(author); fields.Add(announcementDate); fields.Add(startPage); fields.Add(endPage); fields.Add(publisher); fields.Add(city); fields.Add(magazineName); fields.Add(volume); fields.Add(number); fields.Add(summary); fields.Add(url); fields.Add(language); } else if (book.IsBookTypeSocietyAbstract) { fields.Add(title); fields.Add(author); fields.Add(editor); fields.Add(announcementDate); fields.Add(startPage); fields.Add(endPage); fields.Add(publisher); fields.Add(city); fields.Add(summary); fields.Add(url); fields.Add(language); } else if (book.IsBookTypeReport) { fields.Add(title); fields.Add(author); fields.Add(editor); fields.Add(announcementDate); fields.Add(startPage); fields.Add(endPage); fields.Add(publisher); fields.Add(city); fields.Add(summary); fields.Add(url); fields.Add(language); } else if (book.IsBookTypeThesis) { fields.Add(title); fields.Add(author); fields.Add(announcementDate); fields.Add(startPage); fields.Add(endPage); fields.Add(universityName); fields.Add(departmentName); fields.Add(summary); fields.Add(url); fields.Add(language); } else if (book.IsBookTypeWebpage) { fields.Add(title); fields.Add(author); fields.Add(announcementDate); fields.Add(publisher); fields.Add(summary); fields.Add(url); fields.Add(language); } else if (book.IsBookTypeOther) { fields.Add(title); fields.Add(author); fields.Add(editor); fields.Add(announcementDate); fields.Add(startPage); fields.Add(endPage); fields.Add(publisher); fields.Add(city); fields.Add(summary); fields.Add(url); fields.Add(language); } return fields; }
public static void ParseUniversityIdentifier(string str, Book book) { // book.UniversityName + " " + book.DepartmentName + ", "; Regex regex = new Regex(@"^(.*),\s*"); Match m = regex.Match(str); if (!m.Success) { return; } string rest = m.Groups[1].Value; List<string> elems = SplitAndTrim(rest, ' '); if (elems.Count != 2) { return; } book.UniversityName = elems[0]; book.DepartmentName = elems[1]; }
private bool IsMatchBookType(Book book, BookRelationType type) { if (book.BookRelations.Count == 0) { return BookRelationType.Abstract == type; } foreach (BookRelation relation in book.BookRelations) { if (relation.BookRelationType == type) { return true; } } return false; }
private static string BuildBookIdentifier(Book book) { if (string.IsNullOrEmpty(book.BookName) && string.IsNullOrEmpty(book.Chapter)) { return ""; } return book.BookName + ", " + book.Chapter + ": "; }
public BookVM(Book book) { this.book = book; }
private BookVM AddOrEditBook(Book book, BookRelation relation) { EditBookWindowVM vm = new EditBookWindowVM(book) { Parent = this }; vm.Init(relation); EditBookWindow window = new EditBookWindow(vm); window.Owner = Application.Current.MainWindow; BookVM newBook = null; if (window.ShowDialog() == true) { newBook = new BookVM(vm.Book) { Parent = this }; } window.Content = null; return newBook; }