List of usage examples for java.util EnumSet noneOf
public static <E extends Enum<E>> EnumSet<E> noneOf(Class<E> elementType)
From source file:uk.org.rbc1b.roms.controller.volunteer.VolunteersController.java
/** * Display the form to edit the info under the spiritual tab on the * volunteer./*from ww w. jav a 2 s . co m*/ * * @param volunteerId volunteer id to edit * @param model mvc model * @return view name */ @RequestMapping(value = "{volunteerId}/spiritual/edit", method = RequestMethod.GET) @PreAuthorize("hasPermission('VOLUNTEER', 'EDIT')") public String showEditVolunteerSpiritualForm(@PathVariable Integer volunteerId, ModelMap model) { Volunteer volunteer = volunteerDao.findVolunteer(volunteerId, EnumSet.noneOf(VolunteerData.class)); if (volunteer == null) { throw new ResourceNotFoundException("No volunteer #" + volunteerId + " found"); } VolunteerSpiritualForm form = new VolunteerSpiritualForm(); form.setAppointmentCode(volunteer.getAppointmentCode()); form.setBaptismDate(DataConverterUtil.toDateTime(volunteer.getBaptismDate())); if (volunteer.getPerson().getCongregation() != null) { Congregation congregation = congregationDao .findCongregation(volunteer.getPerson().getCongregation().getCongregationId()); form.setCongregationName(congregation.getName()); form.setCongregationId(congregation.getCongregationId()); } form.setFulltimeCode(volunteer.getFulltimeCode()); model.addAttribute("volunteerSpiritual", form); model.addAttribute("forename", volunteer.getPerson().getForename()); model.addAttribute("surname", volunteer.getPerson().getSurname()); model.addAttribute("fulltimeValues", referenceDao.findFulltimeValues()); model.addAttribute("appointmentValues", referenceDao.findAppointmentValues()); model.addAttribute("submitUri", VolunteerModelFactory.generateUri(volunteerId) + "/spiritual"); return "volunteers/edit-spiritual"; }
From source file:org.photovault.imginfo.PhotoInfo.java
/** Creates new thumbnail and preview instances for this image on specific volume @param volume The volume in which the instance is to be created //from ww w . j a v a 2 s.co m @deprecated Use {@link PhotoInstanceCreator} instead */ protected void createThumbnail(VolumeBase volume, boolean createPreview) { log.debug("Creating thumbnail for " + getUuid()); // Maximum size of the thumbnail int maxThumbWidth = 100; int maxThumbHeight = 100; checkCropBounds(); /* Determine the minimum size for the instance used for thumbnail creation to get decent image quality. The cropped portion of the image must be roughly the same resolution as the intended thumbnail. */ double cropWidth = cropMaxX - cropMinX; cropWidth = (cropWidth > 0.000001) ? cropWidth : 1.0; double cropHeight = cropMaxY - cropMinY; cropHeight = (cropHeight > 0.000001) ? cropHeight : 1.0; int minInstanceWidth = (int) (((double) maxThumbWidth) / cropWidth); int minInstanceHeight = (int) (((double) maxThumbHeight) / cropHeight); int minInstanceSide = Math.max(minInstanceWidth, minInstanceHeight); // Find the original image to use as a staring point EnumSet<ImageOperations> allowedOps = EnumSet.allOf(ImageOperations.class); if (createPreview) { // We need to create also the preview image, so we need original. allowedOps = EnumSet.noneOf(ImageOperations.class); minInstanceWidth = 1024; minInstanceHeight = 1024; } ImageDescriptorBase srcImage = this.getPreferredImage(EnumSet.noneOf(ImageOperations.class), allowedOps, minInstanceWidth, minInstanceHeight, Integer.MAX_VALUE, Integer.MAX_VALUE); if (srcImage == null) { // If there are no uncorrupted instances, no thumbnail can be created log.warn("Error - no original image was found!!!"); return; } log.debug("Found original, reading it..."); /* We try to ensure that the thumbnail is actually from the original image by comparing aspect ratio of it to original. This is not a perfect check but it will usually catch the most typical errors (like having a the original rotated by RAW conversion SW but still the original EXIF thumbnail. */ double origAspect = this.getAspect(original.getWidth(), original.getHeight(), 1.0); double aspectAccuracy = 0.01; // First, check if there is a thumbnail in image header RenderedImage origImage = null; // Read the image RenderedImage thumbImage = null; RenderedImage previewImage = null; try { File imageFile = srcImage.getFile().findAvailableCopy(); PhotovaultImageFactory imgFactory = new PhotovaultImageFactory(); PhotovaultImage img = imgFactory.create(imageFile, false, false); ChannelMapOperation channelMap = getColorChannelMapping(); if (channelMap != null) { img.setColorAdjustment(channelMap); } if (img instanceof RawImage) { RawImage ri = (RawImage) img; ri.setRawSettings(getProcessing().getRawConvSettings()); } if (createPreview) { // Calculate preview image size int previewWidth = img.getWidth(); int previewHeight = img.getHeight(); while (previewWidth > 2048 || previewHeight > 2048) { previewWidth >>= 1; previewHeight >>= 1; } previewImage = img.getRenderedImage(previewWidth, previewHeight, false); } img.setCropBounds(this.getCropBounds()); double srcRotation = 0.0; if (srcImage instanceof CopyImageDescriptor) { srcRotation = ((CopyImageDescriptor) srcImage).getRotation(); } img.setRotation(getPrefRotation() - srcRotation); thumbImage = img.getRenderedImage(maxThumbWidth, maxThumbHeight, true); } catch (Exception e) { log.warn("Error reading image: " + e.getMessage()); // TODO: If we aborted here due to image writing problem we would have // problems later with non-existing transaction. We should really // rethink the error handling logic in the whole function. Anyway, we // haven't changed anything yet so we can safely commit the tx. return; } log.debug("Done, finding name"); // Find where to store the file in the target volume File thumbnailFile = volume.getInstanceName(this, "jpg"); log.debug("name = " + thumbnailFile.getName()); try { saveInstance(thumbnailFile, thumbImage); if (thumbImage instanceof PlanarImage) { ((PlanarImage) thumbImage).dispose(); System.gc(); } } catch (PhotovaultException ex) { log.error("error writing thumbnail for " + srcImage.getFile().findAvailableCopy().getAbsolutePath() + ": " + ex.getMessage()); // TODO: If we abort here due to image writing problem we will have // problems later with non-existing transaction. We should really // rethink the error handling login in the whole function. Anyway, we // haven't changed anything yet so we can safely commit the tx. return; } try { ImageFile thumbFile; thumbFile = new ImageFile(thumbnailFile); CopyImageDescriptor thumbImageDesc = new CopyImageDescriptor(thumbFile, "image#0", original); thumbImageDesc.setRotation(getPrefRotation()); thumbImageDesc.setCropArea(getCropBounds()); thumbImageDesc.setColorChannelMapping(getColorChannelMapping()); thumbImageDesc.setRawSettings(getProcessing().getRawConvSettings()); thumbFile.addLocation(new FileLocation(volume, volume.mapFileToVolumeRelativeName(thumbnailFile))); } catch (Exception ex) { log.error("Error creating thumb instance: " + ex.getMessage()); } log.debug("Loading thumbnail..."); thumbnail = Thumbnail.createThumbnail(this, thumbnailFile); oldThumbnail = null; log.debug("Thumbnail loaded"); /* if ( createPreview ) { File previewFile = volume.getInstanceName( this, "jpg" ); try { saveInstance( previewFile, previewImage ); if ( previewImage instanceof PlanarImage ) { ((PlanarImage)previewImage).dispose(); System.gc(); } } catch (PhotovaultException ex) { log.error( "error writing preview for " + srcImage.getFile().findAvailableCopy() + ": " + ex.getMessage() ); return; } ImageInstance previewInstance = addInstance( volume, previewFile, ImageInstance.INSTANCE_TYPE_MODIFIED ); previewInstance.setColorChannelMapping( channelMap ); previewInstance.setRawSettings( rawSettings ); } txw.commit(); */ }
From source file:com.itude.mobile.mobbl.core.controller.MBViewManager.java
/** * @param showFirst/* w w w . j a v a2s . c o m*/ * @param notifyListener * * @deprecated please use {@link #invalidateActionBar(EnumSet)} */ @Deprecated public void invalidateActionBar(boolean showFirst, boolean notifyListener) { EnumSet<MBActionBarInvalidationOption> options = EnumSet.noneOf(MBActionBarInvalidationOption.class); if (showFirst) { options.add(MBActionBarInvalidationOption.SHOW_FIRST); } if (notifyListener) { options.add(MBActionBarInvalidationOption.NOTIFY_LISTENER); } invalidateActionBar(options); }
From source file:org.dcm4che.tool.dcmqrscp.DcmQRSCP.java
private static void configureTransferCapability(DcmQRSCP main, CommandLine cl) throws IOException { ApplicationEntity ae = main.ae;/*from ww w . j av a 2 s. c om*/ EnumSet<QueryOption> queryOptions = cl.hasOption("relational") ? EnumSet.of(QueryOption.RELATIONAL) : EnumSet.noneOf(QueryOption.class); boolean storage = !cl.hasOption("no-storage") && main.isWriteable(); if (storage && cl.hasOption("all-storage")) { TransferCapability tc = new TransferCapability(null, "*", TransferCapability.Role.SCP, "*"); tc.setQueryOptions(queryOptions); ae.addTransferCapability(tc); } else { ae.addTransferCapability(new TransferCapability(null, UID.VerificationSOPClass, TransferCapability.Role.SCP, UID.ImplicitVRLittleEndian)); Properties storageSOPClasses = CLIUtils.loadProperties( cl.getOptionValue("storage-sop-classes", "resource:storage-sop-classes.properties"), null); if (storage) addTransferCapabilities(ae, storageSOPClasses, TransferCapability.Role.SCP, null); if (!cl.hasOption("no-retrieve")) { addTransferCapabilities(ae, storageSOPClasses, TransferCapability.Role.SCU, null); Properties p = CLIUtils.loadProperties( cl.getOptionValue("retrieve-sop-classes", "resource:retrieve-sop-classes.properties"), null); addTransferCapabilities(ae, p, TransferCapability.Role.SCP, queryOptions); } if (!cl.hasOption("no-query")) { Properties p = CLIUtils.loadProperties( cl.getOptionValue("query-sop-classes", "resource:query-sop-classes.properties"), null); addTransferCapabilities(ae, p, TransferCapability.Role.SCP, queryOptions); } } if (storage) main.openDicomDir(); else main.openDicomDirForReadOnly(); }
From source file:org.opencb.opencga.catalog.auth.authorization.CatalogAuthorizationManager.java
private JobAclEntry resolveJobPermissions(long studyId, String userId, String groupId, Map<String, JobAclEntry> userAclMap) throws CatalogException { if (userId.equals(ANONYMOUS)) { if (userAclMap.containsKey(userId)) { return userAclMap.get(userId); } else {// w w w .ja v a 2 s . com return transformStudyAclToJobAcl(getStudyAclBelonging(studyId, userId, groupId)); } } // Registered user EnumSet<JobAclEntry.JobPermissions> permissions = EnumSet.noneOf(JobAclEntry.JobPermissions.class); boolean flagPermissionFound = false; if (userAclMap.containsKey(userId)) { permissions.addAll(userAclMap.get(userId).getPermissions()); flagPermissionFound = true; } if (StringUtils.isNotEmpty(groupId) && userAclMap.containsKey(groupId)) { permissions.addAll(userAclMap.get(groupId).getPermissions()); flagPermissionFound = true; } if (userAclMap.containsKey(ANONYMOUS)) { permissions.addAll(userAclMap.get(ANONYMOUS).getPermissions()); flagPermissionFound = true; } if (userAclMap.containsKey(OTHER_USERS_ID)) { permissions.addAll(userAclMap.get(OTHER_USERS_ID).getPermissions()); flagPermissionFound = true; } if (flagPermissionFound) { return new JobAclEntry(userId, permissions); } else { return transformStudyAclToJobAcl(getStudyAclBelonging(studyId, userId, groupId)); } }
From source file:com.itude.mobile.mobbl.core.controller.MBViewManager.java
/** * @param showFirst/* w w w . j av a2 s.com*/ * @param notifyListener * @param resetHomeDialog * * @deprecated please use {@link #invalidateActionBar(EnumSet)} */ @Deprecated public void invalidateActionBar(boolean showFirst, boolean notifyListener, final boolean resetHomeDialog) { EnumSet<MBActionBarInvalidationOption> options = EnumSet.noneOf(MBActionBarInvalidationOption.class); if (showFirst) { options.add(MBActionBarInvalidationOption.SHOW_FIRST); } if (notifyListener) { options.add(MBActionBarInvalidationOption.NOTIFY_LISTENER); } if (resetHomeDialog) { options.add(MBActionBarInvalidationOption.RESET_HOME_DIALOG); } invalidateActionBar(options); }
From source file:org.ops4j.pax.web.service.tomcat.internal.TomcatServerWrapper.java
private EnumSet<DispatcherType> getDispatcherTypes(final FilterModel filterModel) { final ArrayList<DispatcherType> dispatcherTypes = new ArrayList<DispatcherType>( DispatcherType.values().length); for (final String dispatcherType : filterModel.getDispatcher()) { dispatcherTypes.add(DispatcherType.valueOf(dispatcherType.toUpperCase())); }//from w w w . j ava2 s . com EnumSet<DispatcherType> result = EnumSet.noneOf(DispatcherType.class); if (dispatcherTypes != null && dispatcherTypes.size() > 0) { result = EnumSet.copyOf(dispatcherTypes); } return result; }
From source file:org.apache.hadoop.fs.TestEnhancedByteBufferAccess.java
/** * Test that we can zero-copy read cached data even without disabling * checksums./*w ww . ja va2s .c om*/ */ @Test(timeout = 120000) public void testZeroCopyReadOfCachedData() throws Exception { BlockReaderTestUtil.enableShortCircuitShmTracing(); BlockReaderTestUtil.enableBlockReaderFactoryTracing(); BlockReaderTestUtil.enableHdfsCachingTracing(); final int TEST_FILE_LENGTH = BLOCK_SIZE; final Path TEST_PATH = new Path("/a"); final int RANDOM_SEED = 23453; HdfsConfiguration conf = initZeroCopyTest(); conf.setBoolean(DFSConfigKeys.DFS_CLIENT_READ_SHORTCIRCUIT_SKIP_CHECKSUM_KEY, false); final String CONTEXT = "testZeroCopyReadOfCachedData"; conf.set(DFSConfigKeys.DFS_CLIENT_CONTEXT, CONTEXT); conf.setLong(DFS_DATANODE_MAX_LOCKED_MEMORY_KEY, DFSTestUtil.roundUpToMultiple(TEST_FILE_LENGTH, (int) NativeIO.POSIX.getCacheManipulator().getOperatingSystemPageSize())); MiniDFSCluster cluster = null; ByteBuffer result = null, result2 = null; cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build(); cluster.waitActive(); FsDatasetSpi<?> fsd = cluster.getDataNodes().get(0).getFSDataset(); DistributedFileSystem fs = cluster.getFileSystem(); DFSTestUtil.createFile(fs, TEST_PATH, TEST_FILE_LENGTH, (short) 1, RANDOM_SEED); DFSTestUtil.waitReplication(fs, TEST_PATH, (short) 1); byte original[] = DFSTestUtil.calculateFileContentsFromSeed(RANDOM_SEED, TEST_FILE_LENGTH); // Prior to caching, the file can't be read via zero-copy FSDataInputStream fsIn = fs.open(TEST_PATH); try { result = fsIn.read(null, TEST_FILE_LENGTH / 2, EnumSet.noneOf(ReadOption.class)); Assert.fail("expected UnsupportedOperationException"); } catch (UnsupportedOperationException e) { // expected } // Cache the file fs.addCachePool(new CachePoolInfo("pool1")); long directiveId = fs.addCacheDirective(new CacheDirectiveInfo.Builder().setPath(TEST_PATH) .setReplication((short) 1).setPool("pool1").build()); int numBlocks = (int) Math.ceil((double) TEST_FILE_LENGTH / BLOCK_SIZE); DFSTestUtil.verifyExpectedCacheUsage(DFSTestUtil.roundUpToMultiple(TEST_FILE_LENGTH, BLOCK_SIZE), numBlocks, cluster.getDataNodes().get(0).getFSDataset()); try { result = fsIn.read(null, TEST_FILE_LENGTH, EnumSet.noneOf(ReadOption.class)); } catch (UnsupportedOperationException e) { Assert.fail("expected to be able to read cached file via zero-copy"); } Assert.assertArrayEquals(Arrays.copyOfRange(original, 0, BLOCK_SIZE), byteBufferToArray(result)); // Test that files opened after the cache operation has finished // still get the benefits of zero-copy (regression test for HDFS-6086) FSDataInputStream fsIn2 = fs.open(TEST_PATH); try { result2 = fsIn2.read(null, TEST_FILE_LENGTH, EnumSet.noneOf(ReadOption.class)); } catch (UnsupportedOperationException e) { Assert.fail("expected to be able to read cached file via zero-copy"); } Assert.assertArrayEquals(Arrays.copyOfRange(original, 0, BLOCK_SIZE), byteBufferToArray(result2)); fsIn2.releaseBuffer(result2); fsIn2.close(); // check that the replica is anchored final ExtendedBlock firstBlock = DFSTestUtil.getFirstBlock(fs, TEST_PATH); final ShortCircuitCache cache = ClientContext.get(CONTEXT, new DFSClient.Conf(conf)).getShortCircuitCache(); waitForReplicaAnchorStatus(cache, firstBlock, true, true, 1); // Uncache the replica fs.removeCacheDirective(directiveId); waitForReplicaAnchorStatus(cache, firstBlock, false, true, 1); fsIn.releaseBuffer(result); waitForReplicaAnchorStatus(cache, firstBlock, false, false, 1); DFSTestUtil.verifyExpectedCacheUsage(0, 0, fsd); fsIn.close(); fs.close(); cluster.shutdown(); }
From source file:org.photovault.imginfo.Test_PhotoInfo.java
@Test public void testPreferredImageSelection() throws CommandException { File f = new File(testImgDir, "test1.jpg"); PhotoInfo photo = createPhoto(f);/* w w w . j a va 2 s . co m*/ VolumeDAO volDAO = daoFactory.getVolumeDAO(); File instanceFile = volDAO.getDefaultVolume().getFilingFname(f); try { FileUtils.copyFile(f, instanceFile); } catch (IOException e) { fail(e.getMessage()); } ModifyImageFileCommand fileCmd = new ModifyImageFileCommand(photo.getOriginal().getFile()); Volume vol = volDAO.getDefaultVolume(); fileCmd.addLocation(vol.getFileLocation(instanceFile)); cmdHandler.executeCommand(fileCmd); // Create a copy CreateCopyImageCommand copyCmd = new CreateCopyImageCommand(photo, vol, 200, 200); CreateCopyImageCommand copy2Cmd = new CreateCopyImageCommand(photo, vol, 100, 100); CreateCopyImageCommand copy3Cmd = new CreateCopyImageCommand(photo, vol, 300, 300); copy3Cmd.setOperationsToApply(EnumSet.of(ImageOperations.COLOR_MAP)); cmdHandler.executeCommand(copyCmd); cmdHandler.executeCommand(copy2Cmd); cmdHandler.executeCommand(copy3Cmd); ImageDescriptorBase img = photo.getPreferredImage(EnumSet.allOf(ImageOperations.class), EnumSet.allOf(ImageOperations.class), 0, 0, 100, 100); assertEquals(100, img.getWidth()); img = photo.getPreferredImage(EnumSet.allOf(ImageOperations.class), EnumSet.allOf(ImageOperations.class), 150, 150, 300, 300); assertEquals(200, img.getWidth()); photo.setPrefRotation(90); img = photo.getPreferredImage(EnumSet.allOf(ImageOperations.class), EnumSet.allOf(ImageOperations.class), 150, 150, 300, 300); assertNull(img); img = photo.getPreferredImage(EnumSet.noneOf(ImageOperations.class), EnumSet.allOf(ImageOperations.class), 201, 201, 300, 300); assertEquals(300, img.getWidth()); }
From source file:org.apache.hadoop.fs.FileContextMainOperationsBaseTest.java
@Test(expected = HadoopIllegalArgumentException.class) public void testEmptyCreateFlag() throws IOException { Path p = getTestRootPath(fc, "test/file"); fc.create(p, EnumSet.noneOf(CreateFlag.class)); Assert.fail("Excepted exception not thrown"); }