List of usage examples for java.util EnumSet range
public static <E extends Enum<E>> EnumSet<E> range(E from, E to)
From source file:Main.java
public static void main(String[] args) { final EnumSet<Style> styles = EnumSet.noneOf(Style.class); styles.addAll(EnumSet.range(Style.BOLD, Style.STRIKETHROUGH)); styles.removeAll(EnumSet.of(Style.UNDERLINE, Style.STRIKETHROUGH)); assert EnumSet.of(Style.BOLD, Style.ITALIC).equals(styles); System.out.println(styles);//from w w w . j a v a2s . c o m }
From source file:Numbers.java
public static void main(String[] args) { // create a set EnumSet<Numbers> set;/*from www .j av a 2 s.co m*/ // add one element set = EnumSet.range(Numbers.TWO, Numbers.FIVE); System.out.println(set); }
From source file:gov.nih.nci.firebird.selenium2.scalability.tests.SubmitProtocolRegistrationTest.java
private void answerAllFinancialDisclosureQuestions(FinancialDisclosureTab financialDisclosureTab) { for (Question question : EnumSet.range(Question.Q1_MONETARY_GAIN, Question.Q4_EQUITY_IN_SPONSOR)) { answerFinancialDisclosureQuestion(financialDisclosureTab, question); }// w ww . ja v a 2 s . co m }
From source file:gov.nih.nci.caarray.web.action.project.ProjectFilesAction.java
private void addJsonForExperimentDesignNodes(JSONArray jsonArray, ExperimentDesignTreeNodeType newNodesType, Collection<? extends AbstractExperimentDesignNode> nodes, String nodeIdPrefix) { for (final AbstractExperimentDesignNode node : nodes) { final JSONObject json = new JSONObject(); final String newNodeId = nodeIdPrefix + "_" + node.getId(); json.element(ID_PROPERTY, newNodeId); json.element("entityId", node.getId()); json.element(TEXT_PROPERTY, node.getName()); json.element(SORT_PROPERTY, node.getName()); json.element(NODE_TYPE_PROPERTY, newNodesType); json.element("iconCls", newNodesType.name().toLowerCase(Locale.getDefault()) + "_node"); json.element("checked", false); final JSONArray associatedRoots = new JSONArray(); if (newNodesType == ExperimentDesignTreeNodeType.SOURCE) { addJsonForSamplesRoot(associatedRoots, (AbstractBioMaterial) node, newNodeId); }// w ww. j a va 2 s . c o m if (EnumSet.of(ExperimentDesignTreeNodeType.SOURCE, ExperimentDesignTreeNodeType.SAMPLE) .contains(newNodesType)) { addJsonForExtractsRoot(associatedRoots, (AbstractBioMaterial) node, newNodeId); } if (EnumSet.range(ExperimentDesignTreeNodeType.SOURCE, ExperimentDesignTreeNodeType.EXTRACT) .contains(newNodesType)) { addJsonForLabeledExtractsRoot(associatedRoots, (AbstractBioMaterial) node, newNodeId); } if (newNodesType.isBiomaterialNode()) { addJsonForHybridizationsRoot(associatedRoots, (AbstractBioMaterial) node, newNodeId); } if (associatedRoots.isEmpty()) { json.element("leaf", true); } else { json.element("children", associatedRoots); } jsonArray.element(json); } }
From source file:org.photovault.imginfo.ChangePhotoInfoCommand.java
/** Execute the command.//from ww w . j a v a 2 s . com */ public void execute() throws CommandException { StringBuffer debugMsg = null; if (log.isDebugEnabled()) { debugMsg = new StringBuffer(); debugMsg.append("execute()"); boolean isFirst = true; for (UUID id : photoUuids) { debugMsg.append(isFirst ? "Photo ids: " : ", "); debugMsg.append(id); } debugMsg.append("\n"); debugMsg.append("Changed values:\n"); for (Map.Entry<String, Object> e : changedFields.entrySet()) { String field = e.getKey(); Object value = e.getValue(); debugMsg.append(field).append(": ").append(value).append("\n"); } log.debug(debugMsg); } PhotoInfoDAO photoDAO = daoFactory.getPhotoInfoDAO(); Set<PhotoInfo> photos = new HashSet<PhotoInfo>(); if (photoUuids.size() == 0) { PhotoInfo photo = photoDAO.create(); photos.add(photo); } else { for (UUID id : photoUuids) { PhotoInfo photo = photoDAO.findByUUID(id); photos.add(photo); } } changedPhotos = new HashSet<PhotoInfo>(); Set<PhotoInfoFields> rawSettingsFields = EnumSet.range(PhotoInfoFields.RAW_BLACK_LEVEL, PhotoInfoFields.RAW_COLOR_PROFILE); Set<PhotoInfoFields> colorCurveFields = EnumSet.range(PhotoInfoFields.COLOR_CURVE_VALUE, PhotoInfoFields.COLOR_CURVE_SATURATION); Set<PhotoInfoFields> cropFields = EnumSet.of(PhotoInfoFields.CROP_BOUNDS, PhotoInfoFields.PREF_ROTATION); DTOResolverFactory resolverFactory = daoFactory.getDTOResolverFactory(); for (PhotoInfo photo : photos) { /* Ensure that this photo is persistence & the instance belongs to current persistence context */ changedPhotos.add(photo); VersionedObjectEditor<PhotoInfo> pe = new VersionedObjectEditor(photo, resolverFactory); PhotoEditor pep = (PhotoEditor) pe.getProxy(); RawSettingsFactory rawSettingsFactory = null; ChannelMapOperationFactory channelMapFactory = null; // New processing operations ImageOpChain procChain = photo.getProcessing(); ProcGraphEditorHelper rawConvHelper = null; ProcGraphEditorHelper rawMapHelper = null; ProcGraphEditorHelper chanMapHelper = null; ProcGraphEditorHelper cropHelper = null; try { rawConvHelper = new ProcGraphEditorHelper(pe, "dcraw", DCRawOp.class); rawMapHelper = new ProcGraphEditorHelper(pe, "raw-map", DCRawMapOp.class); chanMapHelper = new ProcGraphEditorHelper(pe, "chan-map", ChanMapOp.class); cropHelper = new ProcGraphEditorHelper(pe, "crop", CropOp.class); } catch (IllegalAccessException ex) { // Should not happen log.error(ex); throw new CommandException("Unexpected problem instantiating processing grap helpers", ex); } catch (InstantiationException ex) { // Should not happen log.error(ex); throw new CommandException("Unexpected problem instantiating processing grap helpers", ex); } for (Map.Entry<String, SetChange> e : modifiedSets.entrySet()) { for (Object val : e.getValue().added) { pe.addToSet(e.getKey(), val); } for (Object val : e.getValue().removed) { pe.removeFromSet(e.getKey(), val); } } for (Map.Entry<String, Object> e : changedFields.entrySet()) { String fieldName = e.getKey(); PhotoInfoFields field = PhotoInfoFields.getByName(fieldName); Object value = e.getValue(); try { if (rawSettingsFields.contains(field)) { this.setRawField(rawConvHelper, rawMapHelper, field, value); } else if (colorCurveFields.contains(field)) { setColorMapField(chanMapHelper, field, value); } else if (field == PhotoInfoFields.CROP_BOUNDS) { Rectangle2D cropRect = (Rectangle2D) e.getValue(); cropHelper.setProperty("minX", cropRect.getMinX()); cropHelper.setProperty("maxX", cropRect.getMaxX()); cropHelper.setProperty("minY", cropRect.getMinY()); cropHelper.setProperty("maxY", cropRect.getMaxY()); } else if (field == PhotoInfoFields.PREF_ROTATION) { Double rot = (Double) e.getValue(); cropHelper.setProperty("rot", rot); } else { pe.setField(fieldName, e.getValue()); } } catch (IllegalAccessException ex) { log.error("exception while setting field " + field, ex); throw new CommandException("Illegal access while setting field " + field, ex); } catch (InvocationTargetException ex) { log.error("exception while setting field " + field, ex); throw new CommandException("Invocation target exception while setting field " + field, ex); } catch (NoSuchMethodException ex) { log.error("exception while setting field " + field, ex); throw new CommandException("Non-existing method called while setting field " + field, ex); } } ProcGraphEditorHelper[] chain = new ProcGraphEditorHelper[] { rawConvHelper, rawMapHelper, chanMapHelper, cropHelper }; String nextNodeInput = null; for (int n = chain.length - 1; n >= 0; n--) { String sourcePort = null; // Find the node that should be connected to input of current node for (int m = n - 1; m >= 0; m--) { if (chain[m].isNodeAlreadyPresent()) { sourcePort = chain[m].getNodeName() + ".out"; break; } } ProcGraphEditorHelper node = chain[n]; if (node.isNodeAlreadyPresent() || node.addNewNode(sourcePort, nextNodeInput)) { nextNodeInput = node.getNodeName() + ".in"; } } PhotoFolderDAO folderDAO = daoFactory.getPhotoFolderDAO(); FolderPhotoAssocDAO assocDAO = daoFactory.getFolderPhotoAssocDAO(); Set<PhotoFolder> af = new HashSet<PhotoFolder>(); for (UUID folderId : addedToFolders) { log.debug("Adding photo " + photo.getUuid() + " to folder " + folderId); PhotoFolder folder = folderDAO.findById(folderId, false); VersionedObjectEditor<PhotoFolder> fe = new VersionedObjectEditor<PhotoFolder>(folder, resolverFactory); FolderEditor fep = (FolderEditor) fe.getProxy(); FolderPhotoAssociation a = assocDAO.getAssociation(folder, photo); pep.addFolderAssociation(a); fep.addPhotoAssociation(a); Change<PhotoFolder> ch = fe.apply(); changes.add(new ChangeDTO<PhotoFolder>(ch)); af.add(folder); } Set<PhotoFolder> rf = new HashSet<PhotoFolder>(); Set<FolderPhotoAssociation> deletedAssocs = new HashSet<FolderPhotoAssociation>(); for (UUID folderId : removedFromFolders) { log.debug("Removing photo " + photo.getUuid() + " from folder " + folderId); PhotoFolder folder = folderDAO.findById(folderId, false); VersionedObjectEditor<PhotoFolder> fe = new VersionedObjectEditor<PhotoFolder>(folder, resolverFactory); FolderEditor fep = (FolderEditor) fe.getProxy(); FolderPhotoAssociation a = assocDAO.getAssociation(folder, photo); fep.removePhotoAssociation(a); pep.removeFolderAssociation(a); deletedAssocs.add(a); Change<PhotoFolder> ch = fe.apply(); changes.add(new ChangeDTO<PhotoFolder>(ch)); } Change<PhotoInfo> ch = pe.apply(); changes.add(new ChangeDTO<PhotoInfo>(ch)); for (FolderPhotoAssociation a : deletedAssocs) { assocDAO.makeTransient(a); } } }
From source file:org.projectforge.business.fibu.datev.EmployeeSalaryExportDao.java
/** * Exports the filtered list as table with almost all fields. *//*from ww w . j av a2 s .c o m*/ @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public byte[] export(final List<EmployeeSalaryDO> list) { log.info("Exporting employee salary list."); Validate.notEmpty(list); Collections.sort(list, new Comparator<EmployeeSalaryDO>() { @Override public int compare(final EmployeeSalaryDO o1, final EmployeeSalaryDO o2) { return (o1.getEmployee().getUser().getFullname()) .compareTo(o2.getEmployee().getUser().getFullname()); } }); final EmployeeFilter filter = new EmployeeFilter(); filter.setShowOnlyActiveEntries(true); filter.setDeleted(false); final List<EmployeeDO> employees = employeeDao.getList(filter); final List<EmployeeDO> missedEmployees = new ArrayList<EmployeeDO>(); for (final EmployeeDO employee : employees) { boolean found = false; for (final EmployeeSalaryDO salary : list) { if (salary.getEmployeeId().equals(employee.getId()) == true) { found = true; break; } } if (found == false) { missedEmployees.add(employee); } } if (CollectionUtils.isNotEmpty(missedEmployees) == true) { Collections.sort(missedEmployees, new Comparator<EmployeeDO>() { @Override public int compare(final EmployeeDO o1, final EmployeeDO o2) { return (o1.getUser().getFullname()).compareTo(o2.getUser().getFullname()); } }); } final ExportWorkbook xls = new ExportWorkbook(); final ContentProvider contentProvider = new MyContentProvider(xls); // create a default Date format and currency column xls.setContentProvider(contentProvider); final EmployeeSalaryDO first = list.get(0); final int year = first.getYear(); final int month = first.getMonth(); final DayHolder buchungsdatum = new DayHolder(); buchungsdatum.setDate(year, month, 1); final MonthHolder monthHolder = new MonthHolder(buchungsdatum.getDate()); final BigDecimal numberOfWorkingDays = monthHolder.getNumberOfWorkingDays(); buchungsdatum.setEndOfMonth(); final String sheetTitle = DateHelper.formatMonth(year, month); final ExportSheet sheet = xls.addSheet(sheetTitle); sheet.createFreezePane(0, 1); final ExportSheet employeeSheet = xls.addSheet(ThreadLocalUserContext.getLocalizedString("fibu.employee")); employeeSheet.setColumnWidth(0, MyXlsContentProvider.LENGTH_USER * 256); employeeSheet.setColumnWidth(1, 14 * 256); employeeSheet.setColumnWidth(2, 12 * 256); employeeSheet.setColumnWidth(3, 12 * 256); employeeSheet.setColumnWidth(4, 12 * 256); final ContentProvider provider = employeeSheet.getContentProvider(); provider.putFormat("STUNDEN", "0.00;[Red]-0.00"); final ExportRow employeeRow = employeeSheet.addRow(); employeeRow.addCell(0, ThreadLocalUserContext.getLocalizedString("fibu.employee")); employeeRow.addCell(1, ThreadLocalUserContext.getLocalizedString("fibu.employee.wochenstunden")); employeeRow.addCell(2, ThreadLocalUserContext.getLocalizedString("fibu.employee.sollstunden")); employeeRow.addCell(3, ThreadLocalUserContext.getLocalizedString("fibu.employee.iststunden")); employeeRow.addCell(4, ThreadLocalUserContext.getLocalizedString("fibu.common.difference")); // build all column names, title, widths from fixed and variable columns final int numCols = ExcelColumn.values().length; final String[] colNames = new String[numCols]; final String[] colTitles = new String[numCols]; final int[] colWidths = new int[numCols]; int idx = 0; for (final ExcelColumn col : EnumSet.range(ExcelColumn.START, ExcelColumn.END)) { colNames[idx] = col.name(); colTitles[idx] = ThreadLocalUserContext.getLocalizedString(col.theTitle); colWidths[idx] = col.width; ++idx; } // column property names sheet.setPropertyNames(colNames); final ContentProvider sheetProvider = sheet.getContentProvider(); sheetProvider.putFormat("STUNDEN", "0.00"); sheetProvider.putFormat("BRUTTO_MIT_AG", "#,##0.00;[Red]-#,##0.00"); sheetProvider.putFormat("KORREKTUR", "#,##0.00;[Red]-#,##0.00"); sheetProvider.putFormat("SUMME", "#,##0.00;[Red]-#,##0.00"); sheetProvider.putFormat("KOST1", "#"); sheetProvider.putFormat("KOST2", "#"); sheetProvider.putFormat("KONTO", "#"); sheetProvider.putFormat("GEGENKONTO", "#"); sheetProvider.putFormat("DATUM", "dd.MM.yyyy"); // inform provider of column widths for (int ci = 0; ci < colWidths.length; ++ci) { sheetProvider.putColWidth(ci, colWidths[ci]); } final ExportRow headRow = sheet.addRow(); int i = 0; for (final String title : colTitles) { headRow.addCell(i++, title); } for (final EmployeeSalaryDO salary : list) { final PropertyMapping mapping = new PropertyMapping(); final PFUserDO user = getUserGroupCache().getUser(salary.getEmployee().getUserId()); Validate.isTrue(year == salary.getYear()); Validate.isTrue(month == salary.getMonth()); final MonthlyEmployeeReport report = monthlyEmployeeReportDao.getReport(year, month, user); mapping.add(ExcelColumn.MITARBEITER, user.getFullname()); final Kost1DO kost1 = salary.getEmployee().getKost1(); final BigDecimal bruttoMitAGAnteil = salary.getBruttoMitAgAnteil(); final BigDecimal netDuration = new BigDecimal(report.getTotalNetDuration()); final Map<String, Kost2Row> rows = report.getKost2Rows(); BigDecimal sum = BigDecimal.ZERO; int j = rows.size(); for (final Kost2Row row : rows.values()) { final Kost2DO kost2 = row.getKost2(); final MonthlyEmployeeReportEntry entry = report.getKost2Durations().get(kost2.getId()); mapping.add(ExcelColumn.KOST1, kost1.getNummer()); mapping.add(ExcelColumn.MITARBEITER, user.getFullname()); mapping.add(ExcelColumn.KOST2, kost2.getNummer()); final BigDecimal duration = new BigDecimal(entry.getMillis() / 1000); // Seconds // duration = duration.divide(new BigDecimal(60 * 60 * 24), 8, RoundingMode.HALF_UP); // Fraction of day (24 hours) // mapping.add(ExcelColumn.STUNDEN, duration); mapping.add(ExcelColumn.STUNDEN, duration.divide(new BigDecimal(3600), 2, RoundingMode.HALF_UP)); mapping.add(ExcelColumn.BEZEICHNUNG, kost2.getToolTip()); final BigDecimal betrag; if (NumberHelper.isNotZero(netDuration) == true) { betrag = CurrencyHelper.multiply(bruttoMitAGAnteil, new BigDecimal(entry.getMillis()).divide(netDuration, 8, RoundingMode.HALF_UP)); } else { betrag = BigDecimal.ZERO; } sum = sum.add(betrag); if (--j == 0) { final BigDecimal korrektur = bruttoMitAGAnteil.subtract(sum); mapping.add(ExcelColumn.BRUTTO_MIT_AG, betrag.add(korrektur)); mapping.add(ExcelColumn.KORREKTUR, korrektur); if (NumberHelper.isEqual(sum.add(korrektur), bruttoMitAGAnteil) == true) { mapping.add(ExcelColumn.SUMME, bruttoMitAGAnteil); } else { mapping.add(ExcelColumn.SUMME, "*** " + sum + " != " + bruttoMitAGAnteil); } } else { mapping.add(ExcelColumn.BRUTTO_MIT_AG, betrag); mapping.add(ExcelColumn.KORREKTUR, ""); mapping.add(ExcelColumn.SUMME, ""); } mapping.add(ExcelColumn.DATUM, buchungsdatum.getCalendar()); // Last day of month mapping.add(ExcelColumn.KONTO, KONTO); // constant. mapping.add(ExcelColumn.GEGENKONTO, GEGENKONTO); // constant. sheet.addRow(mapping.getMapping(), 0); } addEmployeeRow(employeeSheet, salary.getEmployee(), numberOfWorkingDays, netDuration); } for (final EmployeeDO employee : missedEmployees) { final PFUserDO user = getUserGroupCache().getUser(employee.getUserId()); final PropertyMapping mapping = new PropertyMapping(); mapping.add(ExcelColumn.MITARBEITER, user.getFullname()); mapping.add(ExcelColumn.SUMME, "***"); mapping.add(ExcelColumn.BEZEICHNUNG, "*** FEHLT! ***"); sheet.addRow(mapping.getMapping(), 0); final MonthlyEmployeeReport report = monthlyEmployeeReportDao.getReport(year, month, user); final BigDecimal netDuration = new BigDecimal(report.getTotalNetDuration()); addEmployeeRow(employeeSheet, employee, numberOfWorkingDays, netDuration); } // sheet.setZoom(3, 4); // 75% final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { xls.write(baos); } catch (final IOException ex) { log.fatal("Exception encountered " + ex, ex); throw new RuntimeException(ex); } return baos.toByteArray(); }
From source file:org.projectforge.fibu.datev.EmployeeSalaryExportDao.java
/** * Exports the filtered list as table with almost all fields. *//* w w w . j a va 2 s .c om*/ @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public byte[] export(final List<EmployeeSalaryDO> list) { log.info("Exporting employee salary list."); Validate.notEmpty(list); Collections.sort(list, new Comparator<EmployeeSalaryDO>() { public int compare(final EmployeeSalaryDO o1, final EmployeeSalaryDO o2) { return (o1.getEmployee().getUser().getFullname()) .compareTo(o2.getEmployee().getUser().getFullname()); } }); final EmployeeFilter filter = new EmployeeFilter(); filter.setShowOnlyActiveEntries(true); filter.setDeleted(false); final List<EmployeeDO> employees = employeeDao.getList(filter); final List<EmployeeDO> missedEmployees = new ArrayList<EmployeeDO>(); for (final EmployeeDO employee : employees) { boolean found = false; for (final EmployeeSalaryDO salary : list) { if (salary.getEmployeeId().equals(employee.getId()) == true) { found = true; break; } } if (found == false) { missedEmployees.add(employee); } } if (CollectionUtils.isNotEmpty(missedEmployees) == true) { Collections.sort(missedEmployees, new Comparator<EmployeeDO>() { public int compare(final EmployeeDO o1, final EmployeeDO o2) { return (o1.getUser().getFullname()).compareTo(o2.getUser().getFullname()); } }); } final ExportWorkbook xls = new ExportWorkbook(); final ContentProvider contentProvider = new MyContentProvider(xls); // create a default Date format and currency column xls.setContentProvider(contentProvider); final EmployeeSalaryDO first = list.get(0); final int year = first.getYear(); final int month = first.getMonth(); final DayHolder buchungsdatum = new DayHolder(); buchungsdatum.setDate(year, month, 1); final MonthHolder monthHolder = new MonthHolder(buchungsdatum.getDate()); final BigDecimal numberOfWorkingDays = monthHolder.getNumberOfWorkingDays(); buchungsdatum.setEndOfMonth(); final String sheetTitle = DateHelper.formatMonth(year, month); final ExportSheet sheet = xls.addSheet(sheetTitle); sheet.createFreezePane(0, 1); final ExportSheet employeeSheet = xls.addSheet(PFUserContext.getLocalizedString("fibu.employee")); employeeSheet.setColumnWidth(0, XlsContentProvider.LENGTH_USER * 256); employeeSheet.setColumnWidth(1, 14 * 256); employeeSheet.setColumnWidth(2, 12 * 256); employeeSheet.setColumnWidth(3, 12 * 256); employeeSheet.setColumnWidth(4, 12 * 256); final ContentProvider provider = employeeSheet.getContentProvider(); provider.putFormat("STUNDEN", "0.00;[Red]-0.00"); final ExportRow employeeRow = employeeSheet.addRow(); employeeRow.addCell(0, PFUserContext.getLocalizedString("fibu.employee")); employeeRow.addCell(1, PFUserContext.getLocalizedString("fibu.employee.wochenstunden")); employeeRow.addCell(2, PFUserContext.getLocalizedString("fibu.employee.sollstunden")); employeeRow.addCell(3, PFUserContext.getLocalizedString("fibu.employee.iststunden")); employeeRow.addCell(4, PFUserContext.getLocalizedString("fibu.common.difference")); // build all column names, title, widths from fixed and variable columns final int numCols = ExcelColumn.values().length; final String[] colNames = new String[numCols]; final String[] colTitles = new String[numCols]; final int[] colWidths = new int[numCols]; int idx = 0; for (final ExcelColumn col : EnumSet.range(ExcelColumn.START, ExcelColumn.END)) { colNames[idx] = col.name(); colTitles[idx] = PFUserContext.getLocalizedString(col.theTitle); colWidths[idx] = col.width; ++idx; } // column property names sheet.setPropertyNames(colNames); final ContentProvider sheetProvider = sheet.getContentProvider(); sheetProvider.putFormat("STUNDEN", "0.00"); sheetProvider.putFormat("BRUTTO_MIT_AG", "#,##0.00;[Red]-#,##0.00"); sheetProvider.putFormat("KORREKTUR", "#,##0.00;[Red]-#,##0.00"); sheetProvider.putFormat("SUMME", "#,##0.00;[Red]-#,##0.00"); sheetProvider.putFormat("KOST1", "#"); sheetProvider.putFormat("KOST2", "#"); sheetProvider.putFormat("KONTO", "#"); sheetProvider.putFormat("GEGENKONTO", "#"); sheetProvider.putFormat("DATUM", "dd.MM.yyyy"); // inform provider of column widths for (int ci = 0; ci < colWidths.length; ++ci) { sheetProvider.putColWidth(ci, colWidths[ci]); } final ExportRow headRow = sheet.addRow(); int i = 0; for (final String title : colTitles) { headRow.addCell(i++, title); } for (final EmployeeSalaryDO salary : list) { final PropertyMapping mapping = new PropertyMapping(); final PFUserDO user = userGroupCache.getUser(salary.getEmployee().getUserId()); Validate.isTrue(year == salary.getYear()); Validate.isTrue(month == salary.getMonth()); final MonthlyEmployeeReport report = monthlyEmployeeReportDao.getReport(year, month, user); mapping.add(ExcelColumn.MITARBEITER, user.getFullname()); final Kost1DO kost1 = salary.getEmployee().getKost1(); final BigDecimal bruttoMitAGAnteil = salary.getBruttoMitAgAnteil(); final BigDecimal netDuration = new BigDecimal(report.getTotalNetDuration()); final Map<String, Kost2Row> rows = report.getKost2Rows(); BigDecimal sum = BigDecimal.ZERO; int j = rows.size(); for (final Kost2Row row : rows.values()) { final Kost2DO kost2 = row.getKost2(); final MonthlyEmployeeReportEntry entry = report.getKost2Durations().get(kost2.getId()); mapping.add(ExcelColumn.KOST1, kost1.getNummer()); mapping.add(ExcelColumn.MITARBEITER, user.getFullname()); mapping.add(ExcelColumn.KOST2, kost2.getNummer()); final BigDecimal duration = new BigDecimal(entry.getMillis() / 1000); // Seconds // duration = duration.divide(new BigDecimal(60 * 60 * 24), 8, RoundingMode.HALF_UP); // Fraction of day (24 hours) // mapping.add(ExcelColumn.STUNDEN, duration); mapping.add(ExcelColumn.STUNDEN, duration.divide(new BigDecimal(3600), 2, RoundingMode.HALF_UP)); mapping.add(ExcelColumn.BEZEICHNUNG, kost2.getToolTip()); final BigDecimal betrag = CurrencyHelper.multiply(bruttoMitAGAnteil, new BigDecimal(entry.getMillis()).divide(netDuration, 8, RoundingMode.HALF_UP)); sum = sum.add(betrag); if (--j == 0) { final BigDecimal korrektur = bruttoMitAGAnteil.subtract(sum); mapping.add(ExcelColumn.BRUTTO_MIT_AG, betrag.add(korrektur)); mapping.add(ExcelColumn.KORREKTUR, korrektur); if (NumberHelper.isEqual(sum.add(korrektur), bruttoMitAGAnteil) == true) { mapping.add(ExcelColumn.SUMME, bruttoMitAGAnteil); } else { mapping.add(ExcelColumn.SUMME, "*** " + sum + " != " + bruttoMitAGAnteil); } } else { mapping.add(ExcelColumn.BRUTTO_MIT_AG, betrag); mapping.add(ExcelColumn.KORREKTUR, ""); mapping.add(ExcelColumn.SUMME, ""); } mapping.add(ExcelColumn.DATUM, buchungsdatum.getCalendar()); // Last day of month mapping.add(ExcelColumn.KONTO, KONTO); // constant. mapping.add(ExcelColumn.GEGENKONTO, GEGENKONTO); // constant. sheet.addRow(mapping.getMapping(), 0); } addEmployeeRow(employeeSheet, salary.getEmployee(), numberOfWorkingDays, netDuration); } for (final EmployeeDO employee : missedEmployees) { final PFUserDO user = userGroupCache.getUser(employee.getUserId()); final PropertyMapping mapping = new PropertyMapping(); mapping.add(ExcelColumn.MITARBEITER, user.getFullname()); mapping.add(ExcelColumn.SUMME, "***"); mapping.add(ExcelColumn.BEZEICHNUNG, "*** FEHLT! ***"); sheet.addRow(mapping.getMapping(), 0); final MonthlyEmployeeReport report = monthlyEmployeeReportDao.getReport(year, month, user); final BigDecimal netDuration = new BigDecimal(report.getTotalNetDuration()); addEmployeeRow(employeeSheet, employee, numberOfWorkingDays, netDuration); } // sheet.setZoom(3, 4); // 75% final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { xls.write(baos); } catch (final IOException ex) { log.fatal("Exception encountered " + ex, ex); throw new RuntimeException(ex); } return baos.toByteArray(); }
From source file:pcgen.gui2.facade.DescriptionFacadeImpl.java
/** * Add any custom biography fields already registered for the character. *///from w w w.j av a2s . c om private void addCharacterCustomFields() { for (BiographyField field : EnumSet.range(BiographyField.SPEECH_PATTERN, BiographyField.CATCH_PHRASE)) { if (StringUtils.isNotEmpty(getBiographyField(field).get())) { customBiographyFields.addElement(field); } } }
From source file:pcgen.gui2.facade.EquipmentBuilderFacadeImpl.java
/** * Create a new EquipmentBuilderFacadeImpl instance for the customization of * a particular item of equipment for the character. * @param equip The equipment item being customized (must not be the base item). * @param character The character the equipment will be for. * @param delegate The handler for UI functions such as dialogs. *//*from w w w . j ava 2s .com*/ EquipmentBuilderFacadeImpl(Equipment equip, PlayerCharacter character, UIDelegate delegate) { this.equip = equip; this.character = character; this.delegate = delegate; sizeRef = new DefaultReferenceFacade<>(equip.getSizeAdjustment()); final String sBaseKey = equip.getBaseItemKeyName(); baseEquipment = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Equipment.class, sBaseKey); equipHeads = equip.isDouble() ? EnumSet.range(EquipmentHead.PRIMARY, EquipmentHead.SECONDARY) : EnumSet.of(EquipmentHead.PRIMARY); availListMap = new HashMap<>(); selectedListMap = new HashMap<>(); for (EquipmentHead head : equipHeads) { availListMap.put(head, new DefaultListFacade<>()); DefaultListFacade<EquipModFacade> selectedList = new DefaultListFacade<>(); selectedList.setContents(equip.getEqModifierList(head.isPrimary())); selectedListMap.put(head, selectedList); } refreshAvailList(); }