@Override public void liftEmbargo(Context context, Item item) throws SQLException, AuthorizeException, IOException { // Since 3.0 the lift process for all embargoes is performed through the dates // on the authorization process (see DS-2588) // lifter.liftEmbargo(context, item); itemService.clearMetadata(context, item, lift_schema, lift_element, lift_qualifier, Item.ANY); // set the dc.date.available value to right now itemService.clearMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "available", Item.ANY); itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "available", null, DCDate.getCurrent().toString()); log.info("Lifting embargo on Item " + item.getHandle()); itemService.update(context, item); }
protected void populateMetadata(Context c, Item item) throws SQLException, AuthorizeException { DCDate now = DCDate.getCurrent(); itemService.addMetadata(c, item, MetadataSchema.DC_SCHEMA, "date", "accessioned", null, now.toString()); itemService.addMetadata(c, item, MetadataSchema.DC_SCHEMA, "date", "available", null, now.toString()); for (MetadataValue dcv : currentDateIssued) { if (dcv.getValue() != null && dcv.getValue().equalsIgnoreCase("today")) { DCDate issued = new DCDate(now.getYear(), now.getMonth(), now.getDay(), -1, -1, -1); itemService.addMetadata(c, item, dcv.getMetadataField(), dcv.getLanguage(), issued.toString()); } else if (dcv.getValue() != null) { itemService.addMetadata(c, item, dcv.getMetadataField(), dcv.getLanguage(), dcv.getValue()); String previousDateIssued = currentDateIssued.get(0).getValue(); if (previousDateIssued != null && !previousDateIssued.equalsIgnoreCase("today")) { DCDate d = new DCDate(previousDateIssued); provDescription = provDescription + " Previous issue date: " + d.toString();
public String displayLocalDate(boolean showTime, Locale locale) { // forcibly truncate month name to 3 chars -- XXX FIXME? String monthName = getMonthName(getMonth(), locale); if (monthName.length() > 2) { monthName = monthName.substring(0, 3); } // display date and time if (showTime && granularity == DateGran.TIME) { return String.format("%d-%s-%4d %02d:%02d:%02d", getDay(), monthName, getYear(), getHour(), getMinute(), getSecond()); } else if (granularity == DateGran.YEAR) { return String.format("%4d", getYear()); } else if (granularity == DateGran.MONTH) { return String.format("%s-%4d", monthName, getYear()); } else { return String.format("%d-%s-%4d", getDay(), monthName, getYear()); } }
public String displayUTCDate(boolean showTime, Locale locale) { // forcibly truncate month name to 3 chars -- XXX FIXME? String monthName = getMonthName(getMonthUTC(), locale); if (monthName.length() > 2) { monthName = monthName.substring(0, 3); } // display date and time if (showTime && granularity == DateGran.TIME) { return String .format("%d-%s-%4d %02d:%02d:%02d", getDayUTC(), monthName, getYearUTC(), getHourUTC(), getMinuteUTC(), getSecondUTC()); } else if (granularity == DateGran.YEAR) { return String.format("%4d", getYearUTC()); } else if (granularity == DateGran.MONTH) { return String.format("%s-%4d", monthName, getYearUTC()); } else { return String.format("%d-%s-%4d", getDayUTC(), monthName, getYearUTC()); } }
for (int i = 1; i < 13; i++) month.addOption(i,org.dspace.content.DCDate.getMonthName(i,Locale.getDefault())); DCDate dcDate = new DCDate(dcValue.value); year.addInstance().setValue(String.valueOf(dcDate.getYear())); month.addInstance().setOptionSelected(dcDate.getMonth()); day.addInstance().setValue(String.valueOf(dcDate.getDay())); fullDate.addInstance().setValue(dcDate.toString()); DCDate dcDate = new DCDate(dcValues[0].value); year.setValue(String.valueOf(dcDate.getYear())); month.setOptionSelected(dcDate.getMonth()); if (dcDate.getDay() == -1) day.setValue(String.valueOf(dcDate.getDay()));
/** * Get a date representing the current instant in time. * * @return a DSpaceDate object representing the current instant. */ public static DCDate getCurrent() { return (new DCDate(new Date())); }
DCDate dcStart = new DCDate(count.getValue()); Calendar endDate = Calendar.getInstance(); endDate.setTime(dcStart.toDate()); endDate.add(Calendar.YEAR, 1); DCDate dcEndDate = new DCDate(endDate.getTime()); filterQuery.append(ClientUtils.escapeQueryChars(dcStart.toString())); filterQuery.append(" TO "); filterQuery.append(ClientUtils.escapeQueryChars(dcEndDate.toString())); filterQuery.append("]"); filterQuery.append(" NOT ").append(ClientUtils.escapeQueryChars(dcEndDate.toString())); filterQuery.append(")"); String coreName = "statistics-" + dcStart.getYearUTC(); HttpSolrServer statisticsYearServer = createCore((HttpSolrServer) solr, coreName); tempDirectory.getPath() + File.separatorChar + "temp." + dcStart.getYearUTC() + "." + i + ".csv"); FileUtils.copyInputStreamToFile(csvInputstream, csvFile); filesToUpload.add(csvFile);
/** * Add date for bitstream granted (used into the use case for license grant the * {@link LicenseUtils#grantLicense(Context, Item, String, String)} * * @param context the dspace context * @param acceptanceDate the granted date * @throws SQLException */ public void setAcceptanceDate(Context context, DCDate acceptanceDate) throws SQLException { getBitstreamService() .setMetadataSingleValue(context, this, "dcterms", "accessRights", null, null, acceptanceDate.toString()); }
protected DCDate recoverEmbargoDate(Item item) { DCDate liftDate = null; List<MetadataValue> lift = itemService.getMetadata(item, lift_schema, lift_element, lift_qualifier, Item.ANY); if (lift.size() > 0) { liftDate = new DCDate(lift.get(0).getValue()); // sanity check: do not allow an embargo lift date in the past. if (liftDate.toDate().before(new Date())) { liftDate = null; } } return liftDate; }
b.setSource(context, "Written by org.dspace.content.LicenseUtils"); DCDate acceptanceDCDate = DCDate.getCurrent(); if (acceptanceDate != null) { acceptanceDCDate = new DCDate(acceptanceDate);
@Override public DCDate getEmbargoTermsAsDate(Context context, Item item) throws SQLException, AuthorizeException { List<MetadataValue> terms = itemService.getMetadata(item, terms_schema, terms_element, terms_qualifier, Item.ANY); DCDate result = null; // Its poor form to blindly use an object that could be null... if (terms == null) { return null; } result = setter.parseTerms(context, item, terms.size() > 0 ? terms.get(0).getValue() : null); if (result == null) { return null; } // new DCDate(non-date String) means toDate() will return null Date liftDate = result.toDate(); if (liftDate == null) { throw new IllegalArgumentException( "Embargo lift date is uninterpretable: " + result.toString()); } /* * NOTE: We do not check here for past dates as it can result in errors during AIP restoration. * Therefore, UIs should perform any such date validation on input. See DS-3348 */ return result; }
for (int i = 1; i <= 12; i++) month.addOption(false, String.valueOf(i), DCDate.getMonthName(i, Locale .getDefault())); int currentYear = DCDate.getCurrent().getYear(); int i = currentYear;
+ " bitstream(s) on " + DCDate.getCurrent() + " : " + installItemService.getBitstreamProvenanceMessage(context, item); MetadataUtilities.appendMetadata(context, item, dtom, false, append);
.propertiesBuilder(solrConfigDir); PropertiesConfiguration config = builder.getConfiguration(); config.setProperty("workflow-start-date", new DCDate(oldestDate)); builder.save(); } catch (ConfigurationException e) { .setProperty("usage-statistics.workflow-start-date", new DCDate(oldestDate).toString()); return new DCDate(workflowStartDate).toDate();
/** * Parse the terms into a definite date. Only terms expressions processed * are those defined in 'embargo.terms.days' configuration property. * * @param context the DSpace context * @param item the item to embargo * @param terms the embargo terms * @return parsed date in DCDate format */ @Override public DCDate parseTerms(Context context, Item item, String terms) throws SQLException, AuthorizeException { String termsOpen = DSpaceServicesFactory.getInstance().getConfigurationService() .getProperty("embargo.terms.open"); Properties termProps = getTermProperties(); if (terms != null) { if (termsOpen.equals(terms)) { return EmbargoServiceImpl.FOREVER; } String days = termProps.getProperty(terms); if (days != null && days.length() > 0) { long lift = System.currentTimeMillis() + (Long.parseLong(days) * 24 * 60 * 60 * 1000); return new DCDate(new Date(lift)); } } return null; }
date != null ? date.toString() : "null");
@Override public Version createNewVersion(Context c, Item item, String summary) { try { VersionHistory vh = versionHistoryService.findByItem(c, item); if (vh == null) { // first time: create 2 versions: old and new one vh = versionHistoryService.create(c); // get dc:date.accessioned to be set as first version date... List<MetadataValue> values = itemService.getMetadata(item, "dc", "date", "accessioned", Item.ANY); Date versionDate = new Date(); if (values != null && values.size() > 0) { String date = values.get(0).getValue(); versionDate = new DCDate(date).toDate(); } createVersion(c, vh, item, "", versionDate); } // Create new Item Item itemNew = provider.createNewItemAndAddItInWorkspace(c, item); // create new version Version version = createVersion(c, vh, itemNew, summary, new Date()); // Complete any update of the Item and new Identifier generation that needs to happen provider.updateItemState(c, itemNew, item); return version; } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
for (int i = 1; i <= 12; i++) month.addOption(false, String.valueOf(i), DCDate.getMonthName(i, Locale .getDefault())); int currentYear = DCDate.getCurrent().getYear(); int i = currentYear;