@Override public String marshal(KapuaId v) throws Exception { return v.toCompactId(); }
@Override public String marshal(KapuaId v) throws Exception { return v != null ? v.toCompactId() : null; }
@Override public String marshal(KapuaId v) throws Exception { return v != null ? v.toCompactId() : null; }
@Override public String marshal(KapuaId v) throws Exception { return v.toCompactId(); }
/** * Builds the jBatch job name from the {@link Job#getScopeId()} and the {@link Job#getId()}. * <p> * Format is: job-{scopeIdShort}-{jobIdShort} * * @param scopeId The scopeId of the {@link Job} * @param jobId The id of the {@link Job} * @return The jBatch {@link Job} name * @since 1.0.0 */ public static String getJbatchJobName(@NotNull KapuaId scopeId, @NotNull KapuaId jobId) { return String.format("job-%s-%s", scopeId.toCompactId(), jobId.toCompactId()); }
/** * Builds the jBatch job name from the {@link Job#getScopeId()} and the {@link Job#getId()}. * <p> * Format is: job-{scopeIdShort}-{jobIdShort} * * @param scopeId The scopeId of the {@link Job} * @param jobId The id of the {@link Job} * @return The jBatch {@link Job} name * @since 1.0.0 */ public static String getJbatchJobName(@NotNull KapuaId scopeId, @NotNull KapuaId jobId) { return String.format("job-%s-%s", scopeId.toCompactId(), jobId.toCompactId()); }
/** * Get the client identifier (combining accountName and clientId).<br> * <b>If the id is null then it is generated</b> * * @param id * @param scopeId * @param clientId * @return */ public static String getOrDeriveId(StorableId id, KapuaId scopeId, String clientId) { if (id == null) { return DatastoreUtils.getHashCode(scopeId.toCompactId(), clientId); } else { return id.toString(); } }
/** * Get the channel identifier (combining accountName clientId and c).<br> * <b>If the id is null then it is generated</b> * * @param id * @param scopeId * @param clientId * @param channel * @return */ private static String getOrDeriveId(StorableId id, KapuaId scopeId, String clientId, String channel) { if (id == null) { return DatastoreUtils.getHashCode(scopeId.toCompactId(), clientId, channel); } else { return id.toString(); } }
default String toStringURI() { try { return new URI( getSchema(), null, getDns(), getPort(), null, null, null ).toString(); } catch (URISyntaxException e) { throw KapuaRuntimeException.internalError(e, "Unable to build URI for EndpointInfo: " + getId().toCompactId()); } } }
@Given("^Move Account compact id from step data \"(.*)\" to \"(.*)\"$") public void moveAccountCompactIdStepData(String keyFrom, String keyTo) { Account account = (Account) stepData.get(keyFrom); stepData.put(keyTo, account.getId().toCompactId()); }
@Then("^REST response containing User") public void restResponseContainingUser() throws Exception { String restResponse = (String) stepData.get("restResponse"); User user = XmlUtil.unmarshalJson(restResponse, User.class, null); stepData.put("lastUserCompactId", user.getId().toCompactId()); }
@Given("^Move User compact id from step data \"(.*)\" to \"(.*)\"$") public void moveUserCompactIdStepData(String keyFrom, String keyTo) { ComparableUser comparableUser = (ComparableUser) stepData.get(keyFrom); stepData.put(keyTo, comparableUser.getUser().getId().toCompactId()); }
@Then("^REST response containing Account$") public void restResponseContainingAccount() throws Exception { String restResponse = (String) stepData.get("restResponse"); Account account = XmlUtil.unmarshalJson(restResponse, Account.class, null); KapuaId accId = account.getId(); System.out.println("Account Id = " + accId); stepData.put("lastAccountId", accId.toStringId()); stepData.put("lastAccountCompactId", accId.toCompactId()); }
/** * * @param serviceEventEntity * @param serviceEventBus * @return * @throws KapuaIllegalArgumentException * if the service event bus id is null or differs to the service event entity */ public static EventStoreRecord mergeToEntity(EventStoreRecord serviceEventEntity, org.eclipse.kapua.event.ServiceEvent serviceEventBus) throws KapuaIllegalArgumentException { if (serviceEventEntity.getId() == null) { throw new KapuaIllegalArgumentException("id", null); } if (!serviceEventEntity.getId().toCompactId().equals(serviceEventBus.getId())) { throw new KapuaIllegalArgumentException("serviceEventEntity.id - serviceEventBus.id", "not equals"); } return mergeToEntityInternal(serviceEventEntity, serviceEventBus); }
/** * * @param serviceEventEntity * @param serviceEventBus * @return * @throws KapuaIllegalArgumentException * if the service event bus id is null or differs to the service event entity */ public static EventStoreRecord mergeToEntity(EventStoreRecord serviceEventEntity, org.eclipse.kapua.event.ServiceEvent serviceEventBus) throws KapuaIllegalArgumentException { if (serviceEventEntity.getId() == null) { throw new KapuaIllegalArgumentException("id", null); } if (!serviceEventEntity.getId().toCompactId().equals(serviceEventBus.getId())) { throw new KapuaIllegalArgumentException("serviceEventEntity.id - serviceEventBus.id", "not equals"); } return mergeToEntityInternal(serviceEventEntity, serviceEventBus); }
/** * Get the metric identifier (return the hash code of the string obtained by combining accountName, clientId, channel and the converted metricName and metricType).<br> * <b>If the id is null then it is generated.</b> * * @param id * @param scopeId * @param clientId * @param channel * @param metricName * @param metricType * @return */ private static String getOrDeriveId(StorableId id, KapuaId scopeId, String clientId, String channel, String metricName, Class<?> metricType) { if (id == null) { String metricMappedName = DatastoreUtils.getMetricValueQualifier(metricName, DatastoreUtils.convertToClientMetricType(metricType)); return DatastoreUtils.getHashCode(scopeId.toCompactId(), clientId, channel, metricMappedName); } else { return id.toString(); } }
serviceEventBus.setId(persistedKapuaEvent.getId().toCompactId());
public static JSLProperties buildJobProperties(KapuaId scopeId, KapuaId jobId, JobStartOptions jobStartOptions) throws JAXBException { List<Property> jslPropertyList = new ArrayList<>(); // Scope id Property scopeIdProperty = new Property(); scopeIdProperty.setName(JobContextPropertyNames.JOB_SCOPE_ID); scopeIdProperty.setValue(scopeId.toCompactId()); jslPropertyList.add(scopeIdProperty); // Job id Property jobIdProperty = new Property(); jobIdProperty.setName(JobContextPropertyNames.JOB_ID); jobIdProperty.setValue(jobId.toCompactId()); jslPropertyList.add(jobIdProperty); // Job target sublist Property targetSublistProperty = new Property(); targetSublistProperty.setName(JobContextPropertyNames.JOB_TARGET_SUBLIST); targetSublistProperty.setValue(XmlUtil.marshal(new JobTargetSublist(jobStartOptions.getTargetIdSublist()))); jslPropertyList.add(targetSublistProperty); // Job from step index if (jobStartOptions.getFromStepIndex() != null) { Property stepFromIndexProperty = new Property(); stepFromIndexProperty.setName(JobContextPropertyNames.JOB_STEP_FROM_INDEX); stepFromIndexProperty.setValue(jobStartOptions.getFromStepIndex().toString()); jslPropertyList.add(stepFromIndexProperty); } // // Add them to the JBatch properties JSLProperties jslProperties = new JSLProperties(); jslProperties.getPropertyList().addAll(jslPropertyList); return jslProperties; }
@Override public void delete(KapuaId scopeId, KapuaId triggerId) throws KapuaException { // // Argument validation ArgumentValidator.notNull(triggerId, "scopeId"); ArgumentValidator.notNull(scopeId, "triggerId"); // // Check Access AUTHORIZATION_SERVICE.checkPermission(PERMISSION_FACTORY.newPermission(SchedulerDomains.SCHEDULER_DOMAIN, Actions.delete, scopeId)); // // Check existence if (find(scopeId, triggerId) == null) { throw new KapuaEntityNotFoundException(Trigger.TYPE, triggerId); } // // Do delete entityManagerSession.onTransactedAction(em -> { TriggerDAO.delete(em, scopeId, triggerId); try { SchedulerFactory sf = new StdSchedulerFactory(); Scheduler scheduler = sf.getScheduler(); TriggerKey triggerKey = TriggerKey.triggerKey(triggerId.toCompactId(), scopeId.toCompactId()); scheduler.unscheduleJob(triggerKey); } catch (SchedulerException se) { throw new RuntimeException(se); } }); }
/** * Convert the service event entity to the service bus object * * @param serviceEventEntity * @return * @throws KapuaIllegalArgumentException */ public static org.eclipse.kapua.event.ServiceEvent toServiceEventBus(EventStoreRecord serviceEventEntity) throws KapuaIllegalArgumentException { org.eclipse.kapua.event.ServiceEvent newEvent = new org.eclipse.kapua.event.ServiceEvent(); if (serviceEventEntity.getId() == null) { throw new KapuaIllegalArgumentException("id", null); } newEvent.setId(serviceEventEntity.getId().toCompactId()); newEvent.setContextId(serviceEventEntity.getContextId()); newEvent.setTimestamp(serviceEventEntity.getTimestamp()); newEvent.setUserId(serviceEventEntity.getUserId()); newEvent.setService(serviceEventEntity.getService()); newEvent.setEntityType(serviceEventEntity.getEntityType()); newEvent.setScopeId(serviceEventEntity.getScopeId()); newEvent.setEntityId(serviceEventEntity.getEntityId()); newEvent.setOperation(serviceEventEntity.getOperation()); newEvent.setInputs(serviceEventEntity.getInputs()); newEvent.setOutputs(serviceEventEntity.getOutputs()); newEvent.setStatus(serviceEventEntity.getStatus()); newEvent.setNote(serviceEventEntity.getNote()); return newEvent; }