List of usage examples for java.util Calendar clear
public final void clear()
Calendar
undefined. From source file:KitchenManagement.FoodDemandForecastingAndPlanning.FoodDemandForecastingAndPlanningBean.java
@Override public Boolean generateMaterialRequirementPlan(Long storeId) { System.out.println("generateMaterialRequirementPlan is called."); try {/*from w w w . ja v a2 s . c om*/ StoreEntity store = em.find(StoreEntity.class, storeId); Query q = em.createQuery("select s from MonthScheduleEntity s"); List<MonthScheduleEntity> scheduleList = q.getResultList(); MonthScheduleEntity schedule = scheduleList.get(scheduleList.size() - 1); Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.set(Calendar.YEAR, schedule.getYear()); calendar.set(Calendar.MONTH, schedule.getMonth() - 1); Query q1 = em.createQuery( "select mps from MasterProductionScheduleEntity mps where mps.store.id = ?1 and mps.schedule.id = ?2") .setParameter(1, storeId).setParameter(2, schedule.getId()); List<MasterProductionScheduleEntity> mpsList = (List<MasterProductionScheduleEntity>) q1 .getResultList(); for (MasterProductionScheduleEntity mps : mpsList) { if (mps.getMenuItem().getRecipe() != null) { for (LineItemEntity lineItem : mps.getMenuItem().getRecipe().getListOfLineItems()) { Query q2 = em.createQuery( "select mr from MaterialRequirementEntity mr where mr.store.id = ?1 and mr.rawIngredient.SKU = ?2 and mr.schedule.id = ?3 and mr.mps.id = ?4") .setParameter(1, storeId).setParameter(2, lineItem.getItem().getSKU()) .setParameter(3, schedule.getId()).setParameter(4, mps.getId()); List<MaterialRequirementEntity> mrList = (List<MaterialRequirementEntity>) q2 .getResultList(); System.out.println("mrList.getSize(): " + mrList.size()); for (MaterialRequirementEntity mr : mrList) { em.remove(mr); } em.flush(); } } } for (MasterProductionScheduleEntity mps : mpsList) { if (mps.getMenuItem().getRecipe() != null && mps.getAmount_month() != 0) { for (LineItemEntity lineItem : mps.getMenuItem().getRecipe().getListOfLineItems()) { Query query1 = em.createQuery( "select mr from MaterialRequirementEntity mr where mr.store.id = ?1 and mr.rawIngredient.SKU = ?2 and mr.schedule.id =?3 and mr.day = ?4 ") .setParameter(1, storeId).setParameter(2, lineItem.getItem().getSKU()) .setParameter(3, schedule.getId()).setParameter(4, 1); if (mps.getAmount_week1() != 0) { if (query1.getResultList().isEmpty()) { MaterialRequirementEntity MR1 = new MaterialRequirementEntity(); MR1.setStore(store); MR1.setMps(mps); MR1.setRawIngredient((RawIngredientEntity) lineItem.getItem()); MR1.setQuantity(mps.getAmount_week1() * lineItem.getQuantity() / mps.getMenuItem().getRecipe().getBroadLotSize() + 1); MR1.setSchedule(schedule); MR1.setDay(1); em.persist(MR1); } else { MaterialRequirementEntity MR1 = (MaterialRequirementEntity) query1.getResultList() .get(0); MR1.setQuantity(MR1.getQuantity() + mps.getAmount_week1() * lineItem.getQuantity() / mps.getMenuItem().getRecipe().getBroadLotSize() + 1); em.merge(MR1); } } calendar.set(Calendar.WEEK_OF_MONTH, 2); calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); System.out.println("calendar.get(Calendar.DAY_OF_MONTH) week2 :" + calendar.get(Calendar.DAY_OF_MONTH)); Query query2 = em.createQuery( "select mr from MaterialRequirementEntity mr where mr.store.id = ?1 and mr.rawIngredient.SKU = ?2 and mr.schedule.id =?3 and mr.day = ?4 ") .setParameter(1, storeId).setParameter(2, lineItem.getItem().getSKU()) .setParameter(3, schedule.getId()) .setParameter(4, calendar.get(Calendar.DAY_OF_MONTH)); if (query2.getResultList().isEmpty()) { MaterialRequirementEntity MR2 = new MaterialRequirementEntity(); MR2.setStore(store); MR2.setMps(mps); MR2.setRawIngredient((RawIngredientEntity) lineItem.getItem()); System.out.println("persis-mps.getAmount_week2(): " + mps.getAmount_week2()); System.out.println("lineItem.getQuantity(): " + lineItem.getQuantity()); System.out.println("mps.getMenuItem().getRecipe().getBroadLotSize()" + mps.getMenuItem().getRecipe().getBroadLotSize()); MR2.setQuantity(mps.getAmount_week2() * lineItem.getQuantity() / mps.getMenuItem().getRecipe().getBroadLotSize() + 1); MR2.setSchedule(schedule); MR2.setDay(calendar.get(Calendar.DAY_OF_MONTH)); em.persist(MR2); System.out.println("persis-MR2.getQuantity(): " + MR2.getQuantity()); } else { MaterialRequirementEntity MR2 = (MaterialRequirementEntity) query2.getResultList() .get(0); System.out.println("persis-mps.getAmount_week2(): " + mps.getAmount_week2()); System.out.println("lineItem.getQuantity(): " + lineItem.getQuantity()); System.out.println("mps.getMenuItem().getRecipe().getBroadLotSize()" + mps.getMenuItem().getRecipe().getBroadLotSize()); MR2.setQuantity(MR2.getQuantity() + mps.getAmount_week2() * lineItem.getQuantity() / mps.getMenuItem().getRecipe().getBroadLotSize() + 1); em.merge(MR2); System.out.println("merge-MR2.getQuantity(): " + MR2.getQuantity()); } calendar.set(Calendar.WEEK_OF_MONTH, 3); calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); System.out.println("calendar.get(Calendar.DAY_OF_MONTH) week3 :" + calendar.get(Calendar.DAY_OF_MONTH)); Query query3 = em.createQuery( "select mr from MaterialRequirementEntity mr where mr.store.id = ?1 and mr.rawIngredient.SKU = ?2 and mr.schedule.id =?3 and mr.day = ?4 ") .setParameter(1, storeId).setParameter(2, lineItem.getItem().getSKU()) .setParameter(3, schedule.getId()) .setParameter(4, calendar.get(Calendar.DAY_OF_MONTH)); if (query3.getResultList().isEmpty()) { MaterialRequirementEntity MR3 = new MaterialRequirementEntity(); MR3.setStore(store); MR3.setMps(mps); MR3.setRawIngredient((RawIngredientEntity) lineItem.getItem()); MR3.setQuantity(mps.getAmount_week3() * lineItem.getQuantity() / mps.getMenuItem().getRecipe().getBroadLotSize() + 1); MR3.setSchedule(schedule); MR3.setDay(calendar.get(Calendar.DAY_OF_MONTH)); em.persist(MR3); } else { MaterialRequirementEntity MR3 = (MaterialRequirementEntity) query3.getResultList() .get(0); MR3.setQuantity(MR3.getQuantity() + mps.getAmount_week3() * lineItem.getQuantity() / mps.getMenuItem().getRecipe().getBroadLotSize() + 1); em.merge(MR3); } calendar.set(Calendar.WEEK_OF_MONTH, 4); calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); System.out.println("calendar.get(Calendar.DAY_OF_MONTH) week4 :" + calendar.get(Calendar.DAY_OF_MONTH)); Query query4 = em.createQuery( "select mr from MaterialRequirementEntity mr where mr.store.id = ?1 and mr.rawIngredient.SKU = ?2 and mr.schedule.id =?3 and mr.day = ?4 ") .setParameter(1, storeId).setParameter(2, lineItem.getItem().getSKU()) .setParameter(3, schedule.getId()) .setParameter(4, calendar.get(Calendar.DAY_OF_MONTH)); if (query4.getResultList().isEmpty()) { MaterialRequirementEntity MR4 = new MaterialRequirementEntity(); MR4.setStore(store); MR4.setMps(mps); MR4.setRawIngredient((RawIngredientEntity) lineItem.getItem()); MR4.setQuantity(mps.getAmount_week4() * lineItem.getQuantity() / mps.getMenuItem().getRecipe().getBroadLotSize() + 1); MR4.setSchedule(schedule); MR4.setDay(calendar.get(Calendar.DAY_OF_MONTH)); em.persist(MR4); } else { MaterialRequirementEntity MR4 = (MaterialRequirementEntity) query4.getResultList() .get(0); MR4.setQuantity(MR4.getQuantity() + mps.getAmount_week4() * lineItem.getQuantity() / mps.getMenuItem().getRecipe().getBroadLotSize() + 1); em.merge(MR4); } if (mps.getAmount_week5() != 0) { calendar.set(Calendar.WEEK_OF_MONTH, 5); calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); System.out.println("calendar.get(Calendar.DAY_OF_MONTH) week5 :" + calendar.get(Calendar.DAY_OF_MONTH)); Query query5 = em.createQuery( "select mr from MaterialRequirementEntity mr where mr.store.id = ?1 and mr.rawIngredient.SKU = ?2 and mr.schedule.id =?3 and mr.day = ?4 ") .setParameter(1, storeId).setParameter(2, lineItem.getItem().getSKU()) .setParameter(3, schedule.getId()) .setParameter(4, calendar.get(Calendar.DAY_OF_MONTH)); if (query5.getResultList().isEmpty()) { MaterialRequirementEntity MR5 = new MaterialRequirementEntity(); MR5.setStore(store); MR5.setMps(mps); MR5.setRawIngredient((RawIngredientEntity) lineItem.getItem()); MR5.setQuantity(mps.getAmount_week5() * lineItem.getQuantity() / mps.getMenuItem().getRecipe().getBroadLotSize() + 1); MR5.setSchedule(schedule); MR5.setDay(calendar.get(Calendar.DAY_OF_MONTH)); em.persist(MR5); } else { MaterialRequirementEntity MR5 = (MaterialRequirementEntity) query5.getResultList() .get(0); MR5.setQuantity(MR5.getQuantity() + mps.getAmount_week5() * lineItem.getQuantity() / mps.getMenuItem().getRecipe().getBroadLotSize() + 1); em.merge(MR5); } } } } } return true; } catch (Exception ex) { ex.printStackTrace(); } return false; }
From source file:org.sqlite.date.FastDateParser.java
/** * This implementation updates the ParsePosition if the parse succeeeds. * However, unlike the method {@link java.text.SimpleDateFormat#parse(String, ParsePosition)} * it is not able to set the error Index - i.e. {@link ParsePosition#getErrorIndex()} - if the parse fails. * <p>/* w w w . j a v a2 s . c o m*/ * To determine if the parse has succeeded, the caller must check if the current parse position * given by {@link ParsePosition#getIndex()} has been updated. If the input buffer has been fully * parsed, then the index will point to just after the end of the input buffer. * * @see org.apache.commons.lang3.time.DateParser#parse(java.lang.String, java.text.ParsePosition) * {@inheritDoc} */ public Date parse(final String source, final ParsePosition pos) { final int offset = pos.getIndex(); final Matcher matcher = parsePattern.matcher(source.substring(offset)); if (!matcher.lookingAt()) { return null; } // timing tests indicate getting new instance is 19% faster than cloning final Calendar cal = Calendar.getInstance(timeZone, locale); cal.clear(); for (int i = 0; i < strategies.length;) { final Strategy strategy = strategies[i++]; strategy.setCalendar(this, cal, matcher.group(i)); } pos.setIndex(offset + matcher.end()); return cal.getTime(); }
From source file:com.pureinfo.tgirls.servlet.NormalRandomEventMsg.java
public void createEvent(User loginUser) throws ServletException, IOException { if (loginUser == null) { return;//ww w.ja v a 2s . co m } Calendar now = Calendar.getInstance(); int m = now.get(Calendar.MONTH); int d = now.get(Calendar.DAY_OF_MONTH); List<RandomEvent> todayEvents = (List<RandomEvent>) cache.get(NORMAL_EVENT_KEY + "." + m + "." + d); if (todayEvents == null) { todayEvents = new ArrayList<RandomEvent>(); logger.debug("today events is empty. reload."); List<RandomEvent> allNormalEvents = null; try { allNormalEvents = getNormalEvents(); // cache.put(WELCOME_EVENT_KEY, allWelcomeRandomEvents); } catch (PureException e) { logger.error("error when get normal events.", e); } if (allNormalEvents == null || allNormalEvents.isEmpty()) { logger.debug("all normal events is empty."); return; } List<RandomEvent> noDayEvents = new ArrayList<RandomEvent>();// Calendar c1 = Calendar.getInstance();// Calendar.getInstance(); Calendar today = Calendar.getInstance(); for (Iterator iterator = allNormalEvents.iterator(); iterator.hasNext();) { RandomEvent randomEvent = (RandomEvent) iterator.next(); String month_day = randomEvent.getEventMonthDay(); if (StringUtils.isNotEmpty(month_day)) { try { int i = month_day.indexOf("-"); int month = NumberUtils.toInt(month_day.substring(0, i), -1); int day = NumberUtils.toInt(month_day.substring(i + 1), -1); c1.clear(); c1 = Calendar.getInstance(); // logger.debug("the random event [" + randomEvent.getEventInfo() + "] month:" + month + " day:" // + day); if (month != -1) { c1.set(Calendar.MONTH, month - 1); } if (day != -1) { c1.set(Calendar.DAY_OF_MONTH, day); } if (DateUtils.isSameDay(c1, today)) { logger.debug("today event:" + randomEvent.getEventInfo()); todayEvents.add(randomEvent); } } catch (Exception e) { } } else { noDayEvents.add(randomEvent); } } if (todayEvents == null || todayEvents.isEmpty()) { if (noDayEvents.isEmpty()) { logger.debug("today events is empty, and noDay events is empty too."); return; } } // ////////////////////////////// // ////////////////////////////// todayEvents.addAll(noDayEvents); // ////////////////////// // ////////////////////// Collections.sort(todayEvents, new BeanComparator("eventScale")); todayTotalScale = 0; for (Iterator iterator = todayEvents.iterator(); iterator.hasNext();) { RandomEvent randomEvent2 = (RandomEvent) iterator.next(); todayTotalScale += randomEvent2.getEventScale(); } cache.put(NORMAL_EVENT_KEY + "." + m + "." + d, todayEvents); } int random = new Random().nextInt(todayTotalScale); RandomEvent todayEvent = null; int start = 0; int end = 0; for (int i = 0; i < todayEvents.size(); i++) { if (i == 0) { start = 0; end = todayEvents.get(i).getEventScale(); } else { start = end; end = end + todayEvents.get(i).getEventScale(); } if (random >= start && random < end) { todayEvent = todayEvents.get(i); break; } } if (todayEvent == null) { return; } try { logger.info("normal event[" + todayEvent.getEventInfo() + "]"); // loginUser.setFunds(loginUser.getFunds() + todayEvent.getEventMoney()); // loginUser.setAssets(loginUser.getAssets() + todayEvent.getEventMoney()); createInformation(loginUser, todayEvent); UserMoneySaveEntry userMoney = new UserMoneySaveEntry(); userMoney.setTaobaoId(loginUser.getTaobaoID()); userMoney.setFunds(todayEvent.getEventMoney()); userMoney.setAssets(todayEvent.getEventMoney()); UserMoneySaveCache.getInstance().add(userMoney); // UserInfoSaveCache.getInstance().add(loginUser); } catch (Exception e) { logger.error(e); return; } return; }
From source file:org.apache.logging.log4j.core.util.datetime.FastDateParser.java
/** * This implementation updates the ParsePosition if the parse succeeds. * However, it sets the error index to the position before the failed field unlike * the method {@link java.text.SimpleDateFormat#parse(String, ParsePosition)} which sets * the error index to after the failed field. * <p>//from w ww .ja va 2 s. c o m * To determine if the parse has succeeded, the caller must check if the current parse position * given by {@link ParsePosition#getIndex()} has been updated. If the input buffer has been fully * parsed, then the index will point to just after the end of the input buffer. * * @see org.apache.commons.lang3.time.DateParser#parse(java.lang.String, java.text.ParsePosition) */ @Override public Date parse(final String source, final ParsePosition pos) { // timing tests indicate getting new instance is 19% faster than cloning final Calendar cal = Calendar.getInstance(timeZone, locale); cal.clear(); return parse(source, pos, cal) ? cal.getTime() : null; }
From source file:org.tdl.vireo.search.impl.LuceneAbstractJobImpl.java
/** * Write a the provided submission and all associated action logs to the * index writer. This method expects that the submission and action logs * have been removed from the index, either through a specific delete, * or a delete all in the case of rebuilding the index. * /*from ww w. ja v a 2s.c o m*/ * This method is used to share code between the various index job * implementations so that submissions are written the same no matter * who indexes them first. * * @param writer * The index writer. * @param sub * The submission to index. */ public void indexSubmission(IndexWriter writer, Submission sub) throws CorruptIndexException, IOException { StringBuilder searchText = new StringBuilder(); long subId = sub.getId(); String state = sub.getState().getDisplayName(); searchText.append(state).append(" "); long searchAssigned = 0; String sortAssigned = ""; if (sub.getAssignee() != null) { searchAssigned = sub.getAssignee().getId(); sortAssigned = sub.getAssignee().getFormattedName(NameFormat.LAST_FIRST_MIDDLE_BIRTH); searchText.append(sortAssigned).append(" "); } Date graduationSemester = null; if (sub.getGraduationYear() != null) { Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(Calendar.YEAR, sub.getGraduationYear()); if (sub.getGraduationMonth() != null) cal.set(Calendar.MONTH, sub.getGraduationMonth()); graduationSemester = cal.getTime(); } Date defenseDate = sub.getDefenseDate(); String department = sub.getDepartment(); String program = sub.getProgram(); String college = sub.getCollege(); String major = sub.getMajor(); searchText.append(department).append(" ").append(program).append(" ").append(college).append(" ") .append(major).append(" "); String embargo = null; if (sub.getEmbargoType() != null) { embargo = sub.getEmbargoType().getName(); searchText.append(embargo).append(" "); } String degree = sub.getDegree(); String documentType = sub.getDocumentType(); searchText.append(degree).append(" ").append(documentType).append(" "); Date submissionDate = sub.getSubmissionDate(); String studentName = ""; if (sub.getStudentLastName() != null) studentName += sub.getStudentLastName() + " "; if (sub.getStudentFirstName() != null) studentName += sub.getStudentFirstName() + " "; if (sub.getStudentMiddleName() != null) studentName += sub.getStudentMiddleName() + " "; searchText.append(studentName).append(" "); searchText.append(sub.getStudentFormattedName(NameFormat.LAST_FIRST_BIRTH)).append(" "); searchText.append(sub.getStudentFormattedName(NameFormat.FIRST_LAST_BIRTH)).append(" "); String studentEmail = sub.getSubmitter().getEmail(); searchText.append(studentEmail).append(" "); String institutionalIdentifier = sub.getSubmitter().getInstitutionalIdentifier(); searchText.append(institutionalIdentifier).append(" "); String documentTitle = sub.getDocumentTitle(); String documentAbstract = sub.getDocumentAbstract(); String documentKeywords = sub.getDocumentKeywords(); searchText.append(documentTitle).append(" ").append(documentAbstract).append(" ").append(documentKeywords) .append(" "); String documentSubjects = ""; for (String subject : sub.getDocumentSubjects()) { documentSubjects += subject + " "; } searchText.append(documentSubjects).append(" "); String documentLanguage = null; if (sub.getDocumentLanguageLocale() != null) { Locale locale = sub.getDocumentLanguageLocale(); searchText.append(locale.getDisplayName()).append(" "); searchText.append(locale.getDisplayLanguage()).append(" "); searchText.append(locale.getDisplayCountry()).append(" "); searchText.append(locale.getDisplayVariant()).append(" "); documentLanguage = locale.getDisplayName(); } String publishedMaterial = sub.getPublishedMaterial(); searchText.append(publishedMaterial).append(" "); String primaryDocument = null; if (sub.getPrimaryDocument() != null) { primaryDocument = sub.getPrimaryDocument().getName(); searchText.append(primaryDocument).append(" "); } Date licenseAgreementDate = sub.getLicenseAgreementDate(); Date approvalDate = sub.getApprovalDate(); Date committeeApprovalDate = sub.getCommitteeApprovalDate(); Date committeeEmbargoApprovalDate = sub.getCommitteeEmbargoApprovalDate(); String committeeMembers = ""; for (CommitteeMember member : sub.getCommitteeMembers()) { // TODO: sort by display order? committeeMembers += member.getFormattedName(NameFormat.LAST_FIRST) + " " + member.getFormattedRoles(); } searchText.append(committeeMembers).append(" "); String committeeContactEmail = sub.getCommitteeContactEmail(); searchText.append(committeeContactEmail).append(" "); String umiRelease; if (sub.getUMIRelease() == null) { umiRelease = ""; } else if (sub.getUMIRelease()) { umiRelease = "yes"; } else { umiRelease = "no"; } int customActions = 0; for (CustomActionValue action : sub.getCustomActions()) { if (action.getValue()) customActions++; } String degreeLevel = null; if (sub.getDegreeLevel() != null) degreeLevel = sub.getDegreeLevel().name(); searchText.append(degreeLevel).append(" "); String depositId = sub.getDepositId(); searchText.append(depositId).append(" "); String reviewerNotes = sub.getReviewerNotes(); searchText.append(reviewerNotes).append(" "); String lastEventEntry = null; Date lastEventTime = null; List<ActionLog> logs = indexer.subRepo.findActionLog(sub); if (logs.size() > 0) { lastEventEntry = logs.get(0).getEntry(); lastEventTime = logs.get(0).getActionDate(); searchText.append(lastEventEntry); } Document doc = new Document(); doc.add(new NumericField("subId", Field.Store.YES, true).setLongValue(subId)); doc.add(new Field("type", "submission", Field.Store.YES, Index.NOT_ANALYZED)); doc.add(new Field("searchText", searchText.toString(), Field.Store.NO, Index.ANALYZED_NO_NORMS)); if (state != null) doc.add(new Field("state", state, Field.Store.NO, Index.NOT_ANALYZED)); doc.add(new NumericField("searchAssigned", Field.Store.NO, true).setLongValue(searchAssigned)); if (sortAssigned != null) doc.add(new Field("sortAssigned", sortAssigned, Field.Store.NO, Index.NOT_ANALYZED)); if (graduationSemester != null) doc.add(new NumericField("graduationSemester", Field.Store.NO, true) .setLongValue(graduationSemester.getTime())); if (defenseDate != null) doc.add(new NumericField("defenseDate", Field.Store.NO, true).setLongValue(defenseDate.getTime())); if (department != null) doc.add(new Field("department", department, Field.Store.NO, Index.NOT_ANALYZED)); if (program != null) doc.add(new Field("program", program, Field.Store.NO, Index.NOT_ANALYZED)); if (college != null) doc.add(new Field("college", college, Field.Store.NO, Index.NOT_ANALYZED)); if (major != null) doc.add(new Field("major", major, Field.Store.NO, Index.NOT_ANALYZED)); if (embargo != null) doc.add(new Field("embargo", embargo, Field.Store.NO, Index.NOT_ANALYZED)); if (degree != null) doc.add(new Field("degree", degree, Field.Store.NO, Index.NOT_ANALYZED)); if (documentType != null) doc.add(new Field("documentType", documentType, Field.Store.NO, Index.NOT_ANALYZED)); if (submissionDate != null) doc.add(new NumericField("submissionDate", Field.Store.NO, true) .setLongValue(submissionDate.getTime())); if (studentName != null) doc.add(new Field("studentName", studentName, Field.Store.NO, Index.NOT_ANALYZED)); if (studentEmail != null) doc.add(new Field("studentEmail", studentEmail, Field.Store.NO, Index.NOT_ANALYZED)); if (institutionalIdentifier != null) doc.add(new Field("institutionalIdentifier", institutionalIdentifier, Field.Store.NO, Index.NOT_ANALYZED)); if (documentTitle != null) doc.add(new Field("documentTitle", documentTitle, Field.Store.NO, Index.NOT_ANALYZED)); if (documentAbstract != null) doc.add(new Field("documentAbstract", documentAbstract, Field.Store.NO, Index.NOT_ANALYZED)); if (documentKeywords != null) doc.add(new Field("documentKeywords", documentKeywords, Field.Store.NO, Index.NOT_ANALYZED)); if (documentSubjects != null) doc.add(new Field("documentSubjects", documentSubjects, Field.Store.NO, Index.NOT_ANALYZED)); if (documentLanguage != null) doc.add(new Field("documentLanguage", documentLanguage, Field.Store.NO, Index.NOT_ANALYZED)); if (publishedMaterial != null) doc.add(new Field("publishedMaterial", publishedMaterial, Field.Store.NO, Index.NOT_ANALYZED)); if (primaryDocument != null) doc.add(new Field("primaryDocument", primaryDocument, Field.Store.NO, Index.NOT_ANALYZED)); if (licenseAgreementDate != null) doc.add(new NumericField("licenseAgreementDate", Field.Store.NO, true) .setLongValue(licenseAgreementDate.getTime())); if (approvalDate != null) doc.add(new NumericField("approvalDate", Field.Store.NO, true).setLongValue(approvalDate.getTime())); if (committeeApprovalDate != null) doc.add(new NumericField("committeeApprovalDate", Field.Store.NO, true) .setLongValue(committeeApprovalDate.getTime())); if (committeeEmbargoApprovalDate != null) doc.add(new NumericField("committeeEmbargoApprovalDate", Field.Store.NO, true) .setLongValue(committeeEmbargoApprovalDate.getTime())); if (committeeMembers != null) doc.add(new Field("committeeMembers", committeeMembers, Field.Store.NO, Index.NOT_ANALYZED)); if (committeeContactEmail != null) doc.add(new Field("committeeContactEmail", committeeContactEmail, Field.Store.NO, Index.NOT_ANALYZED)); if (umiRelease != null) doc.add(new Field("umiRelease", umiRelease, Field.Store.NO, Index.NOT_ANALYZED)); doc.add(new NumericField("customActions", Field.Store.NO, true).setIntValue(customActions)); if (degreeLevel != null) doc.add(new Field("degreeLevel", degreeLevel, Field.Store.NO, Index.NOT_ANALYZED)); if (depositId != null) doc.add(new Field("depositId", depositId, Field.Store.NO, Index.NOT_ANALYZED)); if (reviewerNotes != null) doc.add(new Field("reviewerNotes", reviewerNotes, Field.Store.NO, Index.NOT_ANALYZED)); if (lastEventEntry != null) doc.add(new Field("lastEventEntry", lastEventEntry, Field.Store.NO, Index.NOT_ANALYZED)); if (lastEventTime != null) doc.add(new NumericField("lastEventTime", Field.Store.NO, true).setLongValue(lastEventTime.getTime())); writer.addDocument(doc); for (ActionLog log : logs) { Long logId = log.getId(); String logEntry = log.getEntry(); String logState = log.getSubmissionState().getDisplayName(); long logSearchAssigned = 0; String logSortAssigned = null; if (log.getPerson() != null) { logSearchAssigned = log.getPerson().getId(); logSortAssigned = log.getPerson().getFormattedName(NameFormat.FIRST_LAST); } Date logTime = log.getActionDate(); // The new special things for action logs. doc = new Document(); doc.add(new NumericField("subId", Field.Store.YES, true).setLongValue(subId)); doc.add(new NumericField("logId", Field.Store.YES, true).setLongValue(logId)); doc.add(new Field("type", "actionlog", Field.Store.YES, Index.NOT_ANALYZED)); if (logEntry != null) doc.add(new Field("searchText", logEntry, Field.Store.NO, Index.ANALYZED_NO_NORMS)); if (logState != null) doc.add(new Field("state", logState, Field.Store.NO, Index.NOT_ANALYZED)); doc.add(new NumericField("searchAssigned", Field.Store.NO, true).setLongValue(logSearchAssigned)); if (logSortAssigned != null) doc.add(new Field("sortAssigned", logSortAssigned, Field.Store.NO, Index.NOT_ANALYZED)); if (logEntry != null) doc.add(new Field("lastEventEntry", logEntry, Field.Store.NO, Index.NOT_ANALYZED)); if (logTime != null) doc.add(new NumericField("lastEventTime", Field.Store.NO, true).setLongValue(logTime.getTime())); // Stuff that is the same as the submission. if (graduationSemester != null) doc.add(new NumericField("graduationSemester", Field.Store.NO, true) .setLongValue(graduationSemester.getTime())); if (defenseDate != null) doc.add(new NumericField("defenseDate", Field.Store.NO, true).setLongValue(defenseDate.getTime())); if (department != null) doc.add(new Field("department", department, Field.Store.NO, Index.NOT_ANALYZED)); if (program != null) doc.add(new Field("program", program, Field.Store.NO, Index.NOT_ANALYZED)); if (college != null) doc.add(new Field("college", college, Field.Store.NO, Index.NOT_ANALYZED)); if (major != null) doc.add(new Field("major", major, Field.Store.NO, Index.NOT_ANALYZED)); if (embargo != null) doc.add(new Field("embargo", embargo, Field.Store.NO, Index.NOT_ANALYZED)); if (degree != null) doc.add(new Field("degree", degree, Field.Store.NO, Index.NOT_ANALYZED)); if (documentType != null) doc.add(new Field("documentType", documentType, Field.Store.NO, Index.NOT_ANALYZED)); if (submissionDate != null) doc.add(new NumericField("submissionDate", Field.Store.NO, true) .setLongValue(submissionDate.getTime())); if (studentName != null) doc.add(new Field("studentName", studentName, Field.Store.NO, Index.NOT_ANALYZED)); if (studentEmail != null) doc.add(new Field("studentEmail", studentEmail, Field.Store.NO, Index.NOT_ANALYZED)); if (institutionalIdentifier != null) doc.add(new Field("institutionalIdentifier", institutionalIdentifier, Field.Store.NO, Index.NOT_ANALYZED)); if (documentAbstract != null) doc.add(new Field("documentAbstract", documentAbstract, Field.Store.NO, Index.NOT_ANALYZED)); if (documentKeywords != null) doc.add(new Field("documentKeywords", documentKeywords, Field.Store.NO, Index.NOT_ANALYZED)); if (documentSubjects != null) doc.add(new Field("documentSubjects", documentSubjects, Field.Store.NO, Index.NOT_ANALYZED)); if (documentLanguage != null) doc.add(new Field("documentLanguage", documentLanguage, Field.Store.NO, Index.NOT_ANALYZED)); if (publishedMaterial != null) doc.add(new Field("publishedMaterial", publishedMaterial, Field.Store.NO, Index.NOT_ANALYZED)); if (primaryDocument != null) doc.add(new Field("primaryDocument", primaryDocument, Field.Store.NO, Index.NOT_ANALYZED)); if (licenseAgreementDate != null) doc.add(new NumericField("licenseAgreementDate", Field.Store.NO, true) .setLongValue(licenseAgreementDate.getTime())); if (approvalDate != null) doc.add(new NumericField("approvalDate", Field.Store.NO, true) .setLongValue(approvalDate.getTime())); if (committeeApprovalDate != null) doc.add(new NumericField("committeeApprovalDate", Field.Store.NO, true) .setLongValue(committeeApprovalDate.getTime())); if (committeeEmbargoApprovalDate != null) doc.add(new NumericField("committeeEmbargoApprovalDate", Field.Store.NO, true) .setLongValue(committeeEmbargoApprovalDate.getTime())); if (committeeMembers != null) doc.add(new Field("committeeMembers", committeeMembers, Field.Store.NO, Index.NOT_ANALYZED)); if (committeeContactEmail != null) doc.add(new Field("committeeContactEmail", committeeContactEmail, Field.Store.NO, Index.NOT_ANALYZED)); if (umiRelease != null) doc.add(new Field("umiRelease", umiRelease, Field.Store.NO, Index.NOT_ANALYZED)); doc.add(new NumericField("customActions", Field.Store.NO, true).setIntValue(customActions)); if (degreeLevel != null) doc.add(new Field("degreeLevel", degreeLevel, Field.Store.NO, Index.NOT_ANALYZED)); if (depositId != null) doc.add(new Field("depositId", depositId, Field.Store.NO, Index.NOT_ANALYZED)); if (reviewerNotes != null) doc.add(new Field("reviewerNotes", reviewerNotes, Field.Store.NO, Index.NOT_ANALYZED)); writer.addDocument(doc); // Detach the log so it dosn't keep stacking up in memory. log.detach(); } // for logs }
From source file:org.openanzo.test.client.TestDateTime.java
/** * The java.util.Calendar API makes it tricky to get a calendar initialized in a predictable state since most ways to create it use the system default time * zone, locale, and sometimes the current time. * /*w ww. j a v a 2s .c o m*/ * This method helps ensure getting a calendar object that is more predictable across different systems. * * @return a new fairly clean Calendar, ready for you to put your dirty paws all over it. */ private Calendar getCleanCalendar() { Calendar cal = Calendar.getInstance(); cal.setTimeZone(DateUtils.UTC_TIME_ZONE); cal.clear(); cal.setLenient(false); return cal; }
From source file:org.exfio.csyncdroid.resource.LocalCalendar.java
protected List<ExceptionDates> parseExceptionDates(String property, TimeZone tz) throws ParseException { RDateList exDateList = new RDateList(property, tz); Calendar calUtc = Calendar.getInstance(TimeZone.getTimeZone("UTC")); ExceptionDates exDates = new ExceptionDates(); for (DateValue exDate : exDateList.getDatesUtc()) { calUtc.clear(); calUtc.set(exDate.year(), exDate.month(), exDate.day()); exDates.addValue(calUtc.getTime()); }/* w ww.java2 s .co m*/ List<ExceptionDates> listExDates = new ArrayList<ExceptionDates>(); listExDates.add(exDates); return listExDates; }
From source file:org.exfio.csyncdroid.resource.LocalCalendar.java
protected List<RecurrenceDates> parseRecurrenceDates(String property, TimeZone tz) throws ParseException { RDateList rDateList = new RDateList(property, tz); Calendar calUtc = Calendar.getInstance(TimeZone.getTimeZone("UTC")); RecurrenceDates recDates = new RecurrenceDates(); for (DateValue rdate : rDateList.getDatesUtc()) { calUtc.clear(); calUtc.set(rdate.year(), rdate.month(), rdate.day()); recDates.addDate(calUtc.getTime()); }// w ww . j a v a 2s. com List<RecurrenceDates> listRecDates = new ArrayList<RecurrenceDates>(); listRecDates.add(recDates); return listRecDates; }
From source file:com.netflix.genie.core.jpa.services.JpaClusterServiceImplIntegrationTests.java
/** * Test the get clusters method.//from w w w. j ava 2s .com */ @Test public void testGetClustersByMinUpdateTime() { final Calendar time = Calendar.getInstance(); time.clear(); time.set(2014, Calendar.JULY, 9, 2, 58, 59); final Page<Cluster> clusters = this.service.getClusters(null, null, null, time.getTime(), null, PAGE); Assert.assertEquals(1, clusters.getNumberOfElements()); Assert.assertEquals(CLUSTER_2_ID, clusters.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new)); }
From source file:com.netflix.genie.core.jpa.services.JpaClusterServiceImplIntegrationTests.java
/** * Test the get clusters method.//w ww . j a v a2 s . c o m */ @Test public void testGetClustersByMaxUpdateTime() { final Calendar time = Calendar.getInstance(); time.clear(); time.set(2014, Calendar.JULY, 8, 3, 0, 0); final Page<Cluster> clusters = this.service.getClusters(null, null, null, null, time.getTime(), PAGE); Assert.assertEquals(1, clusters.getNumberOfElements()); Assert.assertEquals(CLUSTER_1_ID, clusters.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new)); }