/** * Copies the specified channel. * * @param channel The channel to copy. * @return See above. */ private Channel copyChannel(Channel channel) { if (channel == null) return null; Channel newChannel = new ShallowCopy().copy(channel); newChannel.setLogicalChannel(new ShallowCopy().copy(channel .getLogicalChannel())); if (channel.getStatsInfo() != null) { newChannel.setStatsInfo(new ShallowCopy().copy(channel.getStatsInfo())); } return newChannel; }
public <T extends IObject> T copy(T original) { T f = ShallowCopy.reflectiveNewInstance(original); SetValues set = new SetValues(f); original.acceptFilter(set); return f; }
/** * Copies the specified pixels set. * * @param pixels The pixels to set. */ @SuppressWarnings("unchecked") private Pixels copyPixels(Pixels pixels) { if (pixels == null) { return null; } Pixels newPixels = new ShallowCopy().copy(pixels); newPixels.putAt(Pixels.CHANNELS, new ArrayList<Channel>()); copyChannels(pixels, newPixels); newPixels.setPixelsType(new ShallowCopy().copy(pixels.getPixelsType())); return newPixels; }
public Filterable filter(String fieldId, Filterable f) { if (f == null) { return null; } else if (f instanceof Enum) { values.put(fieldId, f); } else if (Details.class.isAssignableFrom(f.getClass())) { values.put(fieldId, ((Details) f).shallowCopy()); } else if (IObject.class.isAssignableFrom(f.getClass())) { IObject old = (IObject) f; IObject iobj = ShallowCopy.reflectiveNewInstance(old); iobj.setId(old.getId()); iobj.unload(); values.put(fieldId, iobj); } else { throw new InternalException("Unknown filterable type:" + f.getClass()); } return f; }
/** * Implemented as specified by the {@link RenderingEngine} interface. * * @see RenderingEngine#getQuantumDef() */ @RolesAllowed("user") public QuantumDef getQuantumDef() { rwl.readLock().lock(); try { errorIfNullRenderingDef(); return new ShallowCopy().copy(rendDefObj.getQuantization()); } finally { rwl.readLock().unlock(); } }
public Filterable filter(String fieldId, Filterable f) { if (f == null) { return null; } else if (f instanceof Enum) { target.putAt(fieldId, f); } else if (f instanceof ome.model.internal.Primitive) { target.putAt(fieldId, f); } else if (Details.class.isAssignableFrom(f.getClass())) { target.putAt(fieldId, ((Details) f).shallowCopy()); } else if (IObject.class.isAssignableFrom(f.getClass())) { IObject old = (IObject) f; IObject iobj = ShallowCopy.reflectiveNewInstance(old); iobj.setId(old.getId()); iobj.unload(); target.putAt(fieldId, iobj); } else { throw new InternalException("Unknown filterable type:" + f.getClass()); } return f; }
@RolesAllowed("user") @Transactional(readOnly = false) public synchronized Pixels save() { if (isModified()) { Long id = (pixelsInstance == null) ? null : pixelsInstance.getId(); if (id == null) { return null; } try { byte[] hash = buffer.calculateMessageDigest(); pixelsInstance.setSha1(Hex.encodeHexString(hash)); } catch (RuntimeException re) { // ticket:3140 if (re.getCause() instanceof FileNotFoundException) { String msg = "Cannot find path. Deleted? " + buffer; log.warn(msg); clean(); // Prevent a second exception on close. throw new ResourceError(msg); } throw re; } catch (IOException e) { log.warn("calculateMessageDigest failed on " + buffer, e); throw new ResourceError(e.getMessage()); } iUpdate.flush(); modified = false; return new ShallowCopy().copy(pixelsInstance); } return null; }
@RolesAllowed("user") public Job getJob() { Job job = internalJobOnly(); JobStatus status = job.getStatus(); Details unloadedDetails = status.getDetails().shallowCopy(); status.getDetails().shallowCopy(unloadedDetails); Job copy = new ShallowCopy().copy(job); copy.setStatus(job.getStatus()); return copy; }
iUpdate.flush(); modified = false; return new ShallowCopy().copy(file); } finally { finalize.stop("omero.services.file.finalize");