/** * Class-level synchronization to avoid potential thread-safety issues * with statically shared DatatypeFactory. */ @Mapping(from = Date.class, to = XMLGregorianCalendar.class) public static synchronized XMLGregorianCalendar map(Date date, XMLGregorianCalendar template) { GregorianCalendar calendar = template != null ? template.toGregorianCalendar() : new GregorianCalendar(); calendar.setTime(date); DatatypeFactory factory = getDatatypeFactory(); return factory != null ? factory.newXMLGregorianCalendar(calendar) : null; }
private Api getApi() { Api api = new Api(); api.setTime(DateMapper.map(new Date(), null)); for (DetailedLink detailedLink : getLinks()) { //add thin link api.getLinks().add(LinkCreator.createLink(detailedLink.getHref(), detailedLink.getRel())); //when required - add extra link for search if (detailedLink.isSetLinkCapabilities() && detailedLink.getLinkCapabilities().isSetSearchable() && detailedLink.getLinkCapabilities().isSearchable()) { api.getLinks().add(LinkCreator.createLink(detailedLink.getHref(), detailedLink.getRel(), detailedLink.getRequest().getUrl().getParametersSets())); } //add special links SpecialObjects specialObjects = new SpecialObjects(); specialObjects.setBlankTemplate(createBlankTemplate()); specialObjects.setRootTag(createRootTag()); api.setSpecialObjects(specialObjects); } return api; }
@Mapping(from = org.ovirt.engine.core.common.job.Job.class, to = Job.class) public static Job map(org.ovirt.engine.core.common.job.Job entity, Job job) { Job model = job != null ? job : new Job(); model.setId(entity.getId().toString()); model.setDescription(entity.getDescription()); model.setStatus(mapJobStatus(entity.getStatus())); if (entity.getOwnerId() != null) { User user = new User(); user.setId(entity.getOwnerId().toString()); model.setOwner(user); } model.setStartTime(DateMapper.map(entity.getStartTime(), null)); if (entity.getEndTime() != null) { model.setEndTime(DateMapper.map(entity.getEndTime(), null)); } if (entity.getLastUpdateTime() != null) { model.setLastUpdated(DateMapper.map(entity.getLastUpdateTime(), null)); } model.setExternal(entity.isExternal()); model.setAutoCleared(entity.isAutoCleared()); return model; }
private Api getGlusterApi() { Api api = new Api(); api.setTime(DateMapper.map(new Date(), null)); for (DetailedLink detailedLink : getGlusterLinks()) { // add thin link api.getLinks().add(LinkCreator.createLink(detailedLink.getHref(), detailedLink.getRel())); // when required - add extra link for search if (detailedLink.isSetLinkCapabilities() && detailedLink.getLinkCapabilities().isSetSearchable() && detailedLink.getLinkCapabilities().isSearchable()) { api.getLinks().add(LinkCreator.createLink(detailedLink.getHref(), detailedLink.getRel(), detailedLink.getRequest().getUrl().getParametersSets())); } // add special links SpecialObjects specialObjects = new SpecialObjects(); specialObjects.setRootTag(createRootTag()); api.setSpecialObjects(specialObjects); } return api; }
@Mapping(from = Integer.class, to = XMLGregorianCalendar.class) public static synchronized XMLGregorianCalendar map(BigDecimal secondsAgo, XMLGregorianCalendar template) { GregorianCalendar calendar = template != null ? template.toGregorianCalendar() : new GregorianCalendar(TimeZone.getTimeZone("UTC")); DatatypeFactory factory = getDatatypeFactory(); XMLGregorianCalendar ret = null; if (factory != null) { ret = factory.newXMLGregorianCalendar(calendar); ret.add(factory.newDuration(false, 0, 0, 0, 0, 0, secondsAgo.intValue())); } return ret; }
protected KatelloErratum postPopulate(KatelloErratum model) { model.setName(model.getId()); model.setId(string2hex(model.getId())); model.setIssued(DateMapper.map(DATE, null)); model.setSeverity(ErrataSeverity.MODERATE.getDescription()); model.setType(ErrataType.ENHANCEMENT.getDescription()); return super.postPopulate(model); } }
@Mapping(from = Erratum.class, to = KatelloErratum.class) public static KatelloErratum map(Erratum entity, KatelloErratum model) { model = model == null ? new KatelloErratum() : model; model.setId(string2hex(entity.getId())); model.setName(entity.getId()); model.setTitle(entity.getTitle()); model.setSummary(entity.getSummary()); model.setSolution(entity.getSolution()); model.setDescription(entity.getDescription()); if (entity.getIssued() != null) { model.setIssued(DateMapper.map(entity.getIssued(), null)); } model.setSeverity(entity.getSeverity() == null ? null : entity.getSeverity().getDescription()); model.setType(entity.getType() == null ? null : entity.getType().getDescription()); if (entity.getPackages() != null && !entity.getPackages().isEmpty()) { Packages packages = new Packages(); for (String packageName : entity.getPackages()) { Package p = new Package(); p.setName(packageName); packages.getPackages().add(p); } model.setPackages(packages); } return model; }
@Mapping(from = org.ovirt.engine.core.common.businessentities.Snapshot.class, to = Snapshot.class) public static Snapshot map(org.ovirt.engine.core.common.businessentities.Snapshot entity, Snapshot template) { Snapshot model = template != null ? template : new Snapshot(); model.setId(entity.getId().toString()); if (entity.getDescription() != null) { model.setDescription(entity.getDescription()); } if (entity.getCreationDate() != null) { model.setDate(DateMapper.map(entity.getCreationDate(), null)); } if (entity.getStatus() != null) { model.setSnapshotStatus(map(entity.getStatus(), null)); } if (entity.getType() != null) { model.setSnapshotType(map(entity.getType(), null)); } model.setPersistMemorystate(entity.containsMemory()); return model; }
@Mapping(from = LibvirtSecret.class, to = OpenstackVolumeAuthenticationKey.class) public static OpenstackVolumeAuthenticationKey map(LibvirtSecret entity, OpenstackVolumeAuthenticationKey template) { OpenstackVolumeAuthenticationKey model = template != null ? template : new OpenstackVolumeAuthenticationKey(); if (entity.getId() != null) { model.setId(entity.getId().toString()); model.setUuid(entity.getId().toString()); } if (entity.getDescription() != null) { model.setDescription(entity.getDescription()); } if (entity.getCreationDate() != null) { model.setCreationDate(DateMapper.map(entity.getCreationDate(), null)); } if (entity.getUsageType() != null) { model.setUsageType(map(entity.getUsageType(), null)); } if (entity.getProviderId() != null) { OpenStackVolumeProvider provider = new OpenStackVolumeProvider(); provider.setId(entity.getProviderId().toString()); model.setOpenstackVolumeProvider(provider); } return model; }
@Mapping(from = org.ovirt.engine.core.common.job.Step.class, to = Step.class) public static Step map(org.ovirt.engine.core.common.job.Step entity, Step step) { Step model = step != null ? step : new Step(); model.setId(entity.getId().toString()); if (entity.getParentStepId() != null) { Step parentStep = new Step(); parentStep.setId(entity.getParentStepId().toString()); model.setParentStep(parentStep); } Job job = new Job(); job.setId(entity.getJobId().toString()); model.setJob(job); model.setType(map(entity.getStepType())); model.setDescription(entity.getDescription()); model.setNumber(entity.getStepNumber()); model.setStatus(mapStepStatus(entity.getStatus())); model.setProgress(entity.getProgress()); model.setStartTime(DateMapper.map(entity.getStartTime(), null)); if (entity.getEndTime() != null) { model.setEndTime(TypeConversionHelper.toXMLGregorianCalendar(entity.getEndTime(), null)); } model.setExternal(entity.isExternal()); if (entity.getExternalSystem() != null && entity.getExternalSystem().getType() != null) { model.setExternalType(map(entity.getExternalSystem().getType())); } mapStepSubjectEntities(entity, model); return model; }
model.setCreationTime(DateMapper.map(entity.getCreationDate(), null));