You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/13 18:29:28 UTC

[1/3] git commit: Move all the DB view DAOs from cloud-server to cloud-api for future api-server package.

Updated Branches:
  refs/heads/api_refactoring 7dbdf786c -> 7597a38f7


Move all the DB view DAOs from cloud-server to cloud-api for future api-server package.

BUG-ID: CLOUDSTACK-527

Signed-off-by: Rohit Yadav <bh...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/7597a38f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/7597a38f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/7597a38f

Branch: refs/heads/api_refactoring
Commit: 7597a38f7a255e49b73c833918f30b51504e0c53
Parents: 7dbdf78
Author: Min Chen <mi...@citrix.com>
Authored: Wed Dec 12 18:05:04 2012 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Thu Dec 13 09:28:42 2012 -0800

----------------------------------------------------------------------
 .../apache/cloudstack/api/view/DBViewUtils.java    |  225 ++++++++++
 .../cloudstack/api/view/ViewResponseHelper.java    |   43 ++
 .../api/view/dao/DomainRouterJoinDao.java          |   36 ++
 .../api/view/dao/DomainRouterJoinDaoImpl.java      |  203 +++++++++
 .../cloudstack/api/view/dao/EventJoinDao.java      |   39 ++
 .../cloudstack/api/view/dao/EventJoinDaoImpl.java  |  123 ++++++
 .../api/view/dao/InstanceGroupJoinDao.java         |   35 ++
 .../api/view/dao/InstanceGroupJoinDaoImpl.java     |   96 +++++
 .../api/view/dao/ProjectAccountJoinDao.java        |   33 ++
 .../api/view/dao/ProjectAccountJoinDaoImpl.java    |   85 ++++
 .../api/view/dao/ProjectInvitationJoinDao.java     |   29 ++
 .../api/view/dao/ProjectInvitationJoinDaoImpl.java |   85 ++++
 .../cloudstack/api/view/dao/ProjectJoinDao.java    |   36 ++
 .../api/view/dao/ProjectJoinDaoImpl.java           |  109 +++++
 .../api/view/dao/ResourceTagJoinDao.java           |   33 ++
 .../api/view/dao/ResourceTagJoinDaoImpl.java       |  103 +++++
 .../api/view/dao/SecurityGroupJoinDao.java         |   36 ++
 .../api/view/dao/SecurityGroupJoinDaoImpl.java     |  176 ++++++++
 .../api/view/dao/UserAccountJoinDao.java           |   40 ++
 .../api/view/dao/UserAccountJoinDaoImpl.java       |  133 ++++++
 .../cloudstack/api/view/dao/UserVmJoinDao.java     |   38 ++
 .../cloudstack/api/view/dao/UserVmJoinDaoImpl.java |  331 +++++++++++++++
 server/src/com/cloud/api/ApiDBUtils.java           |  141 +------
 server/src/com/cloud/api/ApiResponseHelper.java    |   71 ++--
 .../configuration/DefaultComponentLibrary.java     |   21 +-
 server/src/com/cloud/event/dao/EventJoinDao.java   |   39 --
 .../src/com/cloud/event/dao/EventJoinDaoImpl.java  |  123 ------
 .../network/security/SecurityGroupManagerImpl.java |    2 +-
 .../network/security/dao/SecurityGroupJoinDao.java |   37 --
 .../security/dao/SecurityGroupJoinDaoImpl.java     |  177 --------
 .../src/com/cloud/projects/ProjectManagerImpl.java |    6 +-
 .../cloud/projects/dao/ProjectAccountJoinDao.java  |   33 --
 .../projects/dao/ProjectAccountJoinDaoImpl.java    |   85 ----
 .../projects/dao/ProjectInvitationJoinDao.java     |   29 --
 .../projects/dao/ProjectInvitationJoinDaoImpl.java |   86 ----
 .../src/com/cloud/projects/dao/ProjectJoinDao.java |   36 --
 .../com/cloud/projects/dao/ProjectJoinDaoImpl.java |  108 -----
 .../src/com/cloud/server/ManagementServerImpl.java |    6 +-
 .../com/cloud/tags/TaggedResourceManagerImpl.java  |    2 +-
 .../src/com/cloud/tags/dao/ResourceTagJoinDao.java |   33 --
 .../com/cloud/tags/dao/ResourceTagJoinDaoImpl.java |  103 -----
 server/src/com/cloud/user/AccountManagerImpl.java  |    3 +-
 .../src/com/cloud/user/dao/UserAccountJoinDao.java |   40 --
 .../com/cloud/user/dao/UserAccountJoinDaoImpl.java |  138 ------
 server/src/com/cloud/vm/UserVmManagerImpl.java     |    2 +-
 .../src/com/cloud/vm/dao/DomainRouterJoinDao.java  |   36 --
 .../com/cloud/vm/dao/DomainRouterJoinDaoImpl.java  |  202 ---------
 .../src/com/cloud/vm/dao/InstanceGroupJoinDao.java |   35 --
 .../com/cloud/vm/dao/InstanceGroupJoinDaoImpl.java |   96 -----
 server/src/com/cloud/vm/dao/UserVmJoinDao.java     |   38 --
 server/src/com/cloud/vm/dao/UserVmJoinDaoImpl.java |  327 --------------
 .../security/SecurityGroupManagerImpl2Test.java    |    2 +-
 52 files changed, 2136 insertions(+), 1988 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/api/src/org/apache/cloudstack/api/view/DBViewUtils.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/DBViewUtils.java b/api/src/org/apache/cloudstack/api/view/DBViewUtils.java
new file mode 100644
index 0000000..5ea7eb7
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/DBViewUtils.java
@@ -0,0 +1,225 @@
+// 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 org.apache.cloudstack.api.view;
+
+import java.util.EnumSet;
+import java.util.List;
+
+import org.apache.cloudstack.api.ApiConstants.VMDetails;
+import org.apache.cloudstack.api.response.DomainRouterResponse;
+import org.apache.cloudstack.api.response.EventResponse;
+import org.apache.cloudstack.api.response.InstanceGroupResponse;
+import org.apache.cloudstack.api.response.ProjectAccountResponse;
+import org.apache.cloudstack.api.response.ProjectInvitationResponse;
+import org.apache.cloudstack.api.response.ProjectResponse;
+import org.apache.cloudstack.api.response.ResourceTagResponse;
+import org.apache.cloudstack.api.response.SecurityGroupResponse;
+import org.apache.cloudstack.api.response.UserResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.api.view.dao.DomainRouterJoinDao;
+import org.apache.cloudstack.api.view.dao.EventJoinDao;
+import org.apache.cloudstack.api.view.dao.InstanceGroupJoinDao;
+import org.apache.cloudstack.api.view.dao.ProjectAccountJoinDao;
+import org.apache.cloudstack.api.view.dao.ProjectInvitationJoinDao;
+import org.apache.cloudstack.api.view.dao.ProjectJoinDao;
+import org.apache.cloudstack.api.view.dao.ResourceTagJoinDao;
+import org.apache.cloudstack.api.view.dao.SecurityGroupJoinDao;
+import org.apache.cloudstack.api.view.dao.UserAccountJoinDao;
+import org.apache.cloudstack.api.view.dao.UserVmJoinDao;
+import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
+import org.apache.cloudstack.api.view.vo.EventJoinVO;
+import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
+import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
+import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
+import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
+import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
+import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
+import org.apache.cloudstack.api.view.vo.UserAccountJoinVO;
+import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
+
+
+import com.cloud.configuration.ConfigurationService;
+import com.cloud.event.Event;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.security.SecurityGroup;
+import com.cloud.projects.Project;
+import com.cloud.projects.ProjectAccount;
+import com.cloud.projects.ProjectInvitation;
+import com.cloud.projects.ProjectService;
+import com.cloud.server.ResourceTag;
+import com.cloud.server.TaggedResourceService;
+import com.cloud.user.Account;
+import com.cloud.user.ResourceLimitService;
+import com.cloud.user.User;
+import com.cloud.user.UserAccount;
+
+import com.cloud.uservm.UserVm;
+import com.cloud.utils.component.ComponentLocator;
+import com.cloud.vm.InstanceGroup;
+
+
+/**
+ * @author minc
+ *
+ */
+public class DBViewUtils {
+
+    private static DomainRouterJoinDao _domainRouterJoinDao;
+    private static SecurityGroupJoinDao _securityGroupJoinDao;
+    private static UserVmJoinDao _userVmJoinDao;
+    private static ResourceTagJoinDao _tagJoinDao;
+    private static EventJoinDao _eventJoinDao;
+    private static InstanceGroupJoinDao _vmGroupJoinDao;
+    private static UserAccountJoinDao _userAccountJoinDao;
+    private static ProjectJoinDao _projectJoinDao;
+    private static ProjectAccountJoinDao _projectAccountJoinDao;
+    private static ProjectInvitationJoinDao _projectInvitationJoinDao;
+
+    static {
+        ComponentLocator locator = ComponentLocator.getLocator("management-server");
+        _domainRouterJoinDao = locator.getDao(DomainRouterJoinDao.class);
+        _userVmJoinDao = locator.getDao(UserVmJoinDao.class);
+        _securityGroupJoinDao = locator.getDao(SecurityGroupJoinDao.class);
+        _tagJoinDao = locator.getDao(ResourceTagJoinDao.class);
+        _vmGroupJoinDao = locator.getDao(InstanceGroupJoinDao.class);
+        _eventJoinDao = locator.getDao(EventJoinDao.class);
+        _userAccountJoinDao = locator.getDao(UserAccountJoinDao.class);
+        _projectJoinDao = locator.getDao(ProjectJoinDao.class);
+        _projectAccountJoinDao = locator.getDao(ProjectAccountJoinDao.class);
+        _projectInvitationJoinDao = locator.getDao(ProjectInvitationJoinDao.class);
+    }
+
+
+    public static DomainRouterResponse newDomainRouterResponse(DomainRouterJoinVO vr, Account caller) {
+        return _domainRouterJoinDao.newDomainRouterResponse(vr, caller);
+    }
+
+    public static DomainRouterResponse fillRouterDetails(DomainRouterResponse vrData, DomainRouterJoinVO vr){
+         return _domainRouterJoinDao.setDomainRouterResponse(vrData, vr);
+    }
+
+    public static List<DomainRouterJoinVO> newDomainRouterView(VirtualRouter vr){
+        return _domainRouterJoinDao.newDomainRouterView(vr);
+    }
+
+    public static UserVmResponse newUserVmResponse(String objectName, UserVmJoinVO userVm, EnumSet<VMDetails> details, Account caller) {
+        return _userVmJoinDao.newUserVmResponse(objectName, userVm, details, caller);
+    }
+
+    public static UserVmResponse fillVmDetails(UserVmResponse vmData, UserVmJoinVO vm){
+         return _userVmJoinDao.setUserVmResponse(vmData, vm);
+    }
+
+    public static List<UserVmJoinVO> newUserVmView(UserVm... userVms){
+        return _userVmJoinDao.newUserVmView(userVms);
+    }
+
+    public static SecurityGroupResponse newSecurityGroupResponse(SecurityGroupJoinVO vsg, Account caller) {
+        return _securityGroupJoinDao.newSecurityGroupResponse(vsg, caller);
+    }
+
+    public static SecurityGroupResponse fillSecurityGroupDetails(SecurityGroupResponse vsgData, SecurityGroupJoinVO sg){
+         return _securityGroupJoinDao.setSecurityGroupResponse(vsgData, sg);
+    }
+
+    public static List<SecurityGroupJoinVO> newSecurityGroupView(SecurityGroup sg){
+        return _securityGroupJoinDao.newSecurityGroupView(sg);
+    }
+
+    public static List<SecurityGroupJoinVO> findSecurityGroupViewById(Long sgId){
+        return _securityGroupJoinDao.searchByIds(sgId);
+    }
+
+    public static ResourceTagResponse newResourceTagResponse(ResourceTagJoinVO vsg, boolean keyValueOnly) {
+        return _tagJoinDao.newResourceTagResponse(vsg, keyValueOnly);
+    }
+
+    public static ResourceTagJoinVO newResourceTagView(ResourceTag sg){
+        return _tagJoinDao.newResourceTagView(sg);
+    }
+
+    public static ResourceTagJoinVO findResourceTagViewById(Long tagId){
+        List<ResourceTagJoinVO> tags = _tagJoinDao.searchByIds(tagId);
+        if ( tags != null && tags.size() > 0 ){
+            return tags.get(0);
+        }
+        else{
+            return null;
+        }
+    }
+
+    public static EventResponse newEventResponse(EventJoinVO ve) {
+        return _eventJoinDao.newEventResponse(ve);
+    }
+
+    public static EventJoinVO newEventView(Event e){
+        return _eventJoinDao.newEventView(e);
+    }
+
+    public static InstanceGroupResponse newInstanceGroupResponse(InstanceGroupJoinVO ve) {
+        return _vmGroupJoinDao.newInstanceGroupResponse(ve);
+    }
+
+    public static InstanceGroupJoinVO newInstanceGroupView(InstanceGroup e){
+        return _vmGroupJoinDao.newInstanceGroupView(e);
+    }
+
+    public static UserResponse newUserResponse(UserAccountJoinVO usr) {
+        return _userAccountJoinDao.newUserResponse(usr);
+    }
+
+    public static UserAccountJoinVO newUserView(User usr){
+        return _userAccountJoinDao.newUserView(usr);
+    }
+
+    public static UserAccountJoinVO newUserView(UserAccount usr){
+        return _userAccountJoinDao.newUserView(usr);
+    }
+
+    public static ProjectResponse newProjectResponse(ProjectJoinVO proj) {
+        return _projectJoinDao.newProjectResponse(proj);
+    }
+
+    public static ProjectResponse fillProjectDetails(ProjectResponse rsp, ProjectJoinVO proj){
+         return _projectJoinDao.setProjectResponse(rsp,proj);
+    }
+
+    public static List<ProjectJoinVO> newProjectView(Project proj){
+        return _projectJoinDao.newProjectView(proj);
+    }
+
+    public static List<UserAccountJoinVO> findUserViewByAccountId(Long accountId){
+        return _userAccountJoinDao.searchByAccountId(accountId);
+    }
+
+    public static ProjectAccountResponse newProjectAccountResponse(ProjectAccountJoinVO proj) {
+        return _projectAccountJoinDao.newProjectAccountResponse(proj);
+    }
+
+    public static ProjectAccountJoinVO newProjectAccountView(ProjectAccount proj) {
+        return _projectAccountJoinDao.newProjectAccountView(proj);
+    }
+
+    public static ProjectInvitationResponse newProjectInvitationResponse(ProjectInvitationJoinVO proj) {
+        return _projectInvitationJoinDao.newProjectInvitationResponse(proj);
+    }
+
+    public static ProjectInvitationJoinVO newProjectInvitationView(ProjectInvitation proj) {
+        return _projectInvitationJoinDao.newProjectInvitationView(proj);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/api/src/org/apache/cloudstack/api/view/ViewResponseHelper.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/ViewResponseHelper.java b/api/src/org/apache/cloudstack/api/view/ViewResponseHelper.java
new file mode 100644
index 0000000..39c0429
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/ViewResponseHelper.java
@@ -0,0 +1,43 @@
+// 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 org.apache.cloudstack.api.view;
+
+import org.apache.cloudstack.api.response.ControlledViewEntityResponse;
+import org.apache.cloudstack.api.view.vo.ControlledViewEntity;
+
+import com.cloud.user.Account;
+
+/**
+ * Some helper routine in generating response from db view.
+ * @author minc
+ *
+ */
+public class ViewResponseHelper {
+
+    public static void populateOwner(ControlledViewEntityResponse response, ControlledViewEntity object) {
+
+        if (object.getAccountType() == Account.ACCOUNT_TYPE_PROJECT) {
+            response.setProjectId(object.getProjectUuid());
+            response.setProjectName(object.getProjectName());
+        } else {
+            response.setAccountName(object.getAccountName());
+        }
+
+        response.setDomainId(object.getDomainUuid());
+        response.setDomainName(object.getDomainName());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/api/src/org/apache/cloudstack/api/view/dao/DomainRouterJoinDao.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/DomainRouterJoinDao.java b/api/src/org/apache/cloudstack/api/view/dao/DomainRouterJoinDao.java
new file mode 100644
index 0000000..54390c1
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/DomainRouterJoinDao.java
@@ -0,0 +1,36 @@
+// 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 org.apache.cloudstack.api.view.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.response.DomainRouterResponse;
+import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.user.Account;
+import com.cloud.utils.db.GenericDao;
+
+public interface DomainRouterJoinDao extends GenericDao<DomainRouterJoinVO, Long> {
+
+    DomainRouterResponse newDomainRouterResponse(DomainRouterJoinVO uvo, Account caller);
+
+    DomainRouterResponse setDomainRouterResponse(DomainRouterResponse userVmData, DomainRouterJoinVO uvo);
+
+    List<DomainRouterJoinVO> newDomainRouterView(VirtualRouter vr);
+
+    List<DomainRouterJoinVO> searchByIds(Long... ids);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/api/src/org/apache/cloudstack/api/view/dao/DomainRouterJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/DomainRouterJoinDaoImpl.java b/api/src/org/apache/cloudstack/api/view/dao/DomainRouterJoinDaoImpl.java
new file mode 100644
index 0000000..0f3a96c
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/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 org.apache.cloudstack.api.view.dao;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+
+import org.apache.cloudstack.api.response.DomainRouterResponse;
+import org.apache.cloudstack.api.response.NicResponse;
+import org.apache.cloudstack.api.view.ViewResponseHelper;
+import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
+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.
+        ViewResponseHelper.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/7597a38f/api/src/org/apache/cloudstack/api/view/dao/EventJoinDao.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/EventJoinDao.java b/api/src/org/apache/cloudstack/api/view/dao/EventJoinDao.java
new file mode 100644
index 0000000..abf2c21
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/EventJoinDao.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 org.apache.cloudstack.api.view.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.response.EventResponse;
+import org.apache.cloudstack.api.view.vo.EventJoinVO;
+import com.cloud.event.Event;
+import com.cloud.utils.db.Filter;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.db.SearchCriteria;
+
+public interface EventJoinDao extends GenericDao<EventJoinVO, Long> {
+
+    EventResponse newEventResponse(EventJoinVO uvo);
+
+    EventJoinVO newEventView(Event vr);
+
+    List<EventJoinVO> searchByIds(Long... ids);
+
+    List<EventJoinVO> searchAllEvents(SearchCriteria<EventJoinVO> sc, Filter filter);
+
+    EventJoinVO findCompletedEvent(long startId);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/api/src/org/apache/cloudstack/api/view/dao/EventJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/EventJoinDaoImpl.java b/api/src/org/apache/cloudstack/api/view/dao/EventJoinDaoImpl.java
new file mode 100644
index 0000000..ee99d12
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/EventJoinDaoImpl.java
@@ -0,0 +1,123 @@
+// 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 org.apache.cloudstack.api.view.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+
+import org.apache.cloudstack.api.response.EventResponse;
+import org.apache.cloudstack.api.view.ViewResponseHelper;
+import org.apache.cloudstack.api.view.vo.EventJoinVO;
+import com.cloud.event.Event;
+import com.cloud.event.Event.State;
+import com.cloud.utils.db.Filter;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+
+@Local(value={EventJoinDao.class})
+public class EventJoinDaoImpl extends GenericDaoBase<EventJoinVO, Long> implements EventJoinDao {
+    public static final Logger s_logger = Logger.getLogger(EventJoinDaoImpl.class);
+
+    private SearchBuilder<EventJoinVO> vrSearch;
+
+    private SearchBuilder<EventJoinVO> vrIdSearch;
+
+    private SearchBuilder<EventJoinVO> CompletedEventSearch;
+
+    protected EventJoinDaoImpl() {
+
+        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();
+
+        CompletedEventSearch = createSearchBuilder();
+        CompletedEventSearch.and("state",CompletedEventSearch.entity().getState(),SearchCriteria.Op.EQ);
+        CompletedEventSearch.and("startId", CompletedEventSearch.entity().getStartId(), SearchCriteria.Op.EQ);
+        CompletedEventSearch.done();
+
+
+        this._count = "select count(distinct id) from event_view WHERE ";
+    }
+
+
+
+    @Override
+    public List<EventJoinVO> searchAllEvents(SearchCriteria<EventJoinVO> sc, Filter filter) {
+        return listIncludingRemovedBy(sc, filter);
+    }
+
+
+
+    @Override
+    public EventJoinVO findCompletedEvent(long startId) {
+        SearchCriteria<EventJoinVO> sc = CompletedEventSearch.create();
+        sc.setParameters("state", State.Completed);
+        sc.setParameters("startId", startId);
+        return findOneIncludingRemovedBy(sc);
+    }
+
+
+
+    @Override
+    public EventResponse newEventResponse(EventJoinVO event) {
+        EventResponse responseEvent = new EventResponse();
+        responseEvent.setCreated(event.getCreateDate());
+        responseEvent.setDescription(event.getDescription());
+        responseEvent.setEventType(event.getType());
+        responseEvent.setId(event.getUuid());
+        responseEvent.setLevel(event.getLevel());
+        responseEvent.setParentId(event.getStartUuid());
+        responseEvent.setState(event.getState());
+        responseEvent.setUsername(event.getUserName());
+
+        ViewResponseHelper.populateOwner(responseEvent, event);
+        responseEvent.setObjectName("event");
+        return responseEvent;
+    }
+
+
+
+    @Override
+    public List<EventJoinVO> searchByIds(Long... ids) {
+        SearchCriteria<EventJoinVO> sc = vrSearch.create();
+        sc.setParameters("idIN", ids);
+        return searchIncludingRemoved(sc, null, null, false);
+    }
+
+
+    @Override
+    public EventJoinVO newEventView(Event vr) {
+
+        SearchCriteria<EventJoinVO> sc = vrIdSearch.create();
+        sc.setParameters("id", vr.getId());
+        List<EventJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+        assert vms != null && vms.size() == 1 : "No event found for event id " + vr.getId();
+        return vms.get(0);
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/api/src/org/apache/cloudstack/api/view/dao/InstanceGroupJoinDao.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/InstanceGroupJoinDao.java b/api/src/org/apache/cloudstack/api/view/dao/InstanceGroupJoinDao.java
new file mode 100644
index 0000000..1d067fc
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/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 org.apache.cloudstack.api.view.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.response.InstanceGroupResponse;
+import org.apache.cloudstack.api.view.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/7597a38f/api/src/org/apache/cloudstack/api/view/dao/InstanceGroupJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/InstanceGroupJoinDaoImpl.java b/api/src/org/apache/cloudstack/api/view/dao/InstanceGroupJoinDaoImpl.java
new file mode 100644
index 0000000..cdc6591
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/InstanceGroupJoinDaoImpl.java
@@ -0,0 +1,96 @@
+// 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 org.apache.cloudstack.api.view.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.response.InstanceGroupResponse;
+import org.apache.cloudstack.api.view.ViewResponseHelper;
+import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
+
+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());
+
+        ViewResponseHelper.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/7597a38f/api/src/org/apache/cloudstack/api/view/dao/ProjectAccountJoinDao.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/ProjectAccountJoinDao.java b/api/src/org/apache/cloudstack/api/view/dao/ProjectAccountJoinDao.java
new file mode 100644
index 0000000..3320d9e
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/ProjectAccountJoinDao.java
@@ -0,0 +1,33 @@
+// 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 org.apache.cloudstack.api.view.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.response.ProjectAccountResponse;
+import org.apache.cloudstack.api.view.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/7597a38f/api/src/org/apache/cloudstack/api/view/dao/ProjectAccountJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/ProjectAccountJoinDaoImpl.java b/api/src/org/apache/cloudstack/api/view/dao/ProjectAccountJoinDaoImpl.java
new file mode 100644
index 0000000..59e789b
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/ProjectAccountJoinDaoImpl.java
@@ -0,0 +1,85 @@
+// 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 org.apache.cloudstack.api.view.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.response.ProjectAccountResponse;
+import org.apache.cloudstack.api.view.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/7597a38f/api/src/org/apache/cloudstack/api/view/dao/ProjectInvitationJoinDao.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/ProjectInvitationJoinDao.java b/api/src/org/apache/cloudstack/api/view/dao/ProjectInvitationJoinDao.java
new file mode 100644
index 0000000..ba22c04
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/ProjectInvitationJoinDao.java
@@ -0,0 +1,29 @@
+// 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 org.apache.cloudstack.api.view.dao;
+
+import org.apache.cloudstack.api.response.ProjectInvitationResponse;
+import org.apache.cloudstack.api.view.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/7597a38f/api/src/org/apache/cloudstack/api/view/dao/ProjectInvitationJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/ProjectInvitationJoinDaoImpl.java b/api/src/org/apache/cloudstack/api/view/dao/ProjectInvitationJoinDaoImpl.java
new file mode 100644
index 0000000..5c8231c
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/ProjectInvitationJoinDaoImpl.java
@@ -0,0 +1,85 @@
+// 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 org.apache.cloudstack.api.view.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.response.ProjectInvitationResponse;
+import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
+
+
+import com.cloud.projects.ProjectInvitation;
+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/7597a38f/api/src/org/apache/cloudstack/api/view/dao/ProjectJoinDao.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/ProjectJoinDao.java b/api/src/org/apache/cloudstack/api/view/dao/ProjectJoinDao.java
new file mode 100644
index 0000000..173f57e
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/ProjectJoinDao.java
@@ -0,0 +1,36 @@
+// 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 org.apache.cloudstack.api.view.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.response.ProjectResponse;
+import org.apache.cloudstack.api.view.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/7597a38f/api/src/org/apache/cloudstack/api/view/dao/ProjectJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/ProjectJoinDaoImpl.java b/api/src/org/apache/cloudstack/api/view/dao/ProjectJoinDaoImpl.java
new file mode 100644
index 0000000..8b8d145
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/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 org.apache.cloudstack.api.view.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+
+import org.apache.cloudstack.api.response.ProjectResponse;
+import org.apache.cloudstack.api.view.DBViewUtils;
+import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
+import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
+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 = DBViewUtils.findResourceTagViewById(tag_id);
+            if ( vtag != null ){
+                response.addTag(DBViewUtils.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 = DBViewUtils.findResourceTagViewById(tag_id);
+            if ( vtag != null ){
+                rsp.addTag(DBViewUtils.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/7597a38f/api/src/org/apache/cloudstack/api/view/dao/ResourceTagJoinDao.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/ResourceTagJoinDao.java b/api/src/org/apache/cloudstack/api/view/dao/ResourceTagJoinDao.java
new file mode 100644
index 0000000..38f3e0d
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/ResourceTagJoinDao.java
@@ -0,0 +1,33 @@
+// 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 org.apache.cloudstack.api.view.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.response.ResourceTagResponse;
+import org.apache.cloudstack.api.view.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/7597a38f/api/src/org/apache/cloudstack/api/view/dao/ResourceTagJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/ResourceTagJoinDaoImpl.java b/api/src/org/apache/cloudstack/api/view/dao/ResourceTagJoinDaoImpl.java
new file mode 100644
index 0000000..519ef3d
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/ResourceTagJoinDaoImpl.java
@@ -0,0 +1,103 @@
+// 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 org.apache.cloudstack.api.view.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+
+import org.apache.cloudstack.api.response.ResourceTagResponse;
+import org.apache.cloudstack.api.view.ViewResponseHelper;
+import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
+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());
+
+            ViewResponseHelper.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/7597a38f/api/src/org/apache/cloudstack/api/view/dao/SecurityGroupJoinDao.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/SecurityGroupJoinDao.java b/api/src/org/apache/cloudstack/api/view/dao/SecurityGroupJoinDao.java
new file mode 100644
index 0000000..c9eabec
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/SecurityGroupJoinDao.java
@@ -0,0 +1,36 @@
+// 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 org.apache.cloudstack.api.view.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.response.SecurityGroupResponse;
+import org.apache.cloudstack.api.view.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/7597a38f/api/src/org/apache/cloudstack/api/view/dao/SecurityGroupJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/SecurityGroupJoinDaoImpl.java b/api/src/org/apache/cloudstack/api/view/dao/SecurityGroupJoinDaoImpl.java
new file mode 100644
index 0000000..95256c5
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/SecurityGroupJoinDaoImpl.java
@@ -0,0 +1,176 @@
+// 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 org.apache.cloudstack.api.view.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.response.SecurityGroupResponse;
+import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
+import org.apache.cloudstack.api.view.DBViewUtils;
+import org.apache.cloudstack.api.view.ViewResponseHelper;
+import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
+import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
+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());
+
+        ViewResponseHelper.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 = DBViewUtils.findResourceTagViewById(tag_id);
+            if ( vtag != null ){
+                sgResponse.addTag(DBViewUtils.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 = DBViewUtils.findResourceTagViewById(tag_id);
+            if ( vtag != null ){
+                vsgData.addTag(DBViewUtils.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/7597a38f/api/src/org/apache/cloudstack/api/view/dao/UserAccountJoinDao.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/UserAccountJoinDao.java b/api/src/org/apache/cloudstack/api/view/dao/UserAccountJoinDao.java
new file mode 100644
index 0000000..d13d932
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/UserAccountJoinDao.java
@@ -0,0 +1,40 @@
+// 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 org.apache.cloudstack.api.view.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.response.UserResponse;
+import org.apache.cloudstack.api.view.vo.UserAccountJoinVO;
+
+import com.cloud.user.User;
+import com.cloud.user.UserAccount;
+import com.cloud.utils.db.GenericDao;
+
+public interface UserAccountJoinDao extends GenericDao<UserAccountJoinVO, Long> {
+
+    UserResponse newUserResponse(UserAccountJoinVO usr);
+
+    UserAccountJoinVO newUserView(User usr);
+
+    UserAccountJoinVO newUserView(UserAccount usr);
+
+    List<UserAccountJoinVO> searchByIds(Long... ids);
+
+    List<UserAccountJoinVO> searchByAccountId(Long accountId);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/api/src/org/apache/cloudstack/api/view/dao/UserAccountJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/UserAccountJoinDaoImpl.java b/api/src/org/apache/cloudstack/api/view/dao/UserAccountJoinDaoImpl.java
new file mode 100644
index 0000000..556da8c
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/UserAccountJoinDaoImpl.java
@@ -0,0 +1,133 @@
+// 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 org.apache.cloudstack.api.view.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+
+import org.apache.cloudstack.api.response.UserResponse;
+import org.apache.cloudstack.api.view.vo.UserAccountJoinVO;
+
+import com.cloud.user.User;
+import com.cloud.user.UserAccount;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+
+@Local(value={UserAccountJoinDao.class})
+public class UserAccountJoinDaoImpl extends GenericDaoBase<UserAccountJoinVO, Long> implements UserAccountJoinDao {
+    public static final Logger s_logger = Logger.getLogger(UserAccountJoinDaoImpl.class);
+
+    private SearchBuilder<UserAccountJoinVO> vrSearch;
+
+    private SearchBuilder<UserAccountJoinVO> vrIdSearch;
+
+    private SearchBuilder<UserAccountJoinVO> vrAcctIdSearch;
+
+
+    protected UserAccountJoinDaoImpl() {
+
+        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();
+
+        vrAcctIdSearch = createSearchBuilder();
+        vrAcctIdSearch.and("accountid", vrAcctIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
+        vrAcctIdSearch.done();
+
+
+        this._count = "select count(distinct id) from user_view WHERE ";
+    }
+
+
+
+    @Override
+    public UserResponse newUserResponse(UserAccountJoinVO usr) {
+        UserResponse userResponse = new UserResponse();
+        userResponse.setAccountId(usr.getAccountUuid());
+        userResponse.setAccountName(usr.getAccountName());
+        userResponse.setAccountType(usr.getAccountType());
+        userResponse.setCreated(usr.getCreated());
+        userResponse.setDomainId(usr.getDomainUuid());
+        userResponse.setDomainName(usr.getDomainName());
+        userResponse.setEmail(usr.getEmail());
+        userResponse.setFirstname(usr.getFirstname());
+        userResponse.setId(usr.getUuid());
+        userResponse.setLastname(usr.getLastname());
+        userResponse.setState(usr.getState().toString());
+        userResponse.setTimezone(usr.getTimezone());
+        userResponse.setUsername(usr.getUsername());
+        userResponse.setApiKey(usr.getApiKey());
+        userResponse.setSecretKey(usr.getSecretKey());
+        userResponse.setObjectName("user");
+
+        return userResponse;
+    }
+
+
+    @Override
+    public UserAccountJoinVO newUserView(User usr) {
+        SearchCriteria<UserAccountJoinVO> sc = vrIdSearch.create();
+        sc.setParameters("id", usr.getId());
+        List<UserAccountJoinVO> users = searchIncludingRemoved(sc, null, null, false);
+        assert users != null && users.size() == 1 : "No user found for user id " + usr.getId();
+        return users.get(0);
+    }
+
+
+
+
+    @Override
+    public UserAccountJoinVO newUserView(UserAccount usr) {
+        SearchCriteria<UserAccountJoinVO> sc = vrIdSearch.create();
+        sc.setParameters("id", usr.getId());
+        List<UserAccountJoinVO> users = searchIncludingRemoved(sc, null, null, false);
+        assert users != null && users.size() == 1 : "No user found for user id " + usr.getId();
+        return users.get(0);
+    }
+
+
+
+    @Override
+    public List<UserAccountJoinVO> searchByIds(Long... ids) {
+        SearchCriteria<UserAccountJoinVO> sc = vrSearch.create();
+        sc.setParameters("idIN", ids);
+        return searchIncludingRemoved(sc, null, null, false);
+    }
+
+
+
+    @Override
+    public List<UserAccountJoinVO> searchByAccountId(Long accountId) {
+        SearchCriteria<UserAccountJoinVO> sc = vrAcctIdSearch.create();
+        sc.setParameters("accountId", accountId);
+        return searchIncludingRemoved(sc, null, null, false);
+    }
+
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/api/src/org/apache/cloudstack/api/view/dao/UserVmJoinDao.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/UserVmJoinDao.java b/api/src/org/apache/cloudstack/api/view/dao/UserVmJoinDao.java
new file mode 100644
index 0000000..9f8618c
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/UserVmJoinDao.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 org.apache.cloudstack.api.view.dao;
+
+import java.util.EnumSet;
+import java.util.List;
+
+import org.apache.cloudstack.api.ApiConstants.VMDetails;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.api.view.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);
+}