protected ImageRecordStructure(Repository repository) throws org.osid.repository.RepositoryException { try { this.id = new PID("ImageRecordStructureId"); } catch (org.osid.shared.SharedException sex) { } this.sThumbnailPartStructure = new ThumbnailPartStructure(this, repository); this.sURLPartStructure = new URLPartStructure(this, repository); this.sMediumImagePartStructure = new MediumImagePartStructure(this, repository); this.partsVector.add(this.sThumbnailPartStructure); this.partsVector.add(this.sURLPartStructure); this.partsVector.add(this.sMediumImagePartStructure); this.partsVector.add(ContributorPartStructure.getInstance()); this.partsVector.add(CoveragePartStructure.getInstance()); this.partsVector.add(CreatorPartStructure.getInstance()); this.partsVector.add(DatePartStructure.getInstance()); this.partsVector.add(DescriptionPartStructure.getInstance()); this.partsVector.add(FormatPartStructure.getInstance()); this.partsVector.add(IdentifierPartStructure.getInstance()); this.partsVector.add(LanguagePartStructure.getInstance()); this.partsVector.add(LargeImagePartStructure.getInstance()); this.partsVector.add(PublisherPartStructure.getInstance()); this.partsVector.add(RelationPartStructure.getInstance()); this.partsVector.add(RightsPartStructure.getInstance()); this.partsVector.add(SourcePartStructure.getInstance()); this.partsVector.add(SubjectPartStructure.getInstance()); this.partsVector.add(TitlePartStructure.getInstance()); this.partsVector.add(TypePartStructure.getInstance()); }
protected Part( org.osid.shared.Id partStructureId, java.io.Serializable value, org.osid.id.IdManager idManager) throws org.osid.repository.RepositoryException { this.idManager = idManager; this.partStructureId = partStructureId; this.value = value; try { this.id = this.idManager.createId(); if (partStructureId.isEqual(ContributorPartStructure.getInstance().getId())) { this.partStructure = ContributorPartStructure.getInstance(); } else if (partStructureId.isEqual(CoveragePartStructure.getInstance().getId())) { this.partStructure = CoveragePartStructure.getInstance(); } else if (partStructureId.isEqual(CreatorPartStructure.getInstance().getId())) { this.partStructure = CreatorPartStructure.getInstance(); } else if (partStructureId.isEqual(DatePartStructure.getInstance().getId())) { this.partStructure = DatePartStructure.getInstance(); } else if (partStructureId.isEqual(DateRetrievedPartStructure.getInstance().getId())) { this.partStructure = DateRetrievedPartStructure.getInstance(); } else if (partStructureId.isEqual(DOIPartStructure.getInstance().getId())) { this.partStructure = DOIPartStructure.getInstance(); } else if (partStructureId.isEqual(EditionPartStructure.getInstance().getId())) { this.partStructure = EditionPartStructure.getInstance(); } else if (partStructureId.isEqual(EndPagePartStructure.getInstance().getId())) { this.partStructure = EndPagePartStructure.getInstance(); } else if (partStructureId.isEqual(FormatPartStructure.getInstance().getId())) { this.partStructure = FormatPartStructure.getInstance(); } else if (partStructureId.isEqual(InLineCitationPartStructure.getInstance().getId())) { this.partStructure = InLineCitationPartStructure.getInstance(); } else if (partStructureId.isEqual(IsnIdentifierPartStructure.getInstance().getId())) { this.partStructure = IsnIdentifierPartStructure.getInstance(); } else if (partStructureId.isEqual(IssuePartStructure.getInstance().getId())) { this.partStructure = IssuePartStructure.getInstance(); } else if (partStructureId.isEqual(LanguagePartStructure.getInstance().getId())) { this.partStructure = LanguagePartStructure.getInstance(); } else if (partStructureId.isEqual(NotePartStructure.getInstance().getId())) { this.partStructure = NotePartStructure.getInstance(); } else if (partStructureId.isEqual(OpenUrlPartStructure.getInstance().getId())) { this.partStructure = OpenUrlPartStructure.getInstance(); } else if (partStructureId.isEqual(PreferredUrlPartStructure.getInstance().getId())) { this.partStructure = PreferredUrlPartStructure.getInstance(); } else if (partStructureId.isEqual(PagesPartStructure.getInstance().getId())) { this.partStructure = PagesPartStructure.getInstance(); } else if (partStructureId.isEqual(PublicationLocationPartStructure.getInstance().getId())) { this.partStructure = PublicationLocationPartStructure.getInstance(); } else if (partStructureId.isEqual(PublisherPartStructure.getInstance().getId())) { this.partStructure = PublisherPartStructure.getInstance(); } else if (partStructureId.isEqual(RelationPartStructure.getInstance().getId())) { this.partStructure = RelationPartStructure.getInstance(); } else if (partStructureId.isEqual(RightsPartStructure.getInstance().getId())) { this.partStructure = RightsPartStructure.getInstance(); } else if (partStructureId.isEqual(SourcePartStructure.getInstance().getId())) { this.partStructure = SourcePartStructure.getInstance(); } else if (partStructureId.isEqual(SourceTitlePartStructure.getInstance().getId())) { this.partStructure = SourceTitlePartStructure.getInstance(); } else if (partStructureId.isEqual(StartPagePartStructure.getInstance().getId())) { this.partStructure = StartPagePartStructure.getInstance(); } else if (partStructureId.isEqual(SubjectPartStructure.getInstance().getId())) { this.partStructure = SubjectPartStructure.getInstance(); } else if (partStructureId.isEqual(TypePartStructure.getInstance().getId())) { this.partStructure = TypePartStructure.getInstance(); } else if (partStructureId.isEqual(URLPartStructure.getInstance().getId())) { this.partStructure = URLPartStructure.getInstance(); } else if (partStructureId.isEqual(VolumePartStructure.getInstance().getId())) { this.partStructure = VolumePartStructure.getInstance(); } else if (partStructureId.isEqual(YearPartStructure.getInstance().getId())) { this.partStructure = YearPartStructure.getInstance(); } else { throw new RuntimeException("Unknown PartStructure ID: " + partStructureId); } } catch (Throwable t) { _log.error(t.getMessage()); throw new org.osid.repository.RepositoryException( org.osid.repository.RepositoryException.OPERATION_FAILED); } }
public static Record createImageRecord( String pid, ImageRecordStructure recordStructure, Repository repository, PID objectId, FedoraObjectAssetType assetType, String displayName, String identifier) throws org.osid.repository.RepositoryException { Record record = null; try { record = new Record(new PID(pid), recordStructure); // System.out.println("creating " + recordStructure.getType().getKeyword() + " " + // recordStructure.getDisplayName()); if (assetType.getKeyword().equals("tufts/image/archival")) { record.createPart( recordStructure.getThumbnailPartStructure().getId(), Utilities.formatObjectUrl(objectId.getIdString(), THUMBNAIL, repository)); record.createPart( recordStructure.getURLPartStructure().getId(), Utilities.formatObjectUrl(objectId.getIdString(), FULLVIEW, repository)); record.createPart( recordStructure.getMediumImagePartStructure().getId(), Utilities.formatObjectUrl(objectId.getIdString(), MEDIUM_RES, repository)); record.createPart( LargeImagePartStructure.getInstance().getId(), Utilities.formatObjectUrl(objectId.getIdString(), MEDIUM_RES, repository)); // get the XML for the Dublin Core metadata for this asset; parse it to fill in part // structures String dcURL = Utilities.formatObjectUrl( objectId.getIdString(), "bdef:TuftsMetadata/getDublinCore/", repository); String contributor = ""; String coverage = ""; String creator = ""; String date = ""; String description = ""; String format = ""; String language = ""; String publisher = ""; String relation = ""; String rights = ""; String source = ""; String subject = ""; String type = ""; try { java.net.URL url = new java.net.URL(dcURL); java.net.URLConnection connection = url.openConnection(); java.net.HttpURLConnection http = (java.net.HttpURLConnection) connection; java.io.InputStreamReader in = new java.io.InputStreamReader(http.getInputStream()); StringBuffer xml = new StringBuffer(); try { int i = 0; while ((i = in.read()) != -1) { xml.append(Character.toString((char) i)); } } catch (Throwable t) { } // System.out.println("xml " + xml); javax.xml.parsers.DocumentBuilderFactory dbf = null; javax.xml.parsers.DocumentBuilder db = null; org.w3c.dom.Document document = null; dbf = javax.xml.parsers.DocumentBuilderFactory.newInstance(); db = dbf.newDocumentBuilder(); document = db.parse(new java.io.ByteArrayInputStream(xml.toString().getBytes())); // for each DOC (maps 1-to-1 with Asset) org.w3c.dom.NodeList dcs = document.getElementsByTagName("dc:contributor"); int numDCs = dcs.getLength(); for (int i = 0; i < numDCs; i++) { org.w3c.dom.Element dc = (org.w3c.dom.Element) dcs.item(i); if (dc.hasChildNodes()) { contributor = dc.getFirstChild().getNodeValue(); record.createPart(ContributorPartStructure.getInstance().getId(), contributor); } } dcs = document.getElementsByTagName("dc:creator"); numDCs = dcs.getLength(); for (int i = 0; i < numDCs; i++) { org.w3c.dom.Element dc = (org.w3c.dom.Element) dcs.item(i); if (dc.hasChildNodes()) { creator = dc.getFirstChild().getNodeValue(); record.createPart(CreatorPartStructure.getInstance().getId(), creator); } } dcs = document.getElementsByTagName("dc:date"); numDCs = dcs.getLength(); for (int i = 0; i < numDCs; i++) { org.w3c.dom.Element dc = (org.w3c.dom.Element) dcs.item(i); if (dc.hasChildNodes()) { date = dc.getFirstChild().getNodeValue(); record.createPart(DatePartStructure.getInstance().getId(), date); } } dcs = document.getElementsByTagName("dc:description"); numDCs = dcs.getLength(); for (int i = 0; i < numDCs; i++) { org.w3c.dom.Element dc = (org.w3c.dom.Element) dcs.item(i); if (dc.hasChildNodes()) { description = dc.getFirstChild().getNodeValue(); record.createPart(DescriptionPartStructure.getInstance().getId(), description); } } dcs = document.getElementsByTagName("dc:format"); numDCs = dcs.getLength(); for (int i = 0; i < numDCs; i++) { org.w3c.dom.Element dc = (org.w3c.dom.Element) dcs.item(i); if (dc.hasChildNodes()) { format = dc.getFirstChild().getNodeValue(); record.createPart(FormatPartStructure.getInstance().getId(), format); } } dcs = document.getElementsByTagName("dc:language"); numDCs = dcs.getLength(); for (int i = 0; i < numDCs; i++) { org.w3c.dom.Element dc = (org.w3c.dom.Element) dcs.item(i); if (dc.hasChildNodes()) { language = dc.getFirstChild().getNodeValue(); record.createPart(LanguagePartStructure.getInstance().getId(), language); } } dcs = document.getElementsByTagName("dc:publisher"); numDCs = dcs.getLength(); for (int i = 0; i < numDCs; i++) { org.w3c.dom.Element dc = (org.w3c.dom.Element) dcs.item(i); if (dc.hasChildNodes()) { publisher = dc.getFirstChild().getNodeValue(); record.createPart(PublisherPartStructure.getInstance().getId(), publisher); } } dcs = document.getElementsByTagName("dc:relation"); numDCs = dcs.getLength(); for (int i = 0; i < numDCs; i++) { org.w3c.dom.Element dc = (org.w3c.dom.Element) dcs.item(i); if (dc.hasChildNodes()) { relation = dc.getFirstChild().getNodeValue(); record.createPart(RelationPartStructure.getInstance().getId(), relation); } } dcs = document.getElementsByTagName("dc:rights"); numDCs = dcs.getLength(); for (int i = 0; i < numDCs; i++) { org.w3c.dom.Element dc = (org.w3c.dom.Element) dcs.item(i); if (dc.hasChildNodes()) { rights = dc.getFirstChild().getNodeValue(); record.createPart(RightsPartStructure.getInstance().getId(), rights); } } dcs = document.getElementsByTagName("dc:source"); numDCs = dcs.getLength(); for (int i = 0; i < numDCs; i++) { org.w3c.dom.Element dc = (org.w3c.dom.Element) dcs.item(i); if (dc.hasChildNodes()) { creator = dc.getFirstChild().getNodeValue(); record.createPart(SourcePartStructure.getInstance().getId(), source); } } dcs = document.getElementsByTagName("dc:subject"); numDCs = dcs.getLength(); for (int i = 0; i < numDCs; i++) { org.w3c.dom.Element dc = (org.w3c.dom.Element) dcs.item(i); if (dc.hasChildNodes()) { creator = dc.getFirstChild().getNodeValue(); record.createPart(SubjectPartStructure.getInstance().getId(), subject); } } dcs = document.getElementsByTagName("dc:type"); numDCs = dcs.getLength(); for (int i = 0; i < numDCs; i++) { org.w3c.dom.Element dc = (org.w3c.dom.Element) dcs.item(i); if (dc.hasChildNodes()) { type = dc.getFirstChild().getNodeValue(); record.createPart(TypePartStructure.getInstance().getId(), type); } } } catch (Throwable t) { t.printStackTrace(); } } } catch (Throwable t) { t.printStackTrace(); } return record; }