You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mc...@apache.org on 2012/12/14 19:48:30 UTC
[4/7] Move view based VO and Dao classes to cloud-server module to
hide the details from API client,
also extract query related methods into QueryService interface.
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java
new file mode 100644
index 0000000..9d5c36d
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java
@@ -0,0 +1,203 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.api.ApiResponseHelper;
+import com.cloud.api.query.vo.DomainRouterJoinVO;
+
+import org.apache.cloudstack.api.response.DomainRouterResponse;
+import org.apache.cloudstack.api.response.NicResponse;
+import com.cloud.network.Networks.TrafficType;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.user.Account;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+
+@Local(value={DomainRouterJoinDao.class})
+public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO, Long> implements DomainRouterJoinDao {
+ public static final Logger s_logger = Logger.getLogger(DomainRouterJoinDaoImpl.class);
+
+ private SearchBuilder<DomainRouterJoinVO> vrSearch;
+
+ private SearchBuilder<DomainRouterJoinVO> vrIdSearch;
+
+ protected DomainRouterJoinDaoImpl() {
+
+ vrSearch = createSearchBuilder();
+ vrSearch.and("idIN", vrSearch.entity().getId(), SearchCriteria.Op.IN);
+ vrSearch.done();
+
+ vrIdSearch = createSearchBuilder();
+ vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
+ vrIdSearch.done();
+
+ this._count = "select count(distinct id) from domain_router_view WHERE ";
+ }
+
+
+ @Override
+ public DomainRouterResponse newDomainRouterResponse(DomainRouterJoinVO router, Account caller) {
+ DomainRouterResponse routerResponse = new DomainRouterResponse();
+ routerResponse.setId(router.getUuid());
+ routerResponse.setZoneId(router.getDataCenterUuid());
+ routerResponse.setName(router.getHostName());
+ routerResponse.setTemplateId(router.getTemplateUuid());
+ routerResponse.setCreated(router.getCreated());
+ routerResponse.setState(router.getState());
+ routerResponse.setIsRedundantRouter(router.isRedundantRouter());
+ routerResponse.setRedundantState(router.getRedundantState().toString());
+
+ if (caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN
+ || caller.getType() == Account.ACCOUNT_TYPE_ADMIN) {
+ if (router.getHostId() != null) {
+ routerResponse.setHostId(router.getHostUuid());
+ routerResponse.setHostName(router.getHostName());
+ }
+ routerResponse.setPodId(router.getPodUuid());
+ long nic_id = router.getNicId();
+ if (nic_id > 0) {
+ TrafficType ty = router.getTrafficType();
+ if (ty != null) {
+ // legacy code, public/control/guest nic info is kept in
+ // nics response object
+ if (ty == TrafficType.Public) {
+ routerResponse.setPublicIp(router.getIpAddress());
+ routerResponse.setPublicMacAddress(router.getMacAddress());
+ routerResponse.setPublicNetmask(router.getNetmask());
+ routerResponse.setGateway(router.getGateway());
+ routerResponse.setPublicNetworkId(router.getNetworkUuid());
+ } else if (ty == TrafficType.Control) {
+ routerResponse.setLinkLocalIp(router.getIpAddress());
+ routerResponse.setLinkLocalMacAddress(router.getMacAddress());
+ routerResponse.setLinkLocalNetmask(router.getNetmask());
+ routerResponse.setLinkLocalNetworkId(router.getNetworkUuid());
+ } else if (ty == TrafficType.Guest) {
+ routerResponse.setGuestIpAddress(router.getIpAddress());
+ routerResponse.setGuestMacAddress(router.getMacAddress());
+ routerResponse.setGuestNetmask(router.getNetmask());
+ routerResponse.setGuestNetworkId(router.getNetworkUuid());
+ routerResponse.setNetworkDomain(router.getNetworkDomain());
+ }
+ }
+
+ NicResponse nicResponse = new NicResponse();
+ nicResponse.setId(router.getNicUuid());
+ nicResponse.setIpaddress(router.getIpAddress());
+ nicResponse.setGateway(router.getGateway());
+ nicResponse.setNetmask(router.getNetmask());
+ nicResponse.setNetworkid(router.getNetworkUuid());
+ nicResponse.setNetworkName(router.getNetworkName());
+ nicResponse.setMacAddress(router.getMacAddress());
+ if (router.getBroadcastUri() != null) {
+ nicResponse.setBroadcastUri(router.getBroadcastUri().toString());
+ }
+ if (router.getIsolationUri() != null) {
+ nicResponse.setIsolationUri(router.getIsolationUri().toString());
+ }
+ if (router.getTrafficType() != null) {
+ nicResponse.setTrafficType(router.getTrafficType().toString());
+ }
+ if (router.getGuestType() != null) {
+ nicResponse.setType(router.getGuestType().toString());
+ }
+ nicResponse.setIsDefault(router.isDefaultNic());
+ nicResponse.setObjectName("nic");
+ routerResponse.addNic(nicResponse);
+ }
+ }
+
+ routerResponse.setServiceOfferingId(router.getServiceOfferingUuid());
+ routerResponse.setServiceOfferingName(router.getServiceOfferingName());
+
+ // populate owner.
+ ApiResponseHelper.populateOwner(routerResponse, router);
+
+
+ routerResponse.setDomainId(router.getDomainUuid());
+ routerResponse.setDomainName(router.getDomainName());
+
+ routerResponse.setZoneName(router.getDataCenterName());
+ routerResponse.setDns1(router.getDns1());
+ routerResponse.setDns2(router.getDns2());
+
+ routerResponse.setVpcId(router.getVpcUuid());
+
+ routerResponse.setObjectName("router");
+
+ return routerResponse;
+ }
+
+
+ @Override
+ public DomainRouterResponse setDomainRouterResponse(DomainRouterResponse vrData, DomainRouterJoinVO vr) {
+ long nic_id = vr.getNicId();
+ if (nic_id > 0) {
+ NicResponse nicResponse = new NicResponse();
+ nicResponse.setId(vr.getNicUuid());
+ nicResponse.setIpaddress(vr.getIpAddress());
+ nicResponse.setGateway(vr.getGateway());
+ nicResponse.setNetmask(vr.getNetmask());
+ nicResponse.setNetworkid(vr.getNetworkUuid());
+ nicResponse.setMacAddress(vr.getMacAddress());
+ if (vr.getBroadcastUri() != null) {
+ nicResponse.setBroadcastUri(vr.getBroadcastUri().toString());
+ }
+ if (vr.getIsolationUri() != null) {
+ nicResponse.setIsolationUri(vr.getIsolationUri().toString());
+ }
+ if (vr.getTrafficType() != null) {
+ nicResponse.setTrafficType(vr.getTrafficType().toString());
+ }
+ if (vr.getGuestType() != null) {
+ nicResponse.setType(vr.getGuestType().toString());
+ }
+ nicResponse.setIsDefault(vr.isDefaultNic());
+ nicResponse.setObjectName("nic");
+ vrData.addNic(nicResponse);
+ }
+ return vrData;
+ }
+
+
+
+
+ @Override
+ public List<DomainRouterJoinVO> searchByIds(Long... ids) {
+ SearchCriteria<DomainRouterJoinVO> sc = vrSearch.create();
+ sc.setParameters("idIN", ids);
+ return searchIncludingRemoved(sc, null, null, false);
+ }
+
+
+ @Override
+ public List<DomainRouterJoinVO> newDomainRouterView(VirtualRouter vr) {
+
+ SearchCriteria<DomainRouterJoinVO> sc = vrIdSearch.create();
+ sc.setParameters("id", vr.getId());
+ return searchIncludingRemoved(sc, null, null, false);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/dao/InstanceGroupJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/InstanceGroupJoinDao.java b/server/src/com/cloud/api/query/dao/InstanceGroupJoinDao.java
new file mode 100644
index 0000000..79e5728
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/InstanceGroupJoinDao.java
@@ -0,0 +1,35 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.response.InstanceGroupResponse;
+
+import com.cloud.api.query.vo.InstanceGroupJoinVO;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.vm.InstanceGroup;
+
+public interface InstanceGroupJoinDao extends GenericDao<InstanceGroupJoinVO, Long> {
+
+ InstanceGroupResponse newInstanceGroupResponse(InstanceGroupJoinVO group);
+
+ InstanceGroupJoinVO newInstanceGroupView(InstanceGroup group);
+
+ List<InstanceGroupJoinVO> searchByIds(Long... ids);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/dao/InstanceGroupJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/InstanceGroupJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/InstanceGroupJoinDaoImpl.java
new file mode 100644
index 0000000..8374605
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/InstanceGroupJoinDaoImpl.java
@@ -0,0 +1,97 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.api.ApiResponseHelper;
+import com.cloud.api.query.vo.InstanceGroupJoinVO;
+
+import org.apache.cloudstack.api.response.InstanceGroupResponse;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.vm.InstanceGroup;
+
+
+@Local(value={InstanceGroupJoinDao.class})
+public class InstanceGroupJoinDaoImpl extends GenericDaoBase<InstanceGroupJoinVO, Long> implements InstanceGroupJoinDao {
+ public static final Logger s_logger = Logger.getLogger(InstanceGroupJoinDaoImpl.class);
+
+ private SearchBuilder<InstanceGroupJoinVO> vrSearch;
+
+ private SearchBuilder<InstanceGroupJoinVO> vrIdSearch;
+
+
+ protected InstanceGroupJoinDaoImpl() {
+
+ vrSearch = createSearchBuilder();
+ vrSearch.and("idIN", vrSearch.entity().getId(), SearchCriteria.Op.IN);
+ vrSearch.done();
+
+ vrIdSearch = createSearchBuilder();
+ vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
+ vrIdSearch.done();
+
+ this._count = "select count(distinct id) from instance_group_view WHERE ";
+ }
+
+
+
+ @Override
+ public InstanceGroupResponse newInstanceGroupResponse(InstanceGroupJoinVO group) {
+ InstanceGroupResponse groupResponse = new InstanceGroupResponse();
+ groupResponse.setId(group.getUuid());
+ groupResponse.setName(group.getName());
+ groupResponse.setCreated(group.getCreated());
+
+ ApiResponseHelper.populateOwner(groupResponse, group);
+
+ groupResponse.setObjectName("instancegroup");
+ return groupResponse;
+ }
+
+
+
+ @Override
+ public InstanceGroupJoinVO newInstanceGroupView(InstanceGroup group) {
+ SearchCriteria<InstanceGroupJoinVO> sc = vrIdSearch.create();
+ sc.setParameters("id", group.getId());
+ List<InstanceGroupJoinVO> grps = searchIncludingRemoved(sc, null, null, false);
+ assert grps != null && grps.size() == 1 : "No vm group found for group id " + group.getId();
+ return grps.get(0);
+
+ }
+
+
+
+ @Override
+ public List<InstanceGroupJoinVO> searchByIds(Long... ids) {
+ SearchCriteria<InstanceGroupJoinVO> sc = vrSearch.create();
+ sc.setParameters("idIN", ids);
+ return searchIncludingRemoved(sc, null, null, false);
+ }
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/dao/ProjectAccountJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/ProjectAccountJoinDao.java b/server/src/com/cloud/api/query/dao/ProjectAccountJoinDao.java
new file mode 100644
index 0000000..a653ddd
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/ProjectAccountJoinDao.java
@@ -0,0 +1,34 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.response.ProjectAccountResponse;
+
+import com.cloud.api.query.vo.ProjectAccountJoinVO;
+import com.cloud.projects.ProjectAccount;
+import com.cloud.utils.db.GenericDao;
+
+public interface ProjectAccountJoinDao extends GenericDao<ProjectAccountJoinVO, Long> {
+
+ ProjectAccountResponse newProjectAccountResponse(ProjectAccountJoinVO proj);
+
+ ProjectAccountJoinVO newProjectAccountView(ProjectAccount proj);
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/dao/ProjectAccountJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/ProjectAccountJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/ProjectAccountJoinDaoImpl.java
new file mode 100644
index 0000000..59eeb46
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/ProjectAccountJoinDaoImpl.java
@@ -0,0 +1,86 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.response.ProjectAccountResponse;
+
+import com.cloud.api.query.vo.ProjectAccountJoinVO;
+import com.cloud.projects.ProjectAccount;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Local(value={ProjectAccountJoinDao.class})
+public class ProjectAccountJoinDaoImpl extends GenericDaoBase<ProjectAccountJoinVO, Long> implements ProjectAccountJoinDao {
+ public static final Logger s_logger = Logger.getLogger(ProjectAccountJoinDaoImpl.class);
+
+
+ private SearchBuilder<ProjectAccountJoinVO> vrIdSearch;
+
+ protected ProjectAccountJoinDaoImpl() {
+
+ vrIdSearch = createSearchBuilder();
+ vrIdSearch.and("accountId", vrIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
+ vrIdSearch.and("projectId", vrIdSearch.entity().getProjectId(), SearchCriteria.Op.EQ);
+ vrIdSearch.done();
+
+ this._count = "select count(distinct id) from project_account_view WHERE ";
+ }
+
+
+
+
+ @Override
+ public ProjectAccountResponse newProjectAccountResponse(ProjectAccountJoinVO proj) {
+ ProjectAccountResponse projectAccountResponse = new ProjectAccountResponse();
+
+ projectAccountResponse.setProjectId(proj.getProjectUuid());
+ projectAccountResponse.setProjectName(proj.getProjectName());
+
+ projectAccountResponse.setAccountId(proj.getAccountUuid());
+ projectAccountResponse.setAccountName(proj.getAccountName());
+ projectAccountResponse.setAccountType(proj.getAccountType());
+ projectAccountResponse.setRole(proj.getAccountRole().toString());
+ projectAccountResponse.setDomainId(proj.getDomainUuid());
+ projectAccountResponse.setDomainName(proj.getDomainName());
+
+ projectAccountResponse.setObjectName("projectaccount");
+
+ return projectAccountResponse;
+ }
+
+
+
+
+ @Override
+ public ProjectAccountJoinVO newProjectAccountView(ProjectAccount proj) {
+ SearchCriteria<ProjectAccountJoinVO> sc = vrIdSearch.create();
+ sc.setParameters("accountId", proj.getAccountId());
+ sc.setParameters("projectId", proj.getProjectId());
+ List<ProjectAccountJoinVO> grps = searchIncludingRemoved(sc, null, null, false);
+ assert grps != null && grps.size() == 1 : "No project account found for account id = " + proj.getAccountId() + " and project id = " + proj.getProjectId();
+ return grps.get(0);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/dao/ProjectInvitationJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/ProjectInvitationJoinDao.java b/server/src/com/cloud/api/query/dao/ProjectInvitationJoinDao.java
new file mode 100644
index 0000000..ae81f0e
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/ProjectInvitationJoinDao.java
@@ -0,0 +1,30 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import org.apache.cloudstack.api.response.ProjectInvitationResponse;
+
+import com.cloud.api.query.vo.ProjectInvitationJoinVO;
+import com.cloud.projects.ProjectInvitation;
+import com.cloud.utils.db.GenericDao;
+
+public interface ProjectInvitationJoinDao extends GenericDao<ProjectInvitationJoinVO, Long> {
+
+ ProjectInvitationResponse newProjectInvitationResponse(ProjectInvitationJoinVO proj);
+
+ ProjectInvitationJoinVO newProjectInvitationView(ProjectInvitation proj);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/dao/ProjectInvitationJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/ProjectInvitationJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/ProjectInvitationJoinDaoImpl.java
new file mode 100644
index 0000000..4173861
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/ProjectInvitationJoinDaoImpl.java
@@ -0,0 +1,86 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.response.ProjectInvitationResponse;
+
+import com.cloud.api.ApiDBUtils;
+import com.cloud.api.query.vo.ProjectInvitationJoinVO;
+import com.cloud.projects.ProjectInvitation;
+import com.cloud.user.Account;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Local(value={ProjectInvitationJoinDao.class})
+public class ProjectInvitationJoinDaoImpl extends GenericDaoBase<ProjectInvitationJoinVO, Long> implements ProjectInvitationJoinDao {
+ public static final Logger s_logger = Logger.getLogger(ProjectInvitationJoinDaoImpl.class);
+
+
+ private SearchBuilder<ProjectInvitationJoinVO> vrIdSearch;
+
+ protected ProjectInvitationJoinDaoImpl() {
+
+ vrIdSearch = createSearchBuilder();
+ vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
+ vrIdSearch.done();
+
+ this._count = "select count(distinct id) from project_invitation_view WHERE ";
+ }
+
+
+
+ @Override
+ public ProjectInvitationResponse newProjectInvitationResponse(ProjectInvitationJoinVO invite) {
+ ProjectInvitationResponse response = new ProjectInvitationResponse();
+ response.setId(invite.getUuid());
+ response.setProjectId(invite.getProjectUuid());
+ response.setProjectName(invite.getProjectName());
+ response.setInvitationState(invite.getState().toString());
+
+ if (invite.getAccountName() != null) {
+ response.setAccountName(invite.getAccountName());
+ } else {
+ response.setEmail(invite.getEmail());
+ }
+
+ response.setDomainId(invite.getDomainUuid());
+ response.setDomainName(invite.getDomainName());
+
+ response.setObjectName("projectinvitation");
+ return response;
+ }
+
+
+
+ @Override
+ public ProjectInvitationJoinVO newProjectInvitationView(ProjectInvitation proj) {
+ SearchCriteria<ProjectInvitationJoinVO> sc = vrIdSearch.create();
+ sc.setParameters("id", proj.getId());
+ List<ProjectInvitationJoinVO> grps = searchIncludingRemoved(sc, null, null, false);
+ assert grps != null && grps.size() == 1 : "No project invitation found for id " + proj.getId();
+ return grps.get(0);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/dao/ProjectJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/ProjectJoinDao.java b/server/src/com/cloud/api/query/dao/ProjectJoinDao.java
new file mode 100644
index 0000000..9eeb8aa
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/ProjectJoinDao.java
@@ -0,0 +1,37 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.response.ProjectResponse;
+
+import com.cloud.api.query.vo.ProjectJoinVO;
+import com.cloud.projects.Project;
+import com.cloud.utils.db.GenericDao;
+
+public interface ProjectJoinDao extends GenericDao<ProjectJoinVO, Long> {
+
+ ProjectResponse newProjectResponse(ProjectJoinVO proj);
+
+ ProjectResponse setProjectResponse(ProjectResponse rsp, ProjectJoinVO proj);
+
+ List<ProjectJoinVO> newProjectView(Project proj);
+
+ List<ProjectJoinVO> searchByIds(Long... ids);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/dao/ProjectJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/ProjectJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/ProjectJoinDaoImpl.java
new file mode 100644
index 0000000..a2aaa21
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/ProjectJoinDaoImpl.java
@@ -0,0 +1,109 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.api.ApiDBUtils;
+import com.cloud.api.query.vo.ProjectJoinVO;
+import com.cloud.api.query.vo.ResourceTagJoinVO;
+
+import org.apache.cloudstack.api.response.ProjectResponse;
+import com.cloud.projects.Project;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Local(value={ProjectJoinDao.class})
+public class ProjectJoinDaoImpl extends GenericDaoBase<ProjectJoinVO, Long> implements ProjectJoinDao {
+ public static final Logger s_logger = Logger.getLogger(ProjectJoinDaoImpl.class);
+
+ private SearchBuilder<ProjectJoinVO> vrSearch;
+
+ private SearchBuilder<ProjectJoinVO> vrIdSearch;
+
+ protected ProjectJoinDaoImpl() {
+
+ vrSearch = createSearchBuilder();
+ vrSearch.and("idIN", vrSearch.entity().getId(), SearchCriteria.Op.IN);
+ vrSearch.done();
+
+ vrIdSearch = createSearchBuilder();
+ vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
+ vrIdSearch.done();
+
+ this._count = "select count(distinct id) from project_view WHERE ";
+ }
+
+ @Override
+ public ProjectResponse newProjectResponse(ProjectJoinVO proj) {
+ ProjectResponse response = new ProjectResponse();
+ response.setId(proj.getUuid());
+ response.setName(proj.getName());
+ response.setDisplaytext(proj.getDisplayText());
+ response.setState(proj.getState().toString());
+
+ response.setDomainId(proj.getDomainUuid());
+ response.setDomain(proj.getDomainName());
+
+ response.setOwner(proj.getOwner());
+
+ // update tag information
+ Long tag_id = proj.getTagId();
+ if (tag_id != null && tag_id.longValue() > 0) {
+ ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
+ if ( vtag != null ){
+ response.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
+ }
+ }
+
+ response.setObjectName("project");
+ return response;
+ }
+
+ @Override
+ public ProjectResponse setProjectResponse(ProjectResponse rsp, ProjectJoinVO proj) {
+ // update tag information
+ Long tag_id = proj.getTagId();
+ if (tag_id != null && tag_id.longValue() > 0) {
+ ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
+ if ( vtag != null ){
+ rsp.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
+ }
+ }
+ return rsp;
+ }
+
+ @Override
+ public List<ProjectJoinVO> newProjectView(Project proj) {
+ SearchCriteria<ProjectJoinVO> sc = vrIdSearch.create();
+ sc.setParameters("id", proj.getId());
+ return searchIncludingRemoved(sc, null, null, false);
+ }
+
+ @Override
+ public List<ProjectJoinVO> searchByIds(Long... ids) {
+ SearchCriteria<ProjectJoinVO> sc = vrSearch.create();
+ sc.setParameters("idIN", ids);
+ return searchIncludingRemoved(sc, null, null, false);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/dao/ResourceTagJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/ResourceTagJoinDao.java b/server/src/com/cloud/api/query/dao/ResourceTagJoinDao.java
new file mode 100644
index 0000000..57fc130
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/ResourceTagJoinDao.java
@@ -0,0 +1,34 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.response.ResourceTagResponse;
+
+import com.cloud.api.query.vo.ResourceTagJoinVO;
+import com.cloud.server.ResourceTag;
+import com.cloud.utils.db.GenericDao;
+
+public interface ResourceTagJoinDao extends GenericDao<ResourceTagJoinVO, Long> {
+
+ ResourceTagResponse newResourceTagResponse(ResourceTagJoinVO uvo, boolean keyValueOnly );
+
+ ResourceTagJoinVO newResourceTagView(ResourceTag vr);
+
+ List<ResourceTagJoinVO> searchByIds(Long... ids);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/dao/ResourceTagJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/ResourceTagJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/ResourceTagJoinDaoImpl.java
new file mode 100644
index 0000000..badf457
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/ResourceTagJoinDaoImpl.java
@@ -0,0 +1,104 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.api.ApiResponseHelper;
+import com.cloud.api.query.vo.ResourceTagJoinVO;
+
+import org.apache.cloudstack.api.response.ResourceTagResponse;
+import com.cloud.server.ResourceTag;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+
+@Local(value={ResourceTagJoinDao.class})
+public class ResourceTagJoinDaoImpl extends GenericDaoBase<ResourceTagJoinVO, Long> implements ResourceTagJoinDao {
+ public static final Logger s_logger = Logger.getLogger(ResourceTagJoinDaoImpl.class);
+
+ private SearchBuilder<ResourceTagJoinVO> vrSearch;
+
+ private SearchBuilder<ResourceTagJoinVO> vrIdSearch;
+
+ protected ResourceTagJoinDaoImpl() {
+
+ vrSearch = createSearchBuilder();
+ vrSearch.and("idIN", vrSearch.entity().getId(), SearchCriteria.Op.IN);
+ vrSearch.done();
+
+ vrIdSearch = createSearchBuilder();
+ vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
+ vrIdSearch.done();
+
+ this._count = "select count(distinct id) from resource_tag_view WHERE ";
+ }
+
+
+
+
+
+ @Override
+ public ResourceTagResponse newResourceTagResponse(ResourceTagJoinVO resourceTag, boolean keyValueOnly) {
+ ResourceTagResponse response = new ResourceTagResponse();
+ response.setKey(resourceTag.getKey());
+ response.setValue(resourceTag.getValue());
+
+ if (!keyValueOnly) {
+ response.setResourceType(resourceTag.getResourceType().toString());
+ response.setResourceId(resourceTag.getResourceUuid());
+
+ ApiResponseHelper.populateOwner(response, resourceTag);
+
+ response.setDomainId(resourceTag.getDomainUuid());
+ response.setDomainName(resourceTag.getDomainName());
+
+ response.setCustomer(resourceTag.getCustomer());
+ }
+
+ response.setObjectName("tag");
+
+ return response;
+ }
+
+
+ @Override
+ public List<ResourceTagJoinVO> searchByIds(Long... ids) {
+ SearchCriteria<ResourceTagJoinVO> sc = vrSearch.create();
+ sc.setParameters("idIN", ids);
+ return searchIncludingRemoved(sc, null, null, false);
+ }
+
+
+ @Override
+ public ResourceTagJoinVO newResourceTagView(ResourceTag vr) {
+
+ SearchCriteria<ResourceTagJoinVO> sc = vrIdSearch.create();
+ sc.setParameters("id", vr.getId());
+ List<ResourceTagJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+ assert vms != null && vms.size() == 1 : "No tag found for tag id " + vr.getId();
+ return vms.get(0);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/dao/SecurityGroupJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/SecurityGroupJoinDao.java b/server/src/com/cloud/api/query/dao/SecurityGroupJoinDao.java
new file mode 100644
index 0000000..de1b72a
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/SecurityGroupJoinDao.java
@@ -0,0 +1,38 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.response.SecurityGroupResponse;
+
+import com.cloud.api.query.vo.SecurityGroupJoinVO;
+import com.cloud.network.security.SecurityGroup;
+import com.cloud.user.Account;
+import com.cloud.utils.db.GenericDao;
+
+public interface SecurityGroupJoinDao extends GenericDao<SecurityGroupJoinVO, Long> {
+
+ SecurityGroupResponse newSecurityGroupResponse(SecurityGroupJoinVO vsg, Account caller);
+
+ SecurityGroupResponse setSecurityGroupResponse(SecurityGroupResponse vsgData, SecurityGroupJoinVO vsg);
+
+ List<SecurityGroupJoinVO> newSecurityGroupView(SecurityGroup sg);
+
+ List<SecurityGroupJoinVO> searchByIds(Long... ids);
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/dao/SecurityGroupJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/SecurityGroupJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/SecurityGroupJoinDaoImpl.java
new file mode 100644
index 0000000..b7994cb
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/SecurityGroupJoinDaoImpl.java
@@ -0,0 +1,178 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.api.ApiDBUtils;
+import com.cloud.api.ApiResponseHelper;
+import com.cloud.api.query.vo.ResourceTagJoinVO;
+import com.cloud.api.query.vo.SecurityGroupJoinVO;
+
+import org.apache.cloudstack.api.response.SecurityGroupResponse;
+import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
+import com.cloud.network.security.SecurityGroup;
+import com.cloud.network.security.SecurityRule.SecurityRuleType;
+import com.cloud.user.Account;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Local(value={SecurityGroupJoinDao.class})
+public class SecurityGroupJoinDaoImpl extends GenericDaoBase<SecurityGroupJoinVO, Long> implements SecurityGroupJoinDao {
+ public static final Logger s_logger = Logger.getLogger(SecurityGroupJoinDaoImpl.class);
+
+ private SearchBuilder<SecurityGroupJoinVO> sgSearch;
+
+ private SearchBuilder<SecurityGroupJoinVO> sgIdSearch;
+
+ protected SecurityGroupJoinDaoImpl() {
+
+ sgSearch = createSearchBuilder();
+ sgSearch.and("idIN", sgSearch.entity().getId(), SearchCriteria.Op.IN);
+ sgSearch.done();
+
+ sgIdSearch = createSearchBuilder();
+ sgIdSearch.and("id", sgIdSearch.entity().getId(), SearchCriteria.Op.EQ);
+ sgIdSearch.done();
+
+ this._count = "select count(distinct id) from security_group_view WHERE ";
+ }
+
+ @Override
+ public SecurityGroupResponse newSecurityGroupResponse(SecurityGroupJoinVO vsg, Account caller) {
+ SecurityGroupResponse sgResponse = new SecurityGroupResponse();
+ sgResponse.setId(vsg.getUuid());
+ sgResponse.setName(vsg.getName());
+ sgResponse.setDescription(vsg.getDescription());
+
+ ApiResponseHelper.populateOwner(sgResponse, vsg);
+
+ Long rule_id = vsg.getRuleId();
+ if (rule_id != null && rule_id.longValue() > 0) {
+ SecurityGroupRuleResponse ruleData = new SecurityGroupRuleResponse();
+ ruleData.setRuleId(vsg.getRuleUuid());
+ ruleData.setProtocol(vsg.getRuleProtocol());
+
+ if ("icmp".equalsIgnoreCase(vsg.getRuleProtocol())) {
+ ruleData.setIcmpType(vsg.getRuleStartPort());
+ ruleData.setIcmpCode(vsg.getRuleEndPort());
+ } else {
+ ruleData.setStartPort(vsg.getRuleStartPort());
+ ruleData.setEndPort(vsg.getRuleEndPort());
+ }
+
+ if (vsg.getRuleAllowedNetworkId() != null) {
+ List<SecurityGroupJoinVO> sgs = this.searchByIds(vsg.getRuleAllowedNetworkId());
+ if (sgs != null && sgs.size() > 0) {
+ SecurityGroupJoinVO sg = sgs.get(0);
+ ruleData.setSecurityGroupName(sg.getName());
+ ruleData.setAccountName(sg.getAccountName());
+ }
+ } else {
+ ruleData.setCidr(vsg.getRuleAllowedSourceIpCidr());
+ }
+
+ if (vsg.getRuleType() == SecurityRuleType.IngressRule) {
+ ruleData.setObjectName("ingressrule");
+ sgResponse.addSecurityGroupIngressRule(ruleData);
+ } else {
+ ruleData.setObjectName("egressrule");
+ sgResponse.addSecurityGroupEgressRule(ruleData);
+ }
+ }
+
+ // update tag information
+ Long tag_id = vsg.getTagId();
+ if (tag_id != null && tag_id.longValue() > 0) {
+ ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
+ if ( vtag != null ){
+ sgResponse.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
+ }
+ }
+ sgResponse.setObjectName("securitygroup");
+
+ return sgResponse;
+ }
+
+ @Override
+ public SecurityGroupResponse setSecurityGroupResponse(SecurityGroupResponse vsgData, SecurityGroupJoinVO vsg) {
+ Long rule_id = vsg.getRuleId();
+ if (rule_id != null && rule_id.longValue() > 0) {
+ SecurityGroupRuleResponse ruleData = new SecurityGroupRuleResponse();
+ ruleData.setRuleId(vsg.getRuleUuid());
+ ruleData.setProtocol(vsg.getRuleProtocol());
+
+ if ("icmp".equalsIgnoreCase(vsg.getRuleProtocol())) {
+ ruleData.setIcmpType(vsg.getRuleStartPort());
+ ruleData.setIcmpCode(vsg.getRuleEndPort());
+ } else {
+ ruleData.setStartPort(vsg.getRuleStartPort());
+ ruleData.setEndPort(vsg.getRuleEndPort());
+ }
+
+ if (vsg.getRuleAllowedNetworkId() != null) {
+ List<SecurityGroupJoinVO> sgs = this.searchByIds(vsg.getRuleAllowedNetworkId());
+ if (sgs != null && sgs.size() > 0) {
+ SecurityGroupJoinVO sg = sgs.get(0);
+ ruleData.setSecurityGroupName(sg.getName());
+ ruleData.setAccountName(sg.getAccountName());
+ }
+ } else {
+ ruleData.setCidr(vsg.getRuleAllowedSourceIpCidr());
+ }
+
+ if (vsg.getRuleType() == SecurityRuleType.IngressRule) {
+ ruleData.setObjectName("ingressrule");
+ vsgData.addSecurityGroupIngressRule(ruleData);
+ } else {
+ ruleData.setObjectName("egressrule");
+ vsgData.addSecurityGroupEgressRule(ruleData);
+ }
+ }
+
+ // update tag information
+ Long tag_id = vsg.getTagId();
+ if (tag_id != null && tag_id.longValue() > 0 ) {
+ ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
+ if ( vtag != null ){
+ vsgData.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
+ }
+ }
+ return vsgData;
+ }
+
+ @Override
+ public List<SecurityGroupJoinVO> newSecurityGroupView(SecurityGroup sg) {
+
+ SearchCriteria<SecurityGroupJoinVO> sc = sgIdSearch.create();
+ sc.setParameters("id", sg.getId());
+ return searchIncludingRemoved(sc, null, null, false);
+ }
+
+ @Override
+ public List<SecurityGroupJoinVO> searchByIds(Long... ids) {
+ SearchCriteria<SecurityGroupJoinVO> sc = sgSearch.create();
+ sc.setParameters("idIN", ids);
+ return searchIncludingRemoved(sc, null, null, false);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/dao/UserVmJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/UserVmJoinDao.java b/server/src/com/cloud/api/query/dao/UserVmJoinDao.java
new file mode 100644
index 0000000..2617a74
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/UserVmJoinDao.java
@@ -0,0 +1,39 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import java.util.EnumSet;
+import java.util.List;
+
+import org.apache.cloudstack.api.ApiConstants.VMDetails;
+import org.apache.cloudstack.api.response.UserVmResponse;
+
+import com.cloud.api.query.vo.UserVmJoinVO;
+import com.cloud.user.Account;
+import com.cloud.uservm.UserVm;
+import com.cloud.utils.db.GenericDao;
+
+public interface UserVmJoinDao extends GenericDao<UserVmJoinVO, Long> {
+
+ UserVmResponse newUserVmResponse(String objectName, UserVmJoinVO userVm, EnumSet<VMDetails> details, Account caller);
+
+ UserVmResponse setUserVmResponse(UserVmResponse userVmData, UserVmJoinVO uvo);
+
+ List<UserVmJoinVO> newUserVmView(UserVm... userVms);
+
+ List<UserVmJoinVO> searchByIds(Long... ids);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
new file mode 100644
index 0000000..e8317a8
--- /dev/null
+++ b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
@@ -0,0 +1,328 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.dao;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.Hashtable;
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.api.ApiDBUtils;
+import com.cloud.api.query.vo.ResourceTagJoinVO;
+import com.cloud.api.query.vo.UserVmJoinVO;
+
+import org.apache.cloudstack.api.ApiConstants.VMDetails;
+import org.apache.cloudstack.api.response.NicResponse;
+import org.apache.cloudstack.api.response.SecurityGroupResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import com.cloud.user.Account;
+import com.cloud.uservm.UserVm;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.vm.VmStats;
+
+
+@Local(value={UserVmJoinDao.class})
+public class UserVmJoinDaoImpl extends GenericDaoBase<UserVmJoinVO, Long> implements UserVmJoinDao {
+ public static final Logger s_logger = Logger.getLogger(UserVmJoinDaoImpl.class);
+
+ private static final int VM_DETAILS_BATCH_SIZE=100;
+
+ private SearchBuilder<UserVmJoinVO> VmDetailSearch;
+
+ protected UserVmJoinDaoImpl() {
+
+ VmDetailSearch = createSearchBuilder();
+ VmDetailSearch.and("idIN", VmDetailSearch.entity().getId(), SearchCriteria.Op.IN);
+ VmDetailSearch.done();
+
+ this._count = "select count(distinct id) from user_vm_view WHERE ";
+ }
+
+ public UserVmResponse newUserVmResponse(String objectName, UserVmJoinVO userVm, EnumSet<VMDetails> details, Account caller) {
+ UserVmResponse userVmResponse = new UserVmResponse();
+
+ if (userVm.getHypervisorType() != null){
+ userVmResponse.setHypervisor(userVm.getHypervisorType().toString());
+ }
+ userVmResponse.setId(userVm.getUuid());
+ userVmResponse.setName(userVm.getName());
+
+ userVmResponse.setDisplayName(userVm.getDisplayName());
+
+ if (userVm.getAccountType() == Account.ACCOUNT_TYPE_PROJECT) {
+ userVmResponse.setProjectId(userVm.getProjectUuid());
+ userVmResponse.setProjectName(userVm.getProjectName());
+ } else {
+ userVmResponse.setAccountName(userVm.getAccountName());
+ }
+
+ userVmResponse.setDomainId(userVm.getDomainUuid());
+ userVmResponse.setDomainName(userVm.getDomainName());
+
+ userVmResponse.setCreated(userVm.getCreated());
+
+ if (userVm.getState() != null) {
+ userVmResponse.setState(userVm.getState().toString());
+ }
+ userVmResponse.setHaEnable(userVm.isHaEnabled());
+ if (details.contains(VMDetails.all) || details.contains(VMDetails.group)) {
+ userVmResponse.setGroupId(userVm.getInstanceGroupUuid());
+ userVmResponse.setGroup(userVm.getInstanceGroupName());
+ }
+ userVmResponse.setZoneId(userVm.getDataCenterUuid());
+ userVmResponse.setZoneName(userVm.getDataCenterName());
+ if ((caller == null) || (caller.getType() == Account.ACCOUNT_TYPE_ADMIN)) {
+ userVmResponse.setInstanceName(userVm.getInstanceName());
+ userVmResponse.setHostId(userVm.getHostUuid());
+ userVmResponse.setHostName(userVm.getHostName());
+ }
+
+ if (details.contains(VMDetails.all) || details.contains(VMDetails.tmpl)) {
+ userVmResponse.setTemplateId(userVm.getTemplateUuid());
+ userVmResponse.setTemplateName(userVm.getTemplateName());
+ userVmResponse.setTemplateDisplayText(userVm.getTemplateDisplayText());
+ userVmResponse.setPasswordEnabled(userVm.isPasswordEnabled());
+ }
+ if (details.contains(VMDetails.all) || details.contains(VMDetails.iso)) {
+ userVmResponse.setIsoId(userVm.getIsoUuid());
+ userVmResponse.setIsoName(userVm.getIsoName());
+ userVmResponse.setIsoDisplayText(userVm.getIsoDisplayText());
+ }
+ if (details.contains(VMDetails.all) || details.contains(VMDetails.servoff)) {
+ userVmResponse.setServiceOfferingId(userVm.getServiceOfferingUuid());
+ userVmResponse.setServiceOfferingName(userVm.getServiceOfferingName());
+ userVmResponse.setCpuNumber(userVm.getCpu());
+ userVmResponse.setCpuSpeed(userVm.getSpeed());
+ userVmResponse.setMemory(userVm.getRamSize());
+ }
+ userVmResponse.setGuestOsId(userVm.getGuestOsUuid());
+ if (details.contains(VMDetails.all) || details.contains(VMDetails.volume)) {
+ userVmResponse.setRootDeviceId(userVm.getVolumeDeviceId());
+ if (userVm.getVolumeType() != null) {
+ userVmResponse.setRootDeviceType(userVm.getVolumeType().toString());
+ }
+ }
+ userVmResponse.setPassword(userVm.getPassword());
+ userVmResponse.setJobUuid(userVm.getJobUuid());
+ userVmResponse.setJobStatus(userVm.getJobStatus());
+ //userVmResponse.setForVirtualNetwork(userVm.getForVirtualNetwork());
+
+ userVmResponse.setPublicIpId(userVm.getPublicIpUuid());
+ userVmResponse.setPublicIp(userVm.getPublicIpAddress());
+ userVmResponse.setKeyPairName(userVm.getKeypairName());
+
+ if (details.contains(VMDetails.all) || details.contains(VMDetails.stats)) {
+ DecimalFormat decimalFormat = new DecimalFormat("#.##");
+ // stats calculation
+ String cpuUsed = null;
+ VmStats vmStats = ApiDBUtils.getVmStatistics(userVm.getId());
+ if (vmStats != null) {
+ float cpuUtil = (float) vmStats.getCPUUtilization();
+ cpuUsed = decimalFormat.format(cpuUtil) + "%";
+ userVmResponse.setCpuUsed(cpuUsed);
+
+ Double networkKbRead = Double.valueOf(vmStats.getNetworkReadKBs());
+ userVmResponse.setNetworkKbsRead(networkKbRead.longValue());
+
+ Double networkKbWrite = Double.valueOf(vmStats.getNetworkWriteKBs());
+ userVmResponse.setNetworkKbsWrite(networkKbWrite.longValue());
+ }
+ }
+
+ if (details.contains(VMDetails.all) || details.contains(VMDetails.secgrp)) {
+ Long securityGroupId = userVm.getSecurityGroupId();
+ if (securityGroupId != null && securityGroupId.longValue() != 0) {
+ SecurityGroupResponse resp = new SecurityGroupResponse();
+ resp.setId(userVm.getSecurityGroupUuid());
+ resp.setName(userVm.getSecurityGroupName());
+ resp.setDescription(userVm.getSecurityGroupDescription());
+ resp.setObjectName("securitygroup");
+ if (userVm.getAccountType() == Account.ACCOUNT_TYPE_PROJECT) {
+ resp.setProjectId(userVm.getProjectUuid());
+ resp.setProjectName(userVm.getProjectName());
+ } else {
+ resp.setAccountName(userVm.getAccountName());
+ }
+ userVmResponse.addSecurityGroup(resp);
+ }
+ }
+
+ if (details.contains(VMDetails.all) || details.contains(VMDetails.nics)) {
+ long nic_id = userVm.getNicId();
+ if (nic_id > 0) {
+ NicResponse nicResponse = new NicResponse();
+ nicResponse.setId(userVm.getNicUuid());
+ nicResponse.setIpaddress(userVm.getIpAddress());
+ nicResponse.setGateway(userVm.getGateway());
+ nicResponse.setNetmask(userVm.getNetmask());
+ nicResponse.setNetworkid(userVm.getNetworkUuid());
+ nicResponse.setMacAddress(userVm.getMacAddress());
+ if (userVm.getBroadcastUri() != null) {
+ nicResponse.setBroadcastUri(userVm.getBroadcastUri().toString());
+ }
+ if (userVm.getIsolationUri() != null) {
+ nicResponse.setIsolationUri(userVm.getIsolationUri().toString());
+ }
+ if (userVm.getTrafficType() != null) {
+ nicResponse.setTrafficType(userVm.getTrafficType().toString());
+ }
+ if (userVm.getGuestType() != null) {
+ nicResponse.setType(userVm.getGuestType().toString());
+ }
+ nicResponse.setIsDefault(userVm.isDefaultNic());
+ nicResponse.setObjectName("nic");
+ userVmResponse.addNic(nicResponse);
+ }
+ }
+
+ // update tag information
+ long tag_id = userVm.getTagId();
+ if (tag_id > 0) {
+ ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
+ if ( vtag != null ){
+ userVmResponse.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
+ }
+ }
+ userVmResponse.setObjectName(objectName);
+
+ return userVmResponse;
+ }
+
+ public UserVmResponse setUserVmResponse(UserVmResponse userVmData, UserVmJoinVO uvo) {
+ Long securityGroupId = uvo.getSecurityGroupId();
+ if (securityGroupId != null && securityGroupId.longValue() != 0) {
+ SecurityGroupResponse resp = new SecurityGroupResponse();
+ resp.setId(uvo.getSecurityGroupUuid());
+ resp.setName(uvo.getSecurityGroupName());
+ resp.setDescription(uvo.getSecurityGroupDescription());
+ resp.setObjectName("securitygroup");
+ if (uvo.getAccountType() == Account.ACCOUNT_TYPE_PROJECT) {
+ resp.setProjectId(uvo.getProjectUuid());
+ resp.setProjectName(uvo.getProjectName());
+ } else {
+ resp.setAccountName(uvo.getAccountName());
+ }
+ userVmData.addSecurityGroup(resp);
+ }
+
+ long nic_id = uvo.getNicId();
+ if (nic_id > 0) {
+ NicResponse nicResponse = new NicResponse();
+ nicResponse.setId(uvo.getNicUuid());
+ nicResponse.setIpaddress(uvo.getIpAddress());
+ nicResponse.setGateway(uvo.getGateway());
+ nicResponse.setNetmask(uvo.getNetmask());
+ nicResponse.setNetworkid(uvo.getNetworkUuid());
+ nicResponse.setMacAddress(uvo.getMacAddress());
+ if (uvo.getBroadcastUri() != null) {
+ nicResponse.setBroadcastUri(uvo.getBroadcastUri().toString());
+ }
+ if (uvo.getIsolationUri() != null) {
+ nicResponse.setIsolationUri(uvo.getIsolationUri().toString());
+ }
+ if (uvo.getTrafficType() != null) {
+ nicResponse.setTrafficType(uvo.getTrafficType().toString());
+ }
+ if (uvo.getGuestType() != null) {
+ nicResponse.setType(uvo.getGuestType().toString());
+ }
+ nicResponse.setIsDefault(uvo.isDefaultNic());
+ nicResponse.setObjectName("nic");
+ userVmData.addNic(nicResponse);
+ }
+
+ long tag_id = uvo.getTagId();
+ if (tag_id > 0) {
+ ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
+ if ( vtag != null ){
+ userVmData.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
+ }
+ }
+ return userVmData;
+ }
+
+
+ @Override
+ public List<UserVmJoinVO> searchByIds(Long... vmIds) {
+ SearchCriteria<UserVmJoinVO> sc = VmDetailSearch.create();
+ sc.setParameters("idIN", vmIds);
+ return searchIncludingRemoved(sc, null, null, false);
+ }
+
+ @Override
+ public List<UserVmJoinVO> newUserVmView(UserVm... userVms) {
+
+ int curr_index = 0;
+
+ Hashtable<Long, UserVm> userVmDataHash = new Hashtable<Long, UserVm>();
+ for (UserVm vm : userVms){
+ if ( !userVmDataHash.containsKey(vm.getId())){
+ userVmDataHash.put(vm.getId(), vm);
+ }
+ }
+
+ List<UserVmJoinVO> uvList = new ArrayList<UserVmJoinVO>();
+ List<Long> userVmIdList = new ArrayList(userVmDataHash.keySet());
+ if (userVmIdList.size() > VM_DETAILS_BATCH_SIZE) {
+ while ((curr_index + VM_DETAILS_BATCH_SIZE) <= userVmIdList.size()) {
+ // set current ids
+ Long[] vmIds = new Long[VM_DETAILS_BATCH_SIZE];
+ for (int k = 0, j = curr_index; j < curr_index + VM_DETAILS_BATCH_SIZE; j++, k++) {
+ vmIds[k] = userVmIdList.get(j);
+ }
+ SearchCriteria<UserVmJoinVO> sc = VmDetailSearch.create();
+ sc.setParameters("idIN", vmIds);
+ List<UserVmJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+ if (vms != null) {
+ for (UserVmJoinVO uvm : vms) {
+ uvList.add(uvm);
+ }
+ }
+ curr_index += VM_DETAILS_BATCH_SIZE;
+ }
+ }
+
+ if (curr_index < userVmIdList.size()) {
+ int batch_size = (userVmIdList.size() - curr_index);
+ // set the ids value
+ Long[] vmIds = new Long[batch_size];
+ for (int k = 0, j = curr_index; j < curr_index + batch_size; j++, k++) {
+ vmIds[k] = userVmIdList.get(j);
+ }
+ SearchCriteria<UserVmJoinVO> sc = VmDetailSearch.create();
+ sc.setParameters("idIN", vmIds);
+ List<UserVmJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+ if (vms != null) {
+ for (UserVmJoinVO uvm : vms) {
+ UserVm vm = userVmDataHash.get(uvm.getId());
+ assert vm != null : "We should not find details of vm not in the passed UserVm list";
+ uvList.add(uvm);
+ }
+ }
+ }
+ return uvList;
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/vo/BaseViewVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/BaseViewVO.java b/server/src/com/cloud/api/query/vo/BaseViewVO.java
new file mode 100644
index 0000000..604f459
--- /dev/null
+++ b/server/src/com/cloud/api/query/vo/BaseViewVO.java
@@ -0,0 +1,49 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.vo;
+
+import javax.persistence.Column;
+
+public abstract class BaseViewVO {
+
+ public abstract long getId();
+
+ public abstract void setId(long id);
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (getId() ^ (getId() >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ BaseViewVO other = (BaseViewVO) obj;
+ if (getId() != other.getId())
+ return false;
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/vo/ControlledViewEntity.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/ControlledViewEntity.java b/server/src/com/cloud/api/query/vo/ControlledViewEntity.java
new file mode 100644
index 0000000..8b36874
--- /dev/null
+++ b/server/src/com/cloud/api/query/vo/ControlledViewEntity.java
@@ -0,0 +1,45 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.vo;
+
+import com.cloud.acl.ControlledEntity;
+
+/**
+ * This is the interface for all VO classes representing DB views created for previous ControlledEntity.
+ *
+ * @author minc
+ *
+ */
+public interface ControlledViewEntity extends ControlledEntity {
+
+ public String getDomainPath();
+
+ public short getAccountType();
+
+ public String getAccountUuid();
+
+ public String getAccountName();
+
+ public String getDomainUuid();
+
+ public String getDomainName();
+
+ public String getProjectUuid();
+
+ public String getProjectName();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/api/query/vo/DomainRouterJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/DomainRouterJoinVO.java b/server/src/com/cloud/api/query/vo/DomainRouterJoinVO.java
new file mode 100644
index 0000000..cf59827
--- /dev/null
+++ b/server/src/com/cloud/api/query/vo/DomainRouterJoinVO.java
@@ -0,0 +1,920 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.query.vo;
+
+import java.net.URI;
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Table;
+
+import com.cloud.network.Network.GuestType;
+import com.cloud.network.Networks.TrafficType;
+import com.cloud.network.router.VirtualRouter.RedundantState;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.vm.VirtualMachine.State;
+
+@Entity
+@Table(name="domain_router_view")
+public class DomainRouterJoinVO extends BaseViewVO implements ControlledViewEntity {
+
+ @Column(name="id", updatable=false, nullable = false)
+ private long id;
+
+ @Column(name="name", updatable=false, nullable=false, length=255)
+ private String name = null;
+
+
+ @Column(name="account_id")
+ private long accountId;
+
+ @Column(name="account_uuid")
+ private String accountUuid;
+
+ @Column(name="account_name")
+ private String accountName = null;
+
+ @Column(name="account_type")
+ private short accountType;
+
+ @Column(name="domain_id")
+ private long domainId;
+
+ @Column(name="domain_uuid")
+ private String domainUuid;
+
+ @Column(name="domain_name")
+ private String domainName = null;
+
+ @Column(name="domain_path")
+ private String domainPath = null;
+
+ /**
+ * Note that state is intentionally missing the setter. Any updates to
+ * the state machine needs to go through the DAO object because someone
+ * else could be updating it as well.
+ */
+ @Enumerated(value=EnumType.STRING)
+ @Column(name="state", updatable=true, nullable=false, length=32)
+ private State state = null;
+
+ @Column(name=GenericDao.CREATED_COLUMN)
+ private Date created;
+
+ @Column(name=GenericDao.REMOVED_COLUMN)
+ private Date removed;
+
+ @Column(name="instance_name", updatable=true, nullable=false)
+ private String instanceName;
+
+ @Column(name="pod_id", updatable=true, nullable=false)
+ private Long podId;
+
+ @Column(name="pod_uuid")
+ private String podUuid;
+
+ @Column(name="data_center_id")
+ private long dataCenterId;
+
+ @Column(name="data_center_uuid")
+ private String dataCenterUuid;
+
+ @Column(name="data_center_name")
+ private String dataCenterName = null;
+
+ @Column(name="dns1")
+ private String dns1 = null;
+
+ @Column(name="dns2")
+ private String dns2 = null;
+
+
+ @Column(name="host_id", updatable=true, nullable=true)
+ private long hostId;
+
+ @Column(name="host_uuid")
+ private String hostUuid;
+
+ @Column(name="host_name", nullable=false)
+ private String hostName;
+
+ @Column(name="template_id", updatable=true, nullable=true, length=17)
+ private long templateId;
+
+ @Column(name="template_uuid")
+ private String templateUuid;
+
+ @Column(name="service_offering_id")
+ private long serviceOfferingId;
+
+ @Column(name="service_offering_uuid")
+ private String serviceOfferingUuid;
+
+ @Column(name="service_offering_name")
+ private String serviceOfferingName;
+
+
+ @Column(name = "vpc_id")
+ private long vpcId;
+
+ @Column(name = "vpc_uuid")
+ private String vpcUuid;
+
+ @Column(name = "nic_id")
+ private long nicId;
+
+ @Column(name = "nic_uuid")
+ private String nicUuid;
+
+ @Column(name = "is_default_nic")
+ private boolean isDefaultNic;
+
+ @Column(name = "ip_address")
+ private String ipAddress;
+
+ @Column(name = "gateway")
+ private String gateway;
+
+ @Column(name = "netmask")
+ private String netmask;
+
+ @Column(name = "mac_address")
+ private String macAddress;
+
+ @Column(name = "broadcast_uri")
+ private URI broadcastUri;
+
+ @Column(name = "isolation_uri")
+ private URI isolationUri;
+
+ @Column(name="network_id")
+ private long networkId;
+
+ @Column(name="network_uuid")
+ private String networkUuid;
+
+ @Column(name="network_name")
+ private String networkName;
+
+ @Column(name="network_domain")
+ private String networkDomain;
+
+ @Column(name="traffic_type")
+ @Enumerated(value=EnumType.STRING)
+ private TrafficType trafficType;
+
+
+ @Column(name="project_id")
+ private long projectId;
+
+ @Column(name="project_uuid")
+ private String projectUuid;
+
+ @Column(name="project_name")
+ private String projectName;
+
+ @Column(name="job_id")
+ private long jobId;
+
+ @Column(name="job_uuid")
+ private String jobUuid;
+
+ @Column(name="job_status")
+ private int jobStatus;
+
+
+ @Column(name="uuid")
+ private String uuid;
+
+ @Column(name="template_version")
+ private String templateVersion;
+
+ @Column(name="scripts_version")
+ private String scriptsVersion;
+
+ @Column(name="redundant_state")
+ @Enumerated(EnumType.STRING)
+ private RedundantState redundantState;
+
+ @Column(name="is_redundant_router")
+ boolean isRedundantRouter;
+
+ @Column(name="guest_type")
+ @Enumerated(value=EnumType.STRING)
+ private GuestType guestType;
+
+
+ public DomainRouterJoinVO() {
+ }
+
+
+
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+
+ @Override
+ public void setId(long id) {
+ this.id = id;
+
+ }
+
+
+
+
+ public String getUuid() {
+ return uuid;
+ }
+
+
+
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+
+
+ public String getName() {
+ return name;
+ }
+
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+
+
+ @Override
+ public long getAccountId() {
+ return accountId;
+ }
+
+
+ public void setAccountId(long accountId) {
+ this.accountId = accountId;
+ }
+
+
+ @Override
+ public String getAccountUuid() {
+ return accountUuid;
+ }
+
+
+
+
+ public void setAccountUuid(String accountUuid) {
+ this.accountUuid = accountUuid;
+ }
+
+
+
+
+ @Override
+ public String getAccountName() {
+ return accountName;
+ }
+
+
+ public void setAccountName(String accountName) {
+ this.accountName = accountName;
+ }
+
+
+ @Override
+ public short getAccountType() {
+ return accountType;
+ }
+
+
+ public void setAccountType(short accountType) {
+ this.accountType = accountType;
+ }
+
+
+ @Override
+ public long getDomainId() {
+ return domainId;
+ }
+
+
+ public void setDomainId(long domainId) {
+ this.domainId = domainId;
+ }
+
+ @Override
+ public String getDomainUuid() {
+ return domainUuid;
+ }
+
+
+
+
+ public void setDomainUuid(String domainUuid) {
+ this.domainUuid = domainUuid;
+ }
+
+
+
+
+ @Override
+ public String getDomainName() {
+ return domainName;
+ }
+
+
+ public void setDomainName(String domainName) {
+ this.domainName = domainName;
+ }
+
+ @Override
+ public String getDomainPath() {
+ return domainPath;
+ }
+
+
+ public void setDomainPath(String domainPath) {
+ this.domainPath = domainPath;
+ }
+
+
+ public State getState() {
+ return state;
+ }
+
+
+ public void setState(State state) {
+ this.state = state;
+ }
+
+
+ public Date getCreated() {
+ return created;
+ }
+
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+
+ public Date getRemoved() {
+ return removed;
+ }
+
+
+ public void setRemoved(Date removed) {
+ this.removed = removed;
+ }
+
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+
+
+ public void setInstanceName(String instanceName) {
+ this.instanceName = instanceName;
+ }
+
+
+ public String getPodUuid() {
+ return podUuid;
+ }
+
+
+
+
+ public void setPodUuid(String podUuid) {
+ this.podUuid = podUuid;
+ }
+
+
+ public String getDataCenterUuid() {
+ return dataCenterUuid;
+ }
+
+ public void setDataCenterUuid(String zoneUuid) {
+ this.dataCenterUuid = zoneUuid;
+ }
+
+ public String getDataCenterName() {
+ return dataCenterName;
+ }
+
+
+ public void setDataCenterName(String zoneName) {
+ this.dataCenterName = zoneName;
+ }
+
+
+ public Long getHostId() {
+ return hostId;
+ }
+
+
+ public void setHostId(long hostId) {
+ this.hostId = hostId;
+ }
+
+
+ public String getHostUuid() {
+ return hostUuid;
+ }
+
+
+
+
+ public void setHostUuid(String hostUuid) {
+ this.hostUuid = hostUuid;
+ }
+
+
+
+
+ public String getHostName() {
+ return hostName;
+ }
+
+
+ public void setHostName(String hostName) {
+ this.hostName = hostName;
+ }
+
+
+ public long getTemplateId() {
+ return templateId;
+ }
+
+
+ public void setTemplateId(long templateId) {
+ this.templateId = templateId;
+ }
+
+
+
+ public String getTemplateUuid() {
+ return templateUuid;
+ }
+
+
+
+
+ public void setTemplateUuid(String templateUuid) {
+ this.templateUuid = templateUuid;
+ }
+
+
+
+
+
+ public String getServiceOfferingUuid() {
+ return serviceOfferingUuid;
+ }
+
+
+ public void setServiceOfferingUuid(String serviceOfferingUuid) {
+ this.serviceOfferingUuid = serviceOfferingUuid;
+ }
+
+
+
+
+ public String getServiceOfferingName() {
+ return serviceOfferingName;
+ }
+
+
+ public void setServiceOfferingName(String serviceOfferingName) {
+ this.serviceOfferingName = serviceOfferingName;
+ }
+
+ public long getVpcId() {
+ return vpcId;
+ }
+
+ public void setVpcId(long vpcId) {
+ this.vpcId = vpcId;
+ }
+
+
+
+
+ public long getNicId() {
+ return nicId;
+ }
+
+
+ public void setNicId(long nicId) {
+ this.nicId = nicId;
+ }
+
+
+ public boolean isDefaultNic() {
+ return isDefaultNic;
+ }
+
+
+ public void setDefaultNic(boolean isDefaultNic) {
+ this.isDefaultNic = isDefaultNic;
+ }
+
+
+ public String getIpAddress() {
+ return ipAddress;
+ }
+
+
+ public void setIpAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+
+
+ public String getGateway() {
+ return gateway;
+ }
+
+
+ public void setGateway(String gateway) {
+ this.gateway = gateway;
+ }
+
+
+ public String getNetmask() {
+ return netmask;
+ }
+
+
+ public void setNetmask(String netmask) {
+ this.netmask = netmask;
+ }
+
+
+ public String getMacAddress() {
+ return macAddress;
+ }
+
+
+ public void setMacAddress(String macAddress) {
+ this.macAddress = macAddress;
+ }
+
+
+ public URI getBroadcastUri() {
+ return broadcastUri;
+ }
+
+
+ public void setBroadcastUri(URI broadcastUri) {
+ this.broadcastUri = broadcastUri;
+ }
+
+
+ public URI getIsolationUri() {
+ return isolationUri;
+ }
+
+
+ public void setIsolationUri(URI isolationUri) {
+ this.isolationUri = isolationUri;
+ }
+
+
+ public long getNetworkId() {
+ return networkId;
+ }
+
+
+ public void setNetworkId(long networkId) {
+ this.networkId = networkId;
+ }
+
+
+ public String getNetworkName() {
+ return networkName;
+ }
+
+
+
+
+ public void setNetworkName(String networkName) {
+ this.networkName = networkName;
+ }
+
+
+
+
+ public String getNetworkDomain() {
+ return networkDomain;
+ }
+
+
+
+
+ public void setNetworkDomain(String networkDomain) {
+ this.networkDomain = networkDomain;
+ }
+
+
+
+
+ public TrafficType getTrafficType() {
+ return trafficType;
+ }
+
+
+ public void setTrafficType(TrafficType trafficType) {
+ this.trafficType = trafficType;
+ }
+
+
+
+ public long getServiceOfferingId() {
+ return serviceOfferingId;
+ }
+
+
+
+
+ public void setServiceOfferingId(long serviceOfferingId) {
+ this.serviceOfferingId = serviceOfferingId;
+ }
+
+
+
+
+ public long getProjectId() {
+ return projectId;
+ }
+
+
+
+
+ public void setProjectId(long projectId) {
+ this.projectId = projectId;
+ }
+
+
+
+
+ @Override
+ public String getProjectUuid() {
+ return projectUuid;
+ }
+
+
+
+
+ public void setProjectUuid(String projectUuid) {
+ this.projectUuid = projectUuid;
+ }
+
+
+
+
+ @Override
+ public String getProjectName() {
+ return projectName;
+ }
+
+
+
+
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+
+
+
+
+
+ public String getVpcUuid() {
+ return vpcUuid;
+ }
+
+
+
+
+ public void setVpcUuid(String vpcUuid) {
+ this.vpcUuid = vpcUuid;
+ }
+
+
+
+
+ public String getNicUuid() {
+ return nicUuid;
+ }
+
+
+
+
+ public void setNicUuid(String nicUuid) {
+ this.nicUuid = nicUuid;
+ }
+
+
+
+
+ public String getNetworkUuid() {
+ return networkUuid;
+ }
+
+
+
+
+ public void setNetworkUuid(String networkUuid) {
+ this.networkUuid = networkUuid;
+ }
+
+
+ public long getJobId() {
+ return jobId;
+ }
+
+
+
+
+ public void setJobId(long jobId) {
+ this.jobId = jobId;
+ }
+
+
+
+
+ public String getJobUuid() {
+ return jobUuid;
+ }
+
+
+
+
+ public void setJobUuid(String jobUuid) {
+ this.jobUuid = jobUuid;
+ }
+
+
+
+
+ public int getJobStatus() {
+ return jobStatus;
+ }
+
+
+
+
+ public void setJobStatus(int jobStatus) {
+ this.jobStatus = jobStatus;
+ }
+
+
+
+ public Long getPodId() {
+ return podId;
+ }
+
+
+
+
+ public void setPodId(Long podId) {
+ this.podId = podId;
+ }
+
+
+
+
+ public long getDataCenterId() {
+ return dataCenterId;
+ }
+
+
+
+
+ public void setDataCenterId(long zoneId) {
+ this.dataCenterId = zoneId;
+ }
+
+
+
+
+ public String getDns1() {
+ return dns1;
+ }
+
+
+
+
+ public void setDns1(String dns1) {
+ this.dns1 = dns1;
+ }
+
+
+
+
+ public String getDns2() {
+ return dns2;
+ }
+
+
+
+
+ public void setDns2(String dns2) {
+ this.dns2 = dns2;
+ }
+
+
+
+
+ public String getTemplateVersion() {
+ return templateVersion;
+ }
+
+
+
+
+ public void setTemplateVersion(String templateVersion) {
+ this.templateVersion = templateVersion;
+ }
+
+
+
+
+ public String getScriptsVersion() {
+ return scriptsVersion;
+ }
+
+
+
+
+ public void setScriptsVersion(String scriptsVersion) {
+ this.scriptsVersion = scriptsVersion;
+ }
+
+
+
+
+ public RedundantState getRedundantState() {
+ return redundantState;
+ }
+
+
+
+
+ public void setRedundantState(RedundantState redundantState) {
+ this.redundantState = redundantState;
+ }
+
+
+
+
+ public boolean isRedundantRouter() {
+ return isRedundantRouter;
+ }
+
+
+
+
+ public void setRedundantRouter(boolean isRedundantRouter) {
+ this.isRedundantRouter = isRedundantRouter;
+ }
+
+
+
+
+ public GuestType getGuestType() {
+ return guestType;
+ }
+
+
+
+
+ public void setGuestType(GuestType guestType) {
+ this.guestType = guestType;
+ }
+
+
+}