本文整理汇总了Java中javax.persistence.Tuple.get方法的典型用法代码示例。如果您正苦于以下问题:Java Tuple.get方法的具体用法?Java Tuple.get怎么用?Java Tuple.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.persistence.Tuple
的用法示例。
在下文中一共展示了Tuple.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEntityFromTuple
import javax.persistence.Tuple; //导入方法依赖的package包/类
private static <T> List<T> createEntityFromTuple(List<Tuple> tuples, Class<T> entity) {
List<T> entities = new ArrayList<>();
for (Tuple t : tuples) {
T el;
try {
el = entity.getConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException |
NoSuchMethodException | InvocationTargetException e) {
throw new AssertionError();
}
for (TupleElement<?> te : t.getElements()) {
Object o = t.get(te);
try {
Field f = getFieldFromEntity(entity, te.getAlias());
f.setAccessible(true);
f.set(el, o);
} catch (NoSuchFieldException | IllegalAccessException e1) {
throw new NoSuchEntityFieldException(e1.getMessage(), te.getAlias(), entity.getSimpleName());
}
}
entities.add(el);
}
return entities;
}
示例2: validate
import javax.persistence.Tuple; //导入方法依赖的package包/类
@Transactional(readOnly = true)
private void validate(APIDetachL3NetworkFromVmMsg msg) {
String sql = "select vm.uuid, vm.type, vm.state from VmInstanceVO vm, VmNicVO nic where vm.uuid = nic.vmInstanceUuid and nic.uuid = :uuid";
TypedQuery<Tuple> q = dbf.getEntityManager().createQuery(sql, Tuple.class);
q.setParameter("uuid", msg.getVmNicUuid());
Tuple t = q.getSingleResult();
String vmUuid = t.get(0, String.class);
String vmType = t.get(1, String.class);
VmInstanceState state = t.get(2, VmInstanceState.class);
if (!VmInstanceState.Running.equals(state) && !VmInstanceState.Stopped.equals(state)) {
throw new ApiMessageInterceptionException(operr("unable to detach a L3 network. The vm[uuid: %s] is not Running or Stopped; the current state is %s",
msg.getVmInstanceUuid(), state));
}
msg.setVmInstanceUuid(vmUuid);
}
示例3: findReservedCapacityByHypervisorType
import javax.persistence.Tuple; //导入方法依赖的package包/类
private void findReservedCapacityByHypervisorType() {
SimpleQuery<HostVO> hq = dbf.createQuery(HostVO.class);
hq.select(HostVO_.uuid, HostVO_.hypervisorType);
hq.add(HostVO_.uuid, Op.IN, hostUuids);
hq.add(HostVO_.state,Op.EQ, HostState.Enabled);
hq.add(HostVO_.status,Op.EQ, HostStatus.Connected);
List<Tuple> tuples = hq.listTuple();
for (Tuple t : tuples) {
String huuid = t.get(0, String.class);
String hvType = t.get(1, String.class);
HostReservedCapacityExtensionPoint ext = exts.get(hvType);
if (ext == null) {
continue;
}
ReservedHostCapacity hc = result.get(huuid);
if (hc.getReservedMemoryCapacity() == -1) {
hc.setReservedMemoryCapacity(ext.getReservedHostCapacity().getReservedMemoryCapacity());
}
if (hc.getReservedCpuCapacity() == -1) {
hc.setReservedCpuCapacity(ext.getReservedHostCapacity().getReservedCpuCapacity());
}
}
}
示例4: getImageOnBackupStorage
import javax.persistence.Tuple; //导入方法依赖的package包/类
@Transactional(readOnly = true)
private List<ImageDeletionStruct> getImageOnBackupStorage(List<String> bsUuids) {
String sql = "select ref.backupStorageUuid, img from ImageVO img, ImageBackupStorageRefVO ref where img.uuid = ref.imageUuid and ref.backupStorageUuid in (:bsUuids) group by img.uuid";
TypedQuery<Tuple> q = dbf.getEntityManager().createQuery(sql, Tuple.class);
q.setParameter("bsUuids", bsUuids);
List<Tuple> ts = q.getResultList();
Map<String, ImageDeletionStruct> tmp = new HashMap<String, ImageDeletionStruct>();
for (Tuple t : ts) {
String bsUuid = t.get(0, String.class);
ImageVO img = t.get(1, ImageVO.class);
ImageDeletionStruct struct = tmp.get(img.getUuid());
if (struct == null) {
struct = new ImageDeletionStruct();
struct.setImage(ImageInventory.valueOf(img));
struct.setBackupStorageUuids(new ArrayList<String>());
tmp.put(img.getUuid(), struct);
}
struct.getBackupStorageUuids().add(bsUuid);
}
List<ImageDeletionStruct> structs = new ArrayList<ImageDeletionStruct>();
structs.addAll(tmp.values());
return structs;
}
示例5: findByL3Uuids
import javax.persistence.Tuple; //导入方法依赖的package包/类
@Transactional(readOnly = true)
public Map<String, String> findByL3Uuids(Collection<String> l3Uuids) {
String sql = "select t.tag, l3.uuid" +
" from SystemTagVO t, L3NetworkVO l3" +
" where t.resourceType = :ttype" +
" and t.tag like :tag" +
" and t.resourceUuid = l3.l2NetworkUuid" +
" and l3.uuid in (:l3Uuids)" +
" group by l3.uuid";
TypedQuery<Tuple> tq = dbf.getEntityManager().createQuery(sql, Tuple.class);
tq.setParameter("tag", TagUtils.tagPatternToSqlPattern(KVMSystemTags.L2_BRIDGE_NAME.getTagFormat()));
tq.setParameter("l3Uuids", l3Uuids);
tq.setParameter("ttype", L2NetworkVO.class.getSimpleName());
List<Tuple> ts = tq.getResultList();
Map<String, String> bridgeNames = new HashMap<>();
for (Tuple t : ts) {
String brToken = t.get(0, String.class);
String l3Uuid = t.get(1, String.class);
bridgeNames.put(l3Uuid, KVMSystemTags.L2_BRIDGE_NAME.getTokenByTag(brToken, KVMSystemTags.L2_BRIDGE_NAME_TOKEN));
}
return bridgeNames;
}
示例6: getPublicL3BridgeNamesByVipUuids
import javax.persistence.Tuple; //导入方法依赖的package包/类
@Transactional
private Map<String, String> getPublicL3BridgeNamesByVipUuids(List<String> vipsUuids) {
String sql = "select l3.uuid, vip.uuid from L3NetworkVO l3, VipVO vip where vip.l3NetworkUuid = l3.uuid and vip.uuid in (:uuids)";
TypedQuery<Tuple> q = dbf.getEntityManager().createQuery(sql, Tuple.class);
q.setParameter("uuids", vipsUuids);
List<Tuple> ts = q.getResultList();
Map<String, String> vipL3 = new HashMap<String, String>();
for (Tuple t : ts) {
String l3Uuid = t.get(0, String.class);
String vipUuid = t.get(1, String.class);
vipL3.put(vipUuid, l3Uuid);
}
DebugUtils.Assert(!vipL3.isEmpty(), "how can we get an empty public L3Network list?");
Map<String, String> brNames = new BridgeNameFinder().findByL3Uuids(vipL3.values());
Map<String, String> vipBr = new HashMap<String, String>();
for (Map.Entry<String, String> e : vipL3.entrySet()) {
vipBr.put(e.getKey(), brNames.get(e.getValue()));
}
return vipBr;
}
示例7: getVipUsePortRange
import javax.persistence.Tuple; //导入方法依赖的package包/类
@Override
public RangeSet getVipUsePortRange(String vipUuid, String protocol, VipUseForList useForList){
RangeSet portRangeList = new RangeSet();
List<RangeSet.Range> portRanges = new ArrayList<RangeSet.Range>();
if (protocol.toUpperCase().equals(PortForwardingProtocolType.UDP.toString()) || protocol.toUpperCase().equals(PortForwardingProtocolType.TCP.toString())) {
List<Tuple> pfPortList = Q.New(PortForwardingRuleVO.class).select(PortForwardingRuleVO_.vipPortStart, PortForwardingRuleVO_.vipPortEnd)
.eq(PortForwardingRuleVO_.vipUuid, vipUuid).eq(PortForwardingRuleVO_.protocolType, PortForwardingProtocolType.valueOf(protocol.toUpperCase())).listTuple();
Iterator<Tuple> it = pfPortList.iterator();
while (it.hasNext()){
Tuple strRange = it.next();
int start = strRange.get(0, Integer.class);
int end = strRange.get(1, Integer.class);
RangeSet.Range range = new RangeSet.Range(start, end);
portRanges.add(range);
}
}
portRangeList.setRanges(portRanges);
return portRangeList;
}
示例8: getTags
import javax.persistence.Tuple; //导入方法依赖的package包/类
public Map<String, List<String>> getTags(List<String> resourceUuids, Class resourceClass) {
SimpleQuery<SystemTagVO> q = dbf.createQuery(SystemTagVO.class);
q.select(SystemTagVO_.tag, SystemTagVO_.resourceUuid);
q.add(SystemTagVO_.resourceType, Op.EQ, resourceClass.getSimpleName());
q.add(SystemTagVO_.resourceUuid, Op.IN, resourceUuids);
q.add(SystemTagVO_.tag, useOp(), useTagFormat());
List<Tuple> ts = q.listTuple();
Map<String, List<String>> ret = new HashMap<>();
for (Tuple t : ts) {
String uuid = t.get(1, String.class);
List<String> tags = ret.get(uuid);
if (tags == null) {
tags = new ArrayList<>();
ret.put(uuid, tags);
}
tags.add(t.get(0, String.class));
}
return ret;
}
示例9: getUsedVmCpuMemory
import javax.persistence.Tuple; //导入方法依赖的package包/类
@Transactional(readOnly = true)
public VmQuota getUsedVmCpuMemory(String accountUUid) {
VmQuota quota = new VmQuota();
// get running info
String sql = "select count(vm), sum(vm.cpuNum), sum(vm.memorySize)" +
" from VmInstanceVO vm, AccountResourceRefVO ref" +
" where vm.uuid = ref.resourceUuid" +
" and ref.accountUuid = :auuid" +
" and ref.resourceType = :rtype" +
" and vm.state not in (:states)";
TypedQuery<Tuple> q = dbf.getEntityManager().createQuery(sql, Tuple.class);
q.setParameter("auuid", accountUUid);
q.setParameter("rtype", VmInstanceVO.class.getSimpleName());
q.setParameter("states", list(VmInstanceState.Stopped, VmInstanceState.Destroying,
VmInstanceState.Destroyed, VmInstanceState.Created));
Tuple t = q.getSingleResult();
Long vnum = t.get(0, Long.class);
quota.runningVmNum = vnum == null ? 0 : vnum;
Long cnum = t.get(1, Long.class);
quota.runningVmCpuNum = cnum == null ? 0 : cnum;
Long msize = t.get(2, Long.class);
quota.runningVmMemorySize = msize == null ? 0 : msize;
// get total vm
String sql2 = "select count(vm)" +
" from VmInstanceVO vm, AccountResourceRefVO ref" +
" where vm.uuid = ref.resourceUuid" +
" and ref.accountUuid = :auuid" +
" and ref.resourceType = :rtype" +
" and vm.state not in (:states)";
TypedQuery<Long> q2 = dbf.getEntityManager().createQuery(sql2, Long.class);
q2.setParameter("auuid", accountUUid);
q2.setParameter("rtype", VmInstanceVO.class.getSimpleName());
q2.setParameter("states", list(VmInstanceState.Destroyed));
Long totalVmNum = q2.getSingleResult();
quota.totalVmNum = totalVmNum == null ? 0 : totalVmNum;
return quota;
}
示例10: getHostManagedByUs
import javax.persistence.Tuple; //导入方法依赖的package包/类
private Bucket getHostManagedByUs() {
int qun = 10000;
long amount = dbf.count(HostVO.class);
int times = (int) (amount / qun) + (amount % qun != 0 ? 1 : 0);
List<String> connected = new ArrayList<String>();
List<String> disconnected = new ArrayList<String>();
int start = 0;
for (int i = 0; i < times; i++) {
SimpleQuery<HostVO> q = dbf.createQuery(HostVO.class);
q.select(HostVO_.uuid, HostVO_.status);
q.setLimit(qun);
q.setStart(start);
List<Tuple> lst = q.listTuple();
start += qun;
for (Tuple t : lst) {
String huuid = t.get(0, String.class);
if (!destMaker.isManagedByUs(huuid)) {
continue;
}
HostStatus state = t.get(1, HostStatus.class);
if (state == HostStatus.Connected) {
connected.add(huuid);
} else {
// for Disconnected and Connecting, treat as Disconnected
disconnected.add(huuid);
}
}
}
return Bucket.newBucket(connected, disconnected);
}
示例11: findL3NeedToDeleteDeprecatedNameSpace
import javax.persistence.Tuple; //导入方法依赖的package包/类
@Transactional(readOnly = true)
private List<L3Host> findL3NeedToDeleteDeprecatedNameSpace() {
String sql = "select l3.uuid from L3NetworkVO l3, NetworkServiceL3NetworkRefVO ref, NetworkServiceProviderVO provider" +
" where l3.uuid = ref.l3NetworkUuid and ref.networkServiceProviderUuid = provider.uuid" +
" and ref.networkServiceType = :nsType and provider.type = :ptype";
TypedQuery<String> q = dbf.getEntityManager().createQuery(sql, String.class);
q.setParameter("nsType", NetworkServiceType.DHCP.toString());
q.setParameter("ptype", FlatNetworkServiceConstant.FLAT_NETWORK_SERVICE_TYPE_STRING);
List<String> l3Uuids = q.getResultList();
if (l3Uuids.isEmpty()) {
return null;
}
sql = "select l3, host.uuid from L3NetworkVO l3, HostVO host, L2NetworkClusterRefVO ref where host.hypervisorType = :htype and l3.uuid in (:uuids)" +
" and ref.l2NetworkUuid = l3.l2NetworkUuid and host.clusterUuid = ref.clusterUuid";
TypedQuery<Tuple> tq = dbf.getEntityManager().createQuery(sql, Tuple.class);
tq.setParameter("htype", KVMConstant.KVM_HYPERVISOR_TYPE);
tq.setParameter("uuids", l3Uuids);
List<Tuple> ts = tq.getResultList();
if (ts.isEmpty()) {
return null;
}
List<L3Host> ret = new ArrayList<>();
for (Tuple t : ts) {
L3NetworkVO l3 = t.get(0, L3NetworkVO.class);
String huuid = t.get(1, String.class);
L3Host lh = new L3Host();
lh.hostUuid= huuid;
lh.l3 = L3NetworkInventory.valueOf(l3);
ret.add(lh);
}
return ret;
}
示例12: returnHostSecurityGroupMember
import javax.persistence.Tuple; //导入方法依赖的package包/类
@Transactional(readOnly = true)
HostSecurityGroupMembersTO returnHostSecurityGroupMember(String sgUuid){
HostSecurityGroupMembersTO hto = new HostSecurityGroupMembersTO();
SecurityGroupMembersTO gto = new SecurityGroupMembersTO();
gto.setSecurityGroupVmIps(getVmIpsBySecurityGroup(sgUuid));
gto.setSecurityGroupUuid(sgUuid);
hto.setGroupMembersTO(gto);
Set<String> hostUuids = new HashSet<>();
List<Tuple> ts = SQL.New("select vm.hostUuid, vm.hypervisorType" +
" from VmNicVO nic, VmInstanceVO vm, VmNicSecurityGroupRefVO ref" +
" where vm.uuid = nic.vmInstanceUuid" +
" and nic.uuid = ref.vmNicUuid" +
" and ref.securityGroupUuid in" +
" (" +
" select rule.securityGroupUuid from SecurityGroupRuleVO rule" +
" where rule.remoteSecurityGroupUuid =:sgUuid" +
" )", Tuple.class).param("sgUuid", sgUuid).list();
for(Tuple t : ts){
if(t.get(0, String.class) != null){
hostUuids.add(t.get(0, String.class));
}
hto.setHypervisorType(t.get(1, String.class));
}
hto.setHostUuids(new ArrayList<>(hostUuids));
return hto;
}
示例13: findEipOnThisRouter
import javax.persistence.Tuple; //导入方法依赖的package包/类
@Transactional(readOnly = true)
private List<EipTO> findEipOnThisRouter(VirtualRouterVmInventory vr, List<String> eipUuids) {
String sql = "select vip.ip, nic.l3NetworkUuid, nic.ip from EipVO eip, VipVO vip, VmNicVO nic, VmInstanceVO vm where nic.vmInstanceUuid = vm.uuid and vm.state = :vmState and eip.vipUuid = vip.uuid and eip.vmNicUuid = nic.uuid and eip.uuid in (:euuids)";
TypedQuery<Tuple> q = dbf.getEntityManager().createQuery(sql, Tuple.class);
q.setParameter("euuids", eipUuids);
q.setParameter("vmState", VmInstanceState.Running);
List<Tuple> tuples = q.getResultList();
List<EipTO> ret = new ArrayList<EipTO>();
for (Tuple t : tuples) {
String vipIp = t.get(0, String.class);
final String l3Uuid = t.get(1, String.class);
String guestIp = t.get(2, String.class);
String privMac = CollectionUtils.find(vr.getVmNics(), new Function<String, VmNicInventory>() {
@Override
public String call(VmNicInventory arg) {
if (arg.getL3NetworkUuid().equals(l3Uuid)) {
return arg.getMac();
}
return null;
}
});
DebugUtils.Assert(privMac!=null, String.format("cannot find private nic[l3NetworkUuid:%s] on virtual router[uuid:%s]",
l3Uuid, vr.getUuid()));
EipTO to = new EipTO();
to.setVipIp(vipIp);
to.setGuestIp(guestIp);
to.setPrivateMac(privMac);
to.setSnatInboundTraffic(EipGlobalConfig.SNAT_INBOUND_TRAFFIC.value(Boolean.class));
ret.add(to);
}
return ret;
}
示例14: __notification__
import javax.persistence.Tuple; //导入方法依赖的package包/类
public ApiNotification __notification__() {
APIMessage that = this;
return new ApiNotification() {
String ip;
String vmUuid;
String vmNicUuid;
@Override
public void before() {
Tuple tuple = SQL.New("select nic.ip, nic.vmInstanceUuid, nic.uuid from VmNicVO nic, PortForwardingRuleVO pfr" +
" where pfr.vmNicUuid = nic.uuid and pfr.uuid = :uuid", Tuple.class)
.param("uuid", getUuid()).find();
ip = tuple.get(0, String.class);
vmUuid = tuple.get(1, String.class);
vmNicUuid = tuple.get(2, String.class);
}
@Override
public void after(APIEvent evt) {
ntfy("Detached from a nic[ip:%s] of the VM[uuid:%s]", ip, vmUuid)
.resource(getUuid(), PortForwardingRuleVO.class.getSimpleName())
.context("vmUuid", vmUuid)
.context("vmNicUuid", vmNicUuid)
.messageAndEvent(that, evt)
.done();
ntfy("Detached a port forwarding rule[%s] from the nic[ip:%s]", getUuid(), ip)
.resource(vmUuid, VmInstanceVO.class.getSimpleName())
.context("portforwardingRuleUuid", getUuid())
.context("vmNicUuid", vmNicUuid)
.messageAndEvent(that, evt)
.done();
}
};
}
示例15: _buildResultsFromOids
import javax.persistence.Tuple; //导入方法依赖的package包/类
protected FindOIDsResult<O> _buildResultsFromOids(final UserContext userContext,
final Collection<Tuple> dbTuples) {
Class<O> oidType = OIDs.oidTypeFor(_modelObjectType);
FindOIDsResult<O> outOids = null;
if (CollectionUtils.hasData(dbTuples)) {
boolean isVersionableOid = Facetables.hasFacet(_modelObjectType,HasVersionableFacet.class);
Collection<O> oids = Lists.newArrayListWithExpectedSize(dbTuples.size());
for (Tuple tuple : dbTuples) {
O oid = null;
if (isVersionableOid) {
String versionIndependentOidAsString = (String)tuple.get(0);
String versionOid = (String)tuple.get(1);
oid = OIDs.createVersionableOIDFromString(oidType,
versionIndependentOidAsString,versionOid);
} else {
String oidAsString = (String)tuple.get(0);
oid = OIDs.createOIDFromString(oidType,
oidAsString);
}
oids.add(oid);
}
outOids = FindOIDsResultBuilder.using(userContext)
.on(_modelObjectType)
.foundEntitiesWithOids(oids);
} else {
outOids = FindOIDsResultBuilder.using(userContext)
.on(_modelObjectType)
.noEntityFound();
}
return outOids;
}