Top Level Namespace

Defined Under Namespace

Modules: ASConstants, ASModel, ASUtils, ASpaceCoverage, ASpaceExport, ASpaceImport, ASpaceMappings, ActiveAssociation, AgentManager, AgentNameDates, AgentNames, Agents, ApplicationHelper, AspaceFormHelper, Assessments, AuthHelpers, AutoGenerator, BulkImportMixins, ClassificationHelper, ClassificationIndexing, Classifications, CollectionManagements, ColumnDefs, ComponentTransfer, ComponentsAddChildren, CrudHelpers, CsvTemplateGenerator, CustomField, Dates, Deaccessions, DigitalObjectTrees, DigitalObjects, DirectionalRelationships, DynamicEnums, EACBaseMap, EnumerationHelper, ErrorsHelper, Events, Exceptions, ExportHelper, ExportHelpers, Extents, ExternalDocuments, ExternalIDs, FileEmbedHelper, FileVersions, HandleFaceting, I18n, Identifiers, IndexHelper, Instances, JSON, JSONModel, JSONModelI18nMixin, JSONModelPublishing, JSONModelTranslatable, JSONSchemaUtils, JobsHelper, JsonHelper, LangMaterials, ManipulateNode, MarcXMLAuthAgentBaseMap, MarcXMLBibBaseMap, MemoryLeak, MergeHelpers, MetadataRights, MixedContentParser, Notes, NotesHelper, ObjectGraph, ParallelAgentNames, PluginHelper, PrefixHelper, Publishable, RESTHelpers, RecordChildren, RecordHelper, RecordableCataloging, RegisterCustomFields, ReindexTopContainers, RelatedAgents, Relationships, ReportManager, ReportUtils, Representative, RepresentativeImages, RequestsHelper, ResolverHelper, ResourceRequestItems, ResourceTrees, RestrictionCalculator, ResultInfo, RevisionStatements, RightsRestrictionNotes, RightsStatementActs, RightsStatementExternalDocuments, RightsStatements, SearchHelper, Searchable, Sequel, SequelColumnTypes, SidebarHelper, SlugHelpers, SortNameProcessor, Subjects, Telephones, TestUtils, TouchRecords, Transferable, TreeNodes, Trees, URIResolver, UserDefineds, UsersHelper, ViewHelper, WelcomeHelper Classes: ASDate, ASFop, ASHTTP, ASpaceEnvironment, ASpaceGems, ASpaceLogger, AbstractReport, AbstractSubreport, AccessDeniedException, Accession, AccessionConverter, AccessionsController, ActiveEdit, AdvancedQueryBuilder, AdvancedQueryString, AdvancedSearch, AgentAlternateSet, AgentContact, AgentConventionsDeclaration, AgentCorporateEntity, AgentFamily, AgentFunction, AgentGender, AgentHandler, AgentIdentifier, AgentMaintenanceHistory, AgentOccupation, AgentOtherAgencyCodes, AgentPerson, AgentPlace, AgentRecordControl, AgentRecordIdentifier, AgentRelationshipAssociative, AgentRelationshipEarlierlater, AgentRelationshipFamily, AgentRelationshipHierarchical, AgentRelationshipIdentity, AgentRelationshipParentchild, AgentRelationshipSubordinatesuperior, AgentRelationshipTemporal, AgentResource, AgentSoftware, AgentSources, AgentTopic, AgentsController, AncestorListing, AnonymousUser, ApplicationController, ApplicationMailer, ArchivalObject, ArchivalObjectChildren, ArchivalObjectsController, ArchivalRecordChildren, ArchivesSpaceClient, ArchivesSpaceDynamicEnumAttribute, ArchivesSpaceIndexer, ArchivesSpaceOAIRecord, ArchivesSpaceOAIRepository, ArchivesSpaceOAIServer, ArchivesSpaceOaiProvider, ArchivesSpaceReadOnlyDynamicEnumAttribute, ArchivesSpaceResumptionToken, ArchivesSpaceSchema, ArchivesSpaceService, ArchivesSpaceSubTypeAttribute, ArchivesSpaceThreadDump, ArchivesSpaceTypeAttribute, ArchivistsToolkit, ArkName, ArkNameController, Assessment, AssessmentAttributeDefinitions, AssessmentAttributesController, AssessmentConverter, AssessmentsController, AuthenticationManager, BackendEnumSource, BackgroundJobQueue, BadParamsException, BarcodeCheck, BatchDeleteController, BatchDeleteFailed, BatchImportRunner, BatchMergeController, BulkImportController, BulkImportDisambigException, BulkImportException, BulkImportParser, BulkImportReport, BulkImportRunner, CiteController, Classification, ClassificationTerm, ClassificationTermsController, ClassificationsController, ClientEnumSource, CollectionManagement, CollectionManagementController, CollectionManagementRecordsController, ConflictException, Container, ContainerInstanceHandler, ContainerLabelsRunner, ContainerLocation, ContainerProfile, ContainerProfilesController, ContainersController, Converter, CsvReportExpander, CustomReportTemplate, CustomReportTemplatesController, CvList, CycleFinder, DB, DBAuth, DBMigrator, DCModel, DCSerializer, DCTermsFormat, DateCalculator, DateCalculatorController, Deaccession, DefaultValues, DependencySet, DigitalObject, DigitalObjectChildren, DigitalObjectComponent, DigitalObjectComponentChildren, DigitalObjectComponentsController, DigitalObjectConverter, DigitalObjectHandler, DigitalObjectsController, DigitalRecordChildren, EACConverter, EACModel, EACSerializer, EAD3Serializer, EADConverter, EADFormat, EADModel, EADSerializer, ERBNoteRenderer, EditMediator, Enumeration, EnumerationMigrationFailed, EnumerationValue, EnumerationsController, Event, EventsController, ExportsController, Extent, ExtentCalculator, ExtentCalculatorController, ExternalDocument, ExternalId, FacetFilter, FakeSolrTimeoutResponse, FileVersion, FindAndReplaceRunner, FindingAidPDF, GenerateArksRunner, GenerateSlugsRunner, GlobalRecordRepositoryLinkages, Group, GroupsController, Handler, IDLookup, IfMissingAttribute, ImpliedPublicationCalculator, ImportArchivalObjects, ImportCanceled, ImportDigitalObjects, ImportException, IndexBatch, IndexController, IndexState, IndexStateS3, IndexerCommon, IndexerCommonConfig, IndexerTiming, Instance, InstanceData, InstanceKey, InvalidUsernameException, JSONModelType, Job, JobCreatedRecord, JobFile, JobModifiedRecord, JobRunner, JobsController, LDAPAuth, LDAPException, LabelModel, LangHandler, LangMaterial, LanguageAndScript, LargeTree, LargeTreeClassification, LargeTreeDigitalObject, LargeTreeDocIndexer, LargeTreeResource, Location, LocationConverter, LocationFunction, LocationProfile, LocationProfilesController, LocationsController, Log, LoginFailedException, LongPolling, MARCAuthModel, MARCAuthSerializer, MARCFormat, MARCModel, MARCSerializer, METSModel, METSSerializer, MODSFormat, MODSModel, MODSSerializer, MarcXMLAuthAgentConverter, MarcXMLBibAccessionConverter, MarcXMLBibConverter, MergeRequestFailed, MetadataRightsDeclaration, MultipartBufferSetter, MultipartNoteRenderer, NameAuthorityId, NameCorporateEntity, NameFamily, NamePerson, NameSoftware, NestedRecordResolver, NotFoundException, Note, NoteBibliography, NoteDigitalObject, NoteIndex, NoteIndexItem, NoteLangMaterial, NoteMultipart, NoteOrderedlist, NotePersistentId, NoteRenderer, NoteSinglepart, NotesHandler, Notifications, OAIConfig, OAIDCMapper, OAIDCTermsMapper, OAIDeletion, OAIMODSMapper, OAIUtils, OaiConfigController, ObjectsController, PUIIndexer, Pager, ParallelNameCorporateEntity, ParallelNameFamily, ParallelNamePerson, ParallelNameSoftware, ParentTracker, PdfController, PeriodicIndexer, Permission, Permissions, Preference, PreferencesController, PrintToPDFRunner, ProgressTicker, RdeTemplate, RdeTemplatesController, ReadOnlyException, RealtimeIndexer, RealtimeIndexing, Record, RecordInheritance, RecordNotFound, ReferenceError, ReportGenerator, ReportRunner, RepositoriesController, Repository, RepositoryNotEmpty, RequestContext, RequestFailedException, RequestItem, RequestMailer, RequestsController, RequiredFields, Resolver, ResolverController, Resource, ResourceChildren, ResourceOrderedRecords, ResourcesController, RetryTransaction, RevisionStatement, RightsRestriction, RightsRestrictionType, RightsStatement, RightsStatementAct, RightsStatementExternalDocument, RtfGenerator, SAXXMLReader, Search, SearchController, SearchResolver, SearchResolverCompactResource, SearchResultData, Sequence, SequenceError, SequenceGenerator, Session, SessionController, SinglepartNoteRenderer, Solr, SolrResults, SolrSnapshotter, SpaceCalculator, SpaceCalculatorController, StaticAssetFinder, StopBulkImportException, StreamingImport, StreamingJsonReader, StructuredDateLabel, StructuredDateRange, StructuredDateSingle, SubContainer, Subject, SubjectHandler, SubjectsController, SubnoteMetadata, SystemEvent, SystemInfoController, Telephone, Term, TestsController, Ticker, Tombstone, TopContainer, TopContainerLinker, TopContainerLinkerRunner, TopContainerLinkerValidator, TopContainersController, TransferConstraintError, Tree, TreeDocs, TrimWhitespaceRunner, UnhandledNoteRenderer, UpdateMonitorController, UsedLanguage, User, UserDefined, UserDefinedFieldMigrator, UserNotFoundException, Username, UsersController, UtilsController, ValidatorCache, Vocabulary, WelcomeController, XMLCleaner Schemata: abstract_agent_relationship_schema, abstract_agent_schema, abstract_archival_object_schema, abstract_classification_schema, abstract_name_schema, abstract_note_schema, abstract_parallel_name_schema, accession_parts_relationship_schema, accession_schema, accession_sibling_relationship_schema, active_edits_schema, advanced_query_schema, agent_alternate_set_schema, agent_contact_schema, agent_conventions_declaration_schema, agent_corporate_entity_schema, agent_family_schema, agent_function_schema, agent_gender_schema, agent_identifier_schema, agent_maintenance_history_schema, agent_occupation_schema, agent_other_agency_codes_schema, agent_person_schema, agent_place_schema, agent_record_control_schema, agent_record_identifier_schema, agent_relationship_associative_schema, agent_relationship_earlierlater_schema, agent_relationship_family_schema, agent_relationship_hierarchical_schema, agent_relationship_identity_schema, agent_relationship_parentchild_schema, agent_relationship_subordinatesuperior_schema, agent_relationship_temporal_schema, agent_resource_schema, agent_software_schema, agent_sources_schema, agent_topic_schema, archival_object_schema, archival_record_children_schema, ark_name_schema, assessment_attribute_definitions_schema, assessment_attribute_schema, assessment_schema, boolean_field_query_schema, boolean_query_schema, bulk_import_job_schema, classification_schema, classification_term_schema, classification_tree_schema, collection_management_schema, container_conversion_job_schema, container_labels_job_schema, container_location_schema, container_profile_schema, custom_report_template_schema, date_field_query_schema, date_schema, deaccession_schema, default_values_schema, defaults_schema, digital_object_component_schema, digital_object_schema, digital_object_tree_schema, digital_record_children_schema, enumeration_migration_schema, enumeration_schema, enumeration_value_schema, event_schema, extent_schema, external_document_schema, external_id_schema, field_query_schema, file_version_schema, find_and_replace_job_schema, generate_arks_job_schema, generate_slugs_job_schema, group_schema, import_job_schema, instance_schema, job_schema, lang_material_schema, language_and_script_schema, location_batch_schema, location_batch_update_schema, location_function_schema, location_profile_schema, location_schema, merge_request_detail_schema, merge_request_schema, metadata_rights_declaration_schema, name_corporate_entity_schema, name_family_schema, name_form_schema, name_person_schema, name_software_schema, note_abstract_schema, note_agent_rights_statement_schema, note_bibliography_schema, note_bioghist_schema, note_chronology_schema, note_citation_schema, note_contact_note_schema, note_definedlist_schema, note_digital_object_schema, note_general_context_schema, note_index_item_schema, note_index_schema, note_langmaterial_schema, note_legal_status_schema, note_mandate_schema, note_multipart_schema, note_orderedlist_schema, note_outline_level_schema, note_outline_schema, note_rights_statement_act_schema, note_rights_statement_schema, note_singlepart_schema, note_structure_or_genealogy_schema, note_text_schema, oai_config_schema, parallel_name_corporate_entity_schema, parallel_name_family_schema, parallel_name_person_schema, parallel_name_software_schema, permission_schema, preference_schema, print_to_pdf_job_schema, range_query_schema, rde_template_schema, record_tree_schema, report_job_schema, repository_schema, repository_with_agent_schema, required_fields_schema, resource_ordered_records_schema, resource_schema, resource_tree_schema, revision_statement_schema, rights_restriction_schema, rights_statement_act_schema, rights_statement_external_document_schema, rights_statement_schema, structured_date_label_schema, structured_date_range_schema, structured_date_single_schema, sub_container_schema, subject_schema, telephone_schema, term_schema, top_container_linker_job_schema, top_container_schema, trim_whitespace_job_schema, used_language_schema, user_defined_schema, user_schema, vocabulary_schema

Constant Summary collapse

POSSIBLE_DATE_RANGE_A =

yes, these overlap but weight the first since the type is range

/^\d{2}(\d{2})\s?-\s?(\d{2})\s*$/
POSSIBLE_DATE_RANGE_B =
/^(\d{3}[\d\?-]{1,2})\s?-\s?(\d{3}[\d\?-]{1,2})\s*$/
NUMBERS_AND_SLASHES =
/^\s*[\d\\]+\s*$/
PROBABLE_DATE =
/^\s*\d{4}([-\s]\d{2})?([-\s][0123]?\d{1})?\s*$/
CONTAINS_PROBABLE_DATE =
/\d{4}(-\d{2})?(-\d{2})?/
PROBABLE_DATE_INLINE =
/\d{4}/
AbstractRelationship =

We’ll create a concrete instance of this class for each defined relationship.

Class.new(Sequel::Model) do
MERGEABLE_TYPES =
[
 {"type" => "JSONModel(:agent_person) uri"},
 {"type" => "JSONModel(:agent_corporate_entity) uri"},
 {"type" => "JSONModel(:agent_software) uri"},
 {"type" => "JSONModel(:agent_family) uri"},
]

Instance Method Summary collapse

Instance Method Details

#process(dx) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'convert_date_expression.rb', line 15

def process(dx)
  if dx.match?(/undated/i) || dx.match?(/bulk/i)
    return [dx, nil]
  end
  dx_orig = dx.dup
  _dx = dx.dup

  Date::MONTHNAMES.each_with_index do |name, i|
    next if name.nil?
    _dx.sub!(name, i.to_s.rjust(2, "0"))
  end

  Date::ABBR_MONTHNAMES.each_with_index do |name, i|
    next if name.nil?
    _dx.sub!("#{name}.", i.to_s.rjust(2, "0"))
    _dx.sub!(name, i.to_s.rjust(2, "0"))
  end

  dx.sub!('–', '-') if dx.split('–').size == 2
  dx.sub!('—', '-') if dx.split('—').size == 2

  if dx.match(POSSIBLE_DATE_RANGE_A) && ($1.to_i < $2.to_i)
    return [dx[0..3], (dx[0..1] + dx[-2..-1])]
  end

  if dx.match(POSSIBLE_DATE_RANGE_B)
    return [$1, $2]
  end

  if dx.split('-').size > 2 && (dx.split('-').size.modulo(2) == 0)
    a = dx.split('-')
    index = a.size / 2
    if a[0...index].join('-').match?(PROBABLE_DATE) && a[index..-1].join('-').match?(PROBABLE_DATE)
      return [a[0...index].join('-'), a[index..-1].join('-')]
    end
  end

  if _dx.split('-').size == 2 && _dx.split('-').select { |x| x.match?(PROBABLE_DATE) }.size == 2
    return dx.split('-')
  end

  if _dx.split('/').size == 2 && _dx.split('/').select { |x| x.match?(PROBABLE_DATE) }.size == 2
    return dx.split('/')
  end

  # assume anything following a comma after a date is an end date
  if dx.split(',').size == 2 && dx.split(',')[0].match?(PROBABLE_DATE) && dx.split(',')[1].match?(CONTAINS_PROBABLE_DATE) && dx.index('-').nil?
    return dx.split(',')
  end

  #assume a single dash is a range separator if between phrases each ending with a date
  if dx.split('-').size == 2
    if dx.index(',').nil? && dx.split('-').select { |x| x.match?(/\d{4}\s*$/) }.size == 2 #.size == 2 && dx.index(',').nil?
      return dx.split('-')
    elsif dx.split('-') && (dx.split('-').select { |x|
                              x.match?(/^\s?([[:alpha:]]+)(\s[0123]?\d,?)?\s\d{4}\s?$/) && (Date::MONTHNAMES.include?($1))
                            }.size == 2)
      return dx.split('-')
    elsif dx.split('-') && (dx.split('-').select { |x|
                              x.match?(/^\s?([[:alpha:]]+)\.?(\s[0123]?\d,?)?\s\d{4}\s?$/) && (Date::ABBR_MONTHNAMES.include?($1))
                            }.size == 2)
      return dx.split('-')
    end
  end

  return [dx_orig, nil]
end