Package com.appspot.plucial.model

Examples of com.appspot.plucial.model.ActivityModel


        // タスクは成功するまで実行されるため、失敗時は例外をキャッチして再実行をさせない
        try{
            // アクティビティの取得
            String activityId = asString("activityId");

            ActivityModel activityModel = ActivityService.getActivity(activityId);
            if(activityModel == null) return null;

            // 短縮URLの取得
            String shortUrl = getShortUrl(userModel, activityModel);

            // Twitter メッセージの作成
            String msg = getMessage(activityModel, shortUrl);

            // POST
            if(activityModel.getAttachmentsType() != null
                    && (activityModel.getAttachmentsType().getCategory().equals(Constants.GOOGLE_ACTIVITY_ATTACHMENTS_TYPE_PHOTO)
                          || activityModel.getAttachmentsType().getCategory().equals(Constants.GOOGLE_ACTIVITY_ATTACHMENTS_TYPE_ALBUM))
                    && activityModel.getVerb().getCategory().equals(Constants.GOOGLE_ACTIVITY_VERB_TYPE_POST)) {

                // 自分が投稿した写真付きの場合もしくアルバム
                imageUpload(userModel, msg, activityModel.getAttachmentsImageUrlString());


            }else {
                postMessage(userModel, msg);
            }
View Full Code Here


    @Override
    protected Navigation execute(UserModel acsessUserModel, UserModel loginUserModel, boolean isLogin, boolean isSmartPhone) throws Exception {

        String activityId = asString("activityId");
        ActivityModel activityModel = ActivityService.getActivity(activityId);

        ArrayList<ActivityModel> activityList = new ArrayList<ActivityModel>();
        if(activityModel != null) {
            activityList.add(activityModel);
        }


        // リクエストスコープの設定
        requestScope("activityList", activityList);
        if(activityModel != null) {
            if(activityModel.getTitleString() != null) {
                requestScope("pageTitle", activityModel.getTitleString() + " - " + acsessUserModel.getDisplayName());

            }else if(activityModel.isAttachmentsFlg() && activityModel.getAttachmentsDisplayNameString() != null) {
                requestScope("pageTitle", activityModel.getAttachmentsDisplayNameString() + " - " + acsessUserModel.getDisplayName());

            }else {
                requestScope("pageTitle", "Google+での投稿 - " + acsessUserModel.getDisplayName());
            }
        }
View Full Code Here

        while (activities != null) {

            for (Activity activity : activities) {

                ActivityModel oldModel = ActivityService.getActivity(activity.getId());

                try {
                    if(oldModel == null) {
                        ActivityService.putActivity(activity, userModel);
                    }
View Full Code Here

     * @return
     */
    public static ActivityModel getActivity(String activityId) {

        Key key = createKey(activityId);
        ActivityModel model = Memcache.get(key.toString());

        if(model == null) {
            model = dao.getOrNull(key);

            if(model != null) {
                Memcache.put(model.getKey().toString(), model);

            }else {
                return null;
            }
        }

        UserModel usermodel = model.getUserModelRef().getModel();
        try {
            if(updateActivity(model, usermodel)) {
                model = dao.getOrNull(key);
            }

View Full Code Here

     * @param activity
     * @return
     */
    public static ActivityModel putActivity(Activity activity, UserModel userModel) throws DataInvalidException {

        ActivityModel model = new ActivityModel();

        // -------------------------------------------------------
        // 基本情報の設定
        // -------------------------------------------------------
        // key
        model.setKey(createKey(activity.getId()));

        // 公開フラグ
        model.setPublicFlg(true);

        // アクティビティタイプ(post or share)
        if(!activity.getVerb().equals(Constants.GOOGLE_ACTIVITY_VERB_TYPE_POST)
                && !activity.getVerb().equals(Constants.GOOGLE_ACTIVITY_VERB_TYPE_SHARE)) {
            throw new DataInvalidException();
        }else {
            model.setVerb(new Category(activity.getVerb()));
        }

        // タイトル
        if(activity.getTitle() != null && !activity.getTitle().trim().isEmpty()) {
            String title = activity.getTitle();
            model.setTitle(new Text(title));
        }

        // 公開日
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(activity.getPublished().getValue());
        calendar.add(Calendar.HOUR, 9);
        model.setPublished(calendar.getTime());

        // 更新日
        model.setUpdated(new Date(activity.getUpdated().getValue()));

        // URL
        model.setUrl(new Text(activity.getUrl()));

        // コンテントの設定
        if(activity.getObject().getContent() != null
                && !activity.getObject().getContent().trim().isEmpty()) {
            String content = activity.getObject().getContent();
            model.setContent(new Text(content));
        }


        // -------------------------------------------------------
        // 添付情報の設定
        // -------------------------------------------------------
        List<Attachments> attachmentsList = activity.getObject().getAttachments();
        if(attachmentsList != null && attachmentsList.size() > 0) {
            // 添付情報の一つ目のみを対象とする
            Attachments attachment = attachmentsList.get(0);

            if(attachment.getObjectType() == null) {
                throw new DataInvalidException();
            }

            // 添付フラグをTrueに設定
            model.setAttachmentsFlg(true);

            // 添付情報のタイプ
            if(attachment.getObjectType() != null) {
                if(attachment.getObjectType().equals(Constants.GOOGLE_ACTIVITY_ATTACHMENTS_TYPE_PHOTO)
                        || attachment.getObjectType().equals(Constants.GOOGLE_ACTIVITY_ATTACHMENTS_TYPE_VIDEO)
                        || attachment.getObjectType().equals(Constants.GOOGLE_ACTIVITY_ATTACHMENTS_TYPE_ARTICLE)
                        || attachment.getObjectType().equals(Constants.GOOGLE_ACTIVITY_ATTACHMENTS_TYPE_ALBUM)) {
                    model.setAttachmentsType(new Category(attachment.getObjectType()));

                }else {
                    throw new DataInvalidException();
                }
            }else {
                throw new DataInvalidException();
            }

            // 添付情報の表示名
            if(attachment.getDisplayName() != null && !attachment.getDisplayName().isEmpty()) {
                model.setAttachmentsDisplayName(new Text(attachment.getDisplayName()));
            }

            // 添付情報のコンテンツ
            if(attachment.getContent() != null && !attachment.getContent().isEmpty()) {
                String content = attachment.getContent();
                model.setAttachmentsContent(new Text(content));
            }

            // 添付情報のURL
            if(attachment.getUrl() != null) {
                model.setAttachmentsUrl(new Text(attachment.getUrl()));
            }

            // 添付情報のイメージURL
            if(attachment.getImage() != null && attachment.getImage().getUrl() != null) {
                model.setAttachmentsImageUrl(new Text(attachment.getImage().getUrl()));
            }

            // 添付情報のFULLイメージURL
            if(attachment.getFullImage() != null && attachment.getFullImage().getUrl() != null) {
                model.setAttachmentsFullImageUrl(new Text(attachment.getFullImage().getUrl()));
            }

            // 動画情報(添付情報は動画の場合)
            if(attachment.getEmbed() != null) {
                if(attachment.getImage() != null && attachment.getImage().getUrl() != null) {
                    model.setAttachmentsImageUrl(new Text(attachment.getImage().getUrl()));
                }

                model.setEmbedType(attachment.getEmbed().getType());
                model.setEmbedUrl(new Text(attachment.getEmbed().getUrl()));
            }

            // アルバムの場合(アクティビティに画像を設定 twtter POSTを簡単にするため)
            if(attachment.getThumbnails() != null && attachment.getThumbnails().size() > 0) {
                Thumbnails thumbnails = attachment.getThumbnails().get(0);
                if(thumbnails != null && thumbnails.getImage() != null) {
                    model.setAttachmentsImageUrl(new Text(thumbnails.getImage().getUrl()));
                }
            }
        }

        // -------------------------------------------------------
        // シェアの場合の元情報
        // -------------------------------------------------------
        if(activity.getVerb().equals(Constants.GOOGLE_ACTIVITY_VERB_TYPE_SHARE)
                && activity.getObject().getActor() != null) {

            model.setShareActorFlg(true);

            model.setActorId(activity.getObject().getActor().getId());
            model.setActorDisplayName(activity.getObject().getActor().getDisplayName());
            model.setActorUrl(new Text(activity.getObject().getActor().getUrl()));

            if(activity.getObject().getActor().getImage() != null && activity.getObject().getActor().getImage().getUrl() != null) {
                model.setActorImageUrl(new Text(activity.getObject().getActor().getImage().getUrl()));
            }

            // 追加コメント
            if(activity.getAnnotation() != null
                    && !activity.getAnnotation().trim().isEmpty()) {
                String content = activity.getAnnotation();
                model.setAnnotation(new Text(content));
            }
        }

        // -------------------------------------------------------
        // 親の設定
        // -------------------------------------------------------
        // userModelの設定
        model.getUserModelRef().setModel(userModel);

        // DateModelの設定
        DateModel dateModel = DateService.getOrNull(userModel, model.getPublished());
        if(dateModel == null) {
            dateModel = DateService.put(userModel, model.getPublished());
        }
        model.getDateModelRef().setModel(dateModel);

        // アクティビティの更新チェック日時を更新
        model.setUpdateCheckDate(new Date());

        // アクティビティ
        return putActivity(userModel, dateModel, model);
    }
View Full Code Here

        List<String> evernoteActivityIdList = new ArrayList<String>();

        // Activityの保存
        for (Activity activity : activities) {

            ActivityModel oldModel = ActivityService.getActivity(activity.getId());

            try {
                // 新しい投稿の場合
                if(oldModel == null) {
                    // 新しいアクティビティを保存
                    ActivityModel newActivityModel = ActivityService.putActivity(activity, userModel);

                    // アルバム内の画像を保存
                    List<Attachments> attachmentsList = activity.getObject().getAttachments();
                    if(attachmentsList != null
                            && attachmentsList.size() > 0) {
View Full Code Here

    @Override
    protected Navigation execute(UserModel loginUserModel) throws Exception {
        String activityId = asString("activity");

        ActivityModel activityModel = ActivityService.getActivity(activityId);

        ArrayList<ActivityModel> activityList = new ArrayList<ActivityModel>();
        if(activityModel != null) {
            activityList.add(activityModel);
        }
View Full Code Here

        while (activities != null && count <= limit) {

            for (Activity activity : activities) {

                ActivityModel oldModel = ActivityService.getActivity(activity.getId());

                try {
                    if(oldModel == null) {
                        ActivityModel newActivityModel = ActivityService.putActivity(activity, userModel);

                        // アルバム内の画像を保存
                        List<Attachments> attachmentsList = activity.getObject().getAttachments();
                        if(attachmentsList != null
                                && attachmentsList.size() > 0) {
View Full Code Here

                        throw new DataInvalidException();
                    }

                    try {

                        ActivityModel oldModel = ActivityService.getActivity(activity.getId());

                        // 新規アクティビティ もしくは 更新されている場合
                        if(oldModel == null || oldModel.getUpdated().before(new Date(activity.getUpdated().getValue()))) {
                            ActivityModel activityModel = ActivityService.putActivity(activity, userModel);
                            activityModelList.add(activityModel);
                        }

                    }catch (Exception e) {};
                }
View Full Code Here

        System.out.println(activityId);
        if(activityId == null || activityId.isEmpty()) {
            return null;
        }

        ActivityModel model = ActivityService.getActivity(activityId);
        if(model == nullreturn null;

        model.setPublicFlg(!model.isPublicFlg());

        DateModel dateModel = DateService.getOrNull(userModel, model.getPublished());
        ActivityService.putActivity(userModel, dateModel, model);

        return null;
    }
View Full Code Here

TOP

Related Classes of com.appspot.plucial.model.ActivityModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.