Examples of Share


Examples of com.skyline.base.model.Share

  }

  @RequestMapping(value = "/view/{id}", method = RequestMethod.GET)
  public ModelAndView listShareByUserId(@PathVariable Long id) {
    ModelAndView mav = new ModelAndView();
    Share share = shareService.getShareById(id);
    if (share == null) {
      // TODO:对share不存在的情况进行处理
      return null;
    } else {
      mav.addObject("SHARE", share);
      if (share.getShareType().equals(ShareType.ARTICLE)) {
        mav.setViewName(ViewPaths.SHARE_VIEWARTICLESHARE);
      }
      return mav;
    }
  }
View Full Code Here

Examples of com.skyline.base.model.Share

  private PersonalFeedService personalFeedService;

  @Override
  public Integer addShare(Long sharerId, String sharerNickname, String sharerPortrait, ShareType shareType, Long resourceId) {
    if (shareType.equals(ShareType.SHARE)) {
      Share s = shareDao.queryShareById(resourceId);
      // System.ou
      if (shareDao.queryCountBySharerTypeResource(sharerId, s.getShareType(), s.getResourceId()) == 0) {
        shareDao.insertShare(sharerId, sharerNickname, sharerPortrait, s.getShareType(), s.getResourceId(), s.getResourceTitle(),
            s.getResourceDigest(), s.getResourceOwnerId(), s.getResourceOwnerNickname(), s.getResourceOwnerPortrait(),
            s.getResourceSourceId(), s.getResourceSoureceName());
        shareDao.updateShareNum(s.getShareType(), s.getResourceId(), s.getResourceOwnerId());
        shareDao.updateShareNum(ShareType.SHARE, s.getId(), s.getSharerId());
        // 分享成功
        return 0;
      } else {
        // 已经分享过了
        return 1;
View Full Code Here

Examples of com.skyline.base.model.Share

    return shareDao.queryShareBySharerIdAndType(sharerId, shareType, page);
  }

  @Override
  public Share getShareById(Long id) {
    Share share = shareDao.queryShareById(id);
    if (share != null) {
      if (share.getShareType().equals(ShareType.ARTICLE)) {
        Article article = articleService.getArticleById(share.getResourceId());
        if (article != null) {
          share.setResourceContent(article.getContent());
          share.setTotalShareNum(article.getShareNum());
        }
      }
    }
    return share;
  }
View Full Code Here

Examples of com.skyline.base.model.Share

  public static ShareMapper getMapper() {
    return MAPPER;
  }

  public Share mapRow(ResultSet rs, int rowNum) throws SQLException {
    Share s = new Share();
    s.setCommentNum(rs.getInt("commentNum"));
    s.setCreateTime(rs.getTimestamp("createTime"));
    s.setDown(rs.getInt("down"));
    s.setId(rs.getLong("id"));
    // s.setResourceContent(rs.getString("resourceContent"));
    s.setResourceDigest(rs.getString("resourceDigest"));
    s.setResourceId(rs.getLong("resourceId"));
    s.setResourceOwnerId(rs.getLong("resourceOwnerId"));
    s.setResourceOwnerNickname(rs.getString("resourceOwnerNickname"));
    s.setResourceOwnerPortrait(rs.getString("resourceOwnerPortrait"));
    s.setResourceSourceId(rs.getLong("resourceSourceId"));
    s.setResourceSoureceName(rs.getString("resourceSoureceName"));
    s.setResourceTitle(rs.getString("resourceTitle"));
    s.setShareNum(rs.getInt("shareNum"));
    s.setSharerId(rs.getLong("sharerId"));
    s.setSharerNickname(rs.getString("sharerNickname"));
    s.setSharerPortrait(rs.getString("sharerPortrait"));
    s.setUp(rs.getInt("up"));
    s.setShareType(ShareType.valueOf(rs.getString("shareType")));
    return s;
  }
View Full Code Here

Examples of de.innovationgate.wga.config.Share

       
        // Add all shares from configuration
        Iterator<Share> shareConfigs = getWgaConfiguration().getShares().iterator();
        Map<String, ShareDefinition> newShares = new HashMap<String, ShareDefinition>();
        while (shareConfigs.hasNext()) {
            Share shareConfig = shareConfigs.next();
            if (!shareConfig.isEnabled()) {
                continue;
            }
           
            ModuleDefinition shareModDefinition = getModuleRegistry().getModuleDefinition(ShareModuleType.class, shareConfig.getImplClassName());
            if (shareModDefinition == null) {
                getLog().error("Unknown content share type '" + shareConfig.getImplClassName() + "'");
                continue;
            }
           
            ShareProperties props = (ShareProperties) shareModDefinition.getProperties();
            try {
                ShareDefinition shareDefinition = props.createShareDefinition(shareConfig);
                shareDefinition.setOrigin(ShareDefinition.ORIGIN_WGACONFIG);
                getLog().info("Initializing content share '" + shareConfig.getName() + "'");
                shareDefinition.init(this);
                newShares.put(shareConfig.getName(), shareDefinition);
            }
            catch (ShareInitException e) {
                getLog().error("Unable to initialize content share '" + shareConfig.getName() + "' because of the following errors:");
                Iterator msgs = e.getDetailMessages().iterator();
                while (msgs.hasNext()) {
                    getLog().error("- " + msgs.next());
                }
            }
            catch (Exception e) {
                getLog().error("Exception initializing content share '" + shareConfig.getName() + "'", e);
            }
        }
       
        // Add custom shares that were added to the previous share configs
        if (_shares != null) {
View Full Code Here

Examples of org.apache.uima.ducc.rm.scheduler.Share

                if ( m == null ) {                             // not known, huh? maybe next epoch it will have checked in
                    refuse(j, "Cannot restore job because node " + ni.getName()  + " is unknown.");
                    return false;                              // so we don't add it to global tables
                } else {
                    DuccId id = proc.getDuccId();
                    Share   s = new Share(id, m, j, m.getShareOrder());        // guess share order; scheduler will reset when it recovers job
                    long mem = proc.getResidentMemory();

                    logger.info(methodName, j.getId(), "Assigning share in state", state, "pid", pid, "for recovery", s.toString());
                    j.recoverShare(s);
                    s.update(j.getId(), mem, state, proc.getTimeWindowInit(), proc.getTimeWindowRun(), pid);                   
                }
            }
            logger.info(methodName, j.getId(), "Scheduling for recovery.");
            scheduler.signalRecovery(j);
        } else {
View Full Code Here

Examples of org.apache.uima.ducc.rm.scheduler.Share

                if ( m == null ) {                             // not known, huh? maybe next epoch it will have checked in
                    refuse(j, "Cannot restore reservation because node " + ni.getName() + " is unknown.");
                    return false;                              // so we don't add it to global tables
                } else {
                    DuccId id = res.getDuccId();
                    Share   s = new Share(id, m, j, m.getShareOrder());
                    s.setFixed();
                    j.recoverShare(s);
                    logger.debug(methodName, j.getId(), "Assigning share for recovery", s.toString());
                }
            }
            logger.info(methodName, j.getId(), "Scheduling for recovery.");
            scheduler.signalRecovery(j);
        } else {
View Full Code Here

Examples of org.apache.uima.ducc.rm.scheduler.Share

        for ( IDuccProcess p : lproc.values() ) {
            // look up share, update resident memory, process state, investment (eventually), maybe pid?
            // simply update the share with the information.  we pass in the jobid as a sanity check so
            // we can crash or at least complain loudly on mismatch.

            Share s = scheduler.getShare(p.getDuccId());
            long mem = p.getResidentMemory();
            ProcessState state = p.getProcessState();
            String pid = p.getPID();

            logger.info(methodName, jobid, "New process ", s.toString(), mem, state, pid);
            if ( ! s.update(jobid, mem, state, p.getTimeWindowInit(), p.getTimeWindowRun(), pid) ) {
                // TODO: probably change to just a warning and cancel the job - for now I want an attention-getter
                throw new SchedulingException(jobid, "Process assignemnt arrives for share " + s.toString() +
                                              " but jobid " + jobid + " does not match share " + s.getJob().getId());
            }
            //scheduler.signalGrowth(jobid, s);
            // sadly, the pid is almost always null here
            //logger.info(methodName, jobid,
            //            "New process arrives for share", s.toString(), "PID", pid);
        }
           
        // gone stuff in in the right side of the map
        Map<DuccId, IDuccProcess> rproc = diffmap.getRight();
        for ( IDuccProcess p : rproc .values()) {
            // these processes are done.  look up the job and tell it process complete.
            Share s = scheduler.getShare(p.getDuccId());
            IRmJob j = scheduler.getJob(jobid);
            if ( j == null ) {
                throw new SchedulingException(jobid, "Process completion arrives for share " + s.toString() +
                                              " but job " + jobid + "cannot be found.");
            }
            scheduler.signalCompletion(j, s);
            logger.info(methodName, jobid,
                         String.format("Process %5s", p.getPID()),
                         "Completion:", s.toString());
        }

        for( DuccMapValueDifference<IDuccProcess> pd: diffmap ) {
            IDuccProcess pl = pd.getLeft();
            IDuccProcess pr = pd.getRight();

            Share sl = scheduler.getShare(pl.getDuccId());
            Share sr = scheduler.getShare(pr.getDuccId());

            String shareL = ( sl == null ) ? "<none>" : sl.toString();
            String shareR = ( sr == null ) ? "<none>" : sr.toString();

            ITimeWindow initL = pl.getTimeWindowInit();
            ITimeWindow initR = pr.getTimeWindowInit();
            long init_timeL = (initL == null) ? 0 : initL.getElapsedMillis();
            long init_timeR = (initR == null) ? 0 : initR.getElapsedMillis();

            /** extreme debugging only*/
            if ( logger.isTrace() ) {
                logger.trace(methodName, jobid,
                             "\n\tReconciling. incoming.(pid, mem, state, share, initTime)",
                             pl.getPID(),
                             pl.getResidentMemory(),
                             pl.getProcessState(),
                             shareL,
                             init_timeL,
                             "\n\tReconciling. existing.(pid, mem, state, share, initTime)",
                             pr.getPID(),
                             pr.getResidentMemory(),
                             pr.getProcessState(),
                             shareR,
                             init_timeR
                             );
            } else {
                if ( (pr.getPID() == null) && (pl.getPID() != null) ) {
                    logger.trace(methodName, jobid,
                                String.format("Process %5s", pl.getPID()),
                                "PID assignement for share", shareL);
                }
                if ( pl.getProcessState() != pr.getProcessState() ) {
                    logger.info(methodName, jobid,
                                String.format("Process %5s", pl.getPID()), sl.toString(),
                                "State:", pr.getProcessState(), "->", pl.getProcessState(),
                                getElapsedTime(pr.getTimeWindowInit()), getElapsedTime(pr.getTimeWindowRun()));
                }
            }

            long mem = pl.getResidentMemory();
            ProcessState state = pl.getProcessState();
            String pid = pl.getPID();                       
            Share s = scheduler.getShare(pl.getDuccId());
            if ( pl.isActive() ) {
               
                if ( s == null ) {
                    // this can happen if a node dies and the share is purged so it's ok.
                    logger.warn(methodName, jobid, "Update for share from process", pl.getPID(), pl.getDuccId(), "but cannot find share.");
                    continue;
                }
               
                if ( s.isPurged() ) {
                    IRmJob j = scheduler.getJob(jobid);
                    scheduler.signalCompletion(j, s);
                    logger.info(methodName, jobid, "Process", pl.getPID(), "marked complete because it is purged. State:", state);
                }

                if ( ! s.update(jobid, mem, state, pl.getTimeWindowInit(), pl.getTimeWindowRun(), pid) ) {
                    // TODO: probably change to just a warning and cancel the job - for now I want an attention-getter
                    throw new SchedulingException(jobid, "Process update arrives for share " + s.toString() +
                                                  " but jobid " + jobid + " does not match job in share " + s.getJob().getId());
                }
                // logger.debug(methodName, jobid, "Process update to process ", pid, "mem", mem, "state", state, "is assigned for share", s.toString());

            } else if ( pl.isComplete() ) {
                if ( s != null ) {              // in some final states the share is already gone, not an error (e.g. Stopped)
View Full Code Here

Examples of org.libreplan.business.planner.entities.Share

        shareDivision = ShareDivision.create(Arrays.asList(shares));
    }

    @Test
    public void aCompoundShareIsCreatedFromSeveralShares() {
        Share share1 = createExampleShare();
        Share share2 = createExampleShare();
        ShareDivision shareDivision = ShareDivision.create(Arrays.asList(
                share1, share2));
        assertThat(shareDivision.getShares(), JUnitMatchers.hasItems(share1,
                share2));
    }
View Full Code Here

Examples of org.libreplan.business.planner.entities.Share

        assertThat(shareDivision.getShares(), JUnitMatchers.hasItems(share1,
                share2));
    }

    private Share createExampleShare() {
        return new Share(10);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.