Search in sources :

Example 1 with GPClientMessage

use of org.geosdi.geoplatform.gui.impl.message.GPClientMessage in project geo-platform by geosdi.

the class DTOSecurityConverter method convertAccountToDTO.

public IGPAccountDetail convertAccountToDTO(GPAccount account, GPAccountProject accountProject, GPViewport viewport, List<GPMessage> messages) {
    GPLoginUserDetail accountDetail = new GPLoginUserDetail();
    UserTreeOptions usertreeOptions = new UserTreeOptions();
    accountDetail.setId(account.getId());
    // Forced representation
    accountDetail.setUsername(account.getNaturalID());
    accountDetail.setOrganization(account.getOrganization().getName());
    usertreeOptions.setLoadExpandedFolders(account.isLoadExpandedFolders());
    accountDetail.setTreeOptions(usertreeOptions);
    if (account instanceof GPUser) {
        GPUser user = (GPUser) account;
        accountDetail.setName(user.getName());
        accountDetail.setEmail(user.getEmailAddress());
        this.extractGPAuthoritiesInToUser(accountDetail, account.getGPAuthorities());
    }
    if (account.getGsAccount() != null) {
        accountDetail.setAuthkey(account.getGsAccount().getAuthkey());
    }
    accountDetail.setHostXmppServer(hostXmppServer);
    if (accountProject != null) {
        accountDetail.setBaseLayer(accountProject.getBaseLayer());
    }
    if (viewport != null) {
        GPBBox serverBBOX = viewport.getBbox();
        BBoxClientInfo clientBBOX = new BBoxClientInfo(serverBBOX.getMinX(), serverBBOX.getMinY(), serverBBOX.getMaxX(), serverBBOX.getMaxY());
        GPClientViewport clientViewport = new GPClientViewport(viewport.getName(), viewport.getDescription(), clientBBOX, viewport.getZoomLevel(), viewport.isIsDefault());
        accountDetail.setViewport(clientViewport);
    }
    if (messages != null) {
        List<IGPClientMessage> unreadMessages = Lists.newArrayListWithCapacity(messages.size());
        for (GPMessage message : messages) {
            GPClientMessage clientMessage = this.convertMessage(message);
            unreadMessages.add(clientMessage);
            logger.debug("\n*** {}", clientMessage);
        }
        Collections.sort(unreadMessages);
        accountDetail.setUnreadMessages(unreadMessages);
    }
    return (IGPAccountDetail) accountDetail;
}
Also used : BBoxClientInfo(org.geosdi.geoplatform.gui.configuration.map.client.geometry.BBoxClientInfo) IGPAccountDetail(org.geosdi.geoplatform.gui.global.security.IGPAccountDetail) IGPClientMessage(org.geosdi.geoplatform.gui.model.message.IGPClientMessage) GPMessage(org.geosdi.geoplatform.core.model.GPMessage) GPUser(org.geosdi.geoplatform.core.model.GPUser) GPClientMessage(org.geosdi.geoplatform.gui.impl.message.GPClientMessage) IGPClientMessage(org.geosdi.geoplatform.gui.model.message.IGPClientMessage) GPClientViewport(org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport) UserTreeOptions(org.geosdi.geoplatform.gui.impl.users.options.UserTreeOptions) GPLoginUserDetail(org.geosdi.geoplatform.gui.client.model.security.GPLoginUserDetail) GPBBox(org.geosdi.geoplatform.core.model.GPBBox)

Example 2 with GPClientMessage

use of org.geosdi.geoplatform.gui.impl.message.GPClientMessage in project geo-platform by geosdi.

the class DTOSecurityConverter method convertMessage.

public GPClientMessage convertMessage(GPMessage message) {
    GPClientMessage clientMessage = new GPClientMessage();
    clientMessage.setId(message.getId());
    clientMessage.setSender(message.getSender().getNaturalID());
    clientMessage.setRecipient(message.getRecipient().getNaturalID());
    clientMessage.setCreationDate(message.getCreationDate());
    clientMessage.setSubject(message.getSubject());
    clientMessage.setText(message.getText());
    clientMessage.setRead(message.isRead());
    clientMessage.setCommand(message.getCommands().get(0));
    clientMessage.setCommandProperties(message.getCommandsProperties());
    return clientMessage;
}
Also used : GPClientMessage(org.geosdi.geoplatform.gui.impl.message.GPClientMessage) IGPClientMessage(org.geosdi.geoplatform.gui.model.message.IGPClientMessage)

Aggregations

GPClientMessage (org.geosdi.geoplatform.gui.impl.message.GPClientMessage)2 IGPClientMessage (org.geosdi.geoplatform.gui.model.message.IGPClientMessage)2 GPBBox (org.geosdi.geoplatform.core.model.GPBBox)1 GPMessage (org.geosdi.geoplatform.core.model.GPMessage)1 GPUser (org.geosdi.geoplatform.core.model.GPUser)1 GPLoginUserDetail (org.geosdi.geoplatform.gui.client.model.security.GPLoginUserDetail)1 GPClientViewport (org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport)1 BBoxClientInfo (org.geosdi.geoplatform.gui.configuration.map.client.geometry.BBoxClientInfo)1 IGPAccountDetail (org.geosdi.geoplatform.gui.global.security.IGPAccountDetail)1 UserTreeOptions (org.geosdi.geoplatform.gui.impl.users.options.UserTreeOptions)1