public Condition getInstanceHostConstraint(Instance instance) { if (StringUtils.isEmpty(instance.getDeploymentUnitUuid())) { return INSTANCE_HOST_MAP.INSTANCE_ID.eq(instance.getId()); } else { return INSTANCE.DEPLOYMENT_UNIT_UUID.eq(instance.getDeploymentUnitUuid()); } }
@Override public List<? extends Instance> findUnallocatedInstanceByDeploymentUnitUuid( long accountId, String deploymentUnitUuid) { return create() .select(INSTANCE.fields()) .from(INSTANCE) .leftOuterJoin(INSTANCE_HOST_MAP) .on(INSTANCE_HOST_MAP.INSTANCE_ID.eq(INSTANCE.ID)) .where( INSTANCE .REMOVED .isNull() .and(INSTANCE_HOST_MAP.ID.isNull()) .and(INSTANCE.DEPLOYMENT_UNIT_UUID.eq(deploymentUnitUuid)) .and(INSTANCE.ALLOCATION_STATE.eq(CommonStatesConstants.INACTIVE))) .fetchInto(InstanceRecord.class); }
public List<Instance> getUnmappedDeploymentUnitInstances(String deploymentUnitUuid) { List<? extends Instance> instanceRecords = create() .select(INSTANCE.fields()) .from(INSTANCE) .leftOuterJoin(INSTANCE_HOST_MAP) .on( INSTANCE_HOST_MAP .INSTANCE_ID .eq(INSTANCE.ID) .and(INSTANCE_HOST_MAP.REMOVED.isNull())) .where(INSTANCE.REMOVED.isNull()) .and(INSTANCE.DEPLOYMENT_UNIT_UUID.eq(deploymentUnitUuid)) .and(INSTANCE_HOST_MAP.ID.isNull()) .fetchInto(InstanceRecord.class); List<Instance> instances = new ArrayList<Instance>(); for (Instance i : instanceRecords) { instances.add(i); } return instances; }