Example usage for java.math BigInteger intValue

List of usage examples for java.math BigInteger intValue

Introduction

In this page you can find the example usage for java.math BigInteger intValue.

Prototype

public int intValue() 

Source Link

Document

Converts this BigInteger to an int .

Usage

From source file:jp.aegif.nemaki.cmis.aspect.type.impl.TypeManagerImpl.java

/**
 * CMIS getTypesDescendants.//from  w w  w .j a  v  a  2 s .c o m
 */
@Override
public List<TypeDefinitionContainer> getTypesDescendants(String repositoryId, String typeId, BigInteger depth,
        Boolean includePropertyDefinitions) {
    Map<String, TypeDefinitionContainer> types = TYPES.get(repositoryId);

    List<TypeDefinitionContainer> result = new ArrayList<TypeDefinitionContainer>();

    // check depth
    int d = (depth == null ? -1 : depth.intValue());
    if (d == 0) {
        throw new CmisInvalidArgumentException("Depth must not be 0!");
    } else if (d < -1) {
        throw new CmisInvalidArgumentException("Depth must be positive(except for -1, that means infinity!");
    }

    // set property definition flag to default value if not set
    boolean ipd = (includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue());

    if (typeId == null) {
        flattenTypeDefinitionContainer(types.get(BaseTypeId.CMIS_FOLDER.value()), result, d, ipd);
        flattenTypeDefinitionContainer(types.get(BaseTypeId.CMIS_DOCUMENT.value()), result, d, ipd);
        flattenTypeDefinitionContainer(types.get(BaseTypeId.CMIS_RELATIONSHIP.value()), result, d, ipd);
        flattenTypeDefinitionContainer(types.get(BaseTypeId.CMIS_POLICY.value()), result, d, ipd);
        flattenTypeDefinitionContainer(types.get(BaseTypeId.CMIS_ITEM.value()), result, d, ipd);
        flattenTypeDefinitionContainer(types.get(BaseTypeId.CMIS_SECONDARY.value()), result, d, ipd);
    } else {
        TypeDefinitionContainer tdc = types.get(typeId);
        flattenTypeDefinitionContainer(tdc, result, d, ipd);
    }

    return result;
}

From source file:org.opencms.cmis.CmsCmisRepository.java

/**
 * @see org.opencms.cmis.I_CmsCmisRepository#getDescendants(org.opencms.cmis.CmsCmisCallContext, java.lang.String, java.math.BigInteger, java.lang.String, boolean, boolean, boolean)
 *///from w w  w .  j  ava 2 s.  c om
public synchronized List<ObjectInFolderContainer> getDescendants(CmsCmisCallContext context, String folderId,
        BigInteger depth, String filter, boolean includeAllowableActions, boolean includePathSegment,
        boolean foldersOnly) {

    try {
        CmsCmisResourceHelper helper = getResourceHelper();

        // check depth
        int d = (depth == null ? 2 : depth.intValue());
        if (d == 0) {
            throw new CmisInvalidArgumentException("Depth must not be 0!");
        }
        if (d < -1) {
            d = -1;
        }

        // split filter
        Set<String> filterCollection = splitFilter(filter);

        CmsObject cms = getCmsObject(context);
        CmsUUID folderStructureId = new CmsUUID(folderId);
        CmsResource folder = cms.readResource(folderStructureId);
        if (!folder.isFolder()) {
            throw new CmisObjectNotFoundException("Not a folder!");
        }

        // set object info of the the folder
        if (context.isObjectInfoRequired()) {
            helper.collectObjectData(context, cms, folder, null, "cmis:none", false, false,
                    IncludeRelationships.NONE);
        }

        // get the tree
        List<ObjectInFolderContainer> result = new ArrayList<ObjectInFolderContainer>();
        gatherDescendants(context, cms, folder, result, foldersOnly, d, filterCollection,
                includeAllowableActions, includePathSegment);

        return result;
    } catch (CmsException e) {
        handleCmsException(e);
        return null;
    }
}

From source file:org.eclipse.ecr.opencmis.impl.server.NuxeoCmisService.java

@Override
public List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth,
        Boolean includePropertyDefinitions, ExtensionsData extension) {
    int d = depth == null ? DEFAULT_TYPE_LEVELS : depth.intValue();
    List<TypeDefinitionContainer> types = repository.getTypeDescendants(typeId, d, includePropertyDefinitions);
    // clone// w  w w .  ja v a  2  s . c o m
    // TODO copy only when local binding
    List<CmisTypeContainer> tmp = new ArrayList<CmisTypeContainer>(types.size());
    Converter.convertTypeContainerList(types, tmp);
    return Converter.convertTypeContainerList(tmp);
}

From source file:org.opencms.cmis.CmsCmisRepository.java

/**
 * @see org.opencms.cmis.I_CmsCmisRepository#getChildren(org.opencms.cmis.CmsCmisCallContext, java.lang.String, java.lang.String, java.lang.String, boolean, org.apache.chemistry.opencmis.commons.enums.IncludeRelationships, java.lang.String, boolean, java.math.BigInteger, java.math.BigInteger)
 *///from w w w .j av a  2 s  .  c o m
public synchronized ObjectInFolderList getChildren(CmsCmisCallContext context, String folderId, String filter,
        String orderBy, boolean includeAllowableActions, IncludeRelationships includeRelationships,
        String renditionFilter, boolean includePathSegment, BigInteger maxItems, BigInteger skipCount) {

    try {
        CmsCmisResourceHelper helper = getResourceHelper();

        // split filter
        Set<String> filterCollection = splitFilter(filter);
        // skip and max
        int skip = (skipCount == null ? 0 : skipCount.intValue());
        if (skip < 0) {
            skip = 0;
        }

        int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue());
        if (max < 0) {
            max = Integer.MAX_VALUE;
        }

        CmsObject cms = getCmsObject(context);
        CmsUUID structureId = new CmsUUID(folderId);
        CmsResource folder = cms.readResource(structureId);
        if (!folder.isFolder()) {
            throw new CmisObjectNotFoundException("Not a folder!");
        }

        // set object info of the the folder
        if (context.isObjectInfoRequired()) {
            helper.collectObjectData(context, cms, folder, null, renditionFilter, false, false,
                    includeRelationships);
        }

        // prepare result
        ObjectInFolderListImpl result = new ObjectInFolderListImpl();
        String folderSitePath = cms.getRequestContext().getSitePath(folder);
        List<CmsResource> children = cms.getResourcesInFolder(folderSitePath, CmsResourceFilter.DEFAULT);
        CmsObjectListLimiter<CmsResource> limiter = new CmsObjectListLimiter<CmsResource>(children, maxItems,
                skipCount);
        List<ObjectInFolderData> resultObjects = new ArrayList<ObjectInFolderData>();
        for (CmsResource child : limiter) {
            // build and add child object
            ObjectInFolderDataImpl objectInFolder = new ObjectInFolderDataImpl();
            objectInFolder.setObject(helper.collectObjectData(context, cms, child, filterCollection,
                    renditionFilter, includeAllowableActions, false, includeRelationships));
            if (includePathSegment) {
                objectInFolder.setPathSegment(child.getName());
            }
            resultObjects.add(objectInFolder);
        }
        result.setObjects(resultObjects);
        result.setNumItems(BigInteger.valueOf(children.size()));
        result.setHasMoreItems(Boolean.valueOf(limiter.hasMore()));
        return result;
    } catch (CmsException e) {
        handleCmsException(e);
        return null;
    }

}

From source file:org.opencms.cmis.CmsCmisRepository.java

/**
 * @see org.opencms.cmis.I_CmsCmisRepository#query(org.opencms.cmis.CmsCmisCallContext, java.lang.String, boolean, boolean, org.apache.chemistry.opencmis.commons.enums.IncludeRelationships, java.lang.String, java.math.BigInteger, java.math.BigInteger)
 *//*from  ww w . j a  va  2s .  c o  m*/
@Override
public synchronized ObjectList query(CmsCmisCallContext context, String statement, boolean searchAllVersions,
        boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
        BigInteger maxItems, BigInteger skipCount) {

    try {
        CmsObject cms = getCmsObject(context);
        CmsSolrIndex index = getIndex();
        CmsCmisResourceHelper helper = getResourceHelper();

        // split filter
        Set<String> filterCollection = null;
        // skip and max
        int skip = (skipCount == null ? 0 : skipCount.intValue());
        if (skip < 0) {
            skip = 0;
        }

        int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue());
        if (max < 0) {
            max = Integer.MAX_VALUE;
        }
        CmsSolrResultList results = solrSearch(cms, index, statement, skip, max);
        ObjectListImpl resultObjectList = new ObjectListImpl();
        List<ObjectData> objectDataList = new ArrayList<ObjectData>();
        resultObjectList.setObjects(objectDataList);
        for (CmsResource resource : results) {
            // build and add child object
            objectDataList.add(helper.collectObjectData(context, cms, resource, filterCollection,
                    renditionFilter, includeAllowableActions, false, includeRelationships));
        }
        resultObjectList.setHasMoreItems(Boolean.valueOf(!results.isEmpty()));
        resultObjectList.setNumItems(BigInteger.valueOf(results.getVisibleHitCount()));
        return resultObjectList;
    } catch (CmsException e) {
        handleCmsException(e);
        return null;
    }

}

From source file:com.sourcesense.opencmis.server.HstCmisRepository.java

/**
 * CMIS getChildren.//  w ww.  j  a  v  a 2s  .c  o m
 */
public ObjectInFolderList getChildren(CallContext context, String folderId, String filter,
        Boolean includeAllowableActions, Boolean includePathSegment, BigInteger maxItems, BigInteger skipCount,
        ObjectInfoHandler objectInfos, HttpServletRequest servletRequest)
        throws ObjectBeanManagerException, RepositoryException {
    debug("getChildren");
    boolean userReadOnly = checkUser(context, false);

    // split filter
    Set<String> filterCollection = splitFilter(filter);

    // set defaults if values not set
    boolean iaa = (includeAllowableActions == null ? false : includeAllowableActions.booleanValue());
    boolean ips = (includePathSegment == null ? false : includePathSegment.booleanValue());

    // skip and max
    int skip = (skipCount == null ? 0 : skipCount.intValue());
    if (skip < 0) {
        skip = 0;
    }

    int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue());
    if (max < 0) {
        max = Integer.MAX_VALUE;
    }

    HstRequestContext requestContext = getRequestContext(servletRequest);
    ObjectBeanPersistenceManager contentPersistenceManager = getContentPersistenceManager(requestContext);

    // get the folder
    HippoFolderBean folder = (HippoFolderBean) contentPersistenceManager.getObjectByUuid(folderId);

    // set object info of the the folder
    if (context.isObjectInfoRequired()) {
        compileObjectType(context, folder, null, false, false, userReadOnly, objectInfos);
    }

    // prepare result
    ObjectInFolderListImpl result = new ObjectInFolderListImpl();
    result.setObjects(new ArrayList<ObjectInFolderData>());
    result.setHasMoreItems(false);
    int count = 0;

    // iterate through children

    List children = folder.getFolders();
    children.addAll(folder.getDocuments());

    while (children.iterator().hasNext()) {
        HippoBean child = (HippoBean) children.iterator().next();

        count++;
        if (skip > 0) {
            skip--;
            continue;
        }

        if (result.getObjects().size() >= max) {
            result.setHasMoreItems(true);
            continue;
        }

        // build and add child object
        ObjectInFolderDataImpl objectInFolder = new ObjectInFolderDataImpl();
        objectInFolder.setObject(
                compileObjectType(context, child, filterCollection, iaa, false, userReadOnly, objectInfos));
        if (ips) {
            objectInFolder.setPathSegment(child.getName());
        }

        result.getObjects().add(objectInFolder);
    }

    result.setNumItems(BigInteger.valueOf(count));

    return result;
}

From source file:gov.nih.nci.cabig.caaers.service.migrator.StudyConverter.java

private void populateStudyDevices(gov.nih.nci.cabig.caaers.integration.schema.study.Study studyDto, Study study)
        throws Exception {
    List<StudyDevice> l = new ArrayList<StudyDevice>();

    if (studyDto.getStudyDevices() == null)
        return;/*  ww  w .j  ava2  s  .co  m*/

    for (StudyDeviceType sdt : studyDto.getStudyDevices().getStudyDevice()) {
        StudyDevice sd = new StudyDevice();

        if (sdt.getDevice() != null) {
            sd.setDevice(new Device());
            sd.getDevice().setBrandName(sdt.getDevice().getBrandName());
            sd.getDevice().setCommonName(sdt.getDevice().getCommonName());
            sd.getDevice().setType(sdt.getDevice().getType());
            sd.getDevice().setCtepDbIdentifier(sdt.getDevice().getCtepDbIdentifier());
        } else {
            sd.setOtherBrandName(sdt.getOtherBrandName());
            sd.setOtherCommonName(sdt.getOtherCommonName());
            sd.setOtherDeviceType(sdt.getOtherDeviceType());
        }
        sd.setCatalogNumber(sdt.getCatalogNumber());
        sd.setManufacturerCity(sdt.getManufacturerCity());
        sd.setManufacturerName(sdt.getManufacturerName());
        sd.setManufacturerState(sdt.getManufacturerState());
        sd.setModelNumber(sdt.getModelNumber());

        //add IDEs
        StudyDeviceINDAssociations ideAssociations = sdt.getStudyDeviceINDAssociations();
        if (ideAssociations != null) {
            StudyDeviceINDAssociationType ideAssociationType = ideAssociations.getStudyDeviceINDAssociation();
            if (ideAssociationType != null) {
                StudyDeviceINDAssociation studyDeviceINDAssociation = new StudyDeviceINDAssociation();
                sd.addStudyDeviceINDAssociation(studyDeviceINDAssociation);

                InvestigationalNewDrugType ideType = ideAssociationType.getInvestigationalNewDrug();
                if (ideType != null) {
                    String ideHolder = ideType.getHolderName();
                    BigInteger ideNumber = ideType.getIndNumber();

                    if (ideNumber != null) {
                        InvestigationalNewDrug ind = new InvestigationalNewDrug();
                        ind.setHolderName(ideHolder);
                        ind.setIndNumber(ideNumber.intValue());
                        ind.setStatus(ActiveInactiveStatus.AC.getCode());
                        if (ideType.getStatus() != null) {
                            ind.setStatus(ideType.getStatus().value());
                        }
                        studyDeviceINDAssociation.setInvestigationalNewDrug(ind);

                    }
                }

            }
        }

        l.add(sd);
    }

    study.setStudyDevices(l);
}

From source file:org.eclipse.ecr.opencmis.impl.server.NuxeoCmisService.java

@Override
public List<ObjectInFolderContainer> getDescendants(String repositoryId, String folderId, BigInteger depth,
        String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
        String renditionFilter, Boolean includePathSegment, ExtensionsData extension) {
    if (folderId == null) {
        throw new CmisInvalidArgumentException("Null folderId");
    }/* www. j  a  v a2  s  .  c  o m*/
    int levels = depth == null ? DEFAULT_FOLDER_LEVELS : depth.intValue();
    if (levels == 0) {
        throw new CmisInvalidArgumentException("Invalid depth: 0");
    }
    return getDescendantsInternal(repositoryId, folderId, filter, includeAllowableActions, includeRelationships,
            renditionFilter, includePathSegment, 0, levels, false);
}

From source file:org.eclipse.ecr.opencmis.impl.server.NuxeoCmisService.java

@Override
public List<ObjectInFolderContainer> getFolderTree(String repositoryId, String folderId, BigInteger depth,
        String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
        String renditionFilter, Boolean includePathSegment, ExtensionsData extension) {
    if (folderId == null) {
        throw new CmisInvalidArgumentException("Null folderId");
    }/* w w  w . j a v  a  2  s  .c  o  m*/
    int levels = depth == null ? DEFAULT_FOLDER_LEVELS : depth.intValue();
    if (levels == 0) {
        throw new CmisInvalidArgumentException("Invalid depth: 0");
    }
    return getDescendantsInternal(repositoryId, folderId, filter, includeAllowableActions, includeRelationships,
            renditionFilter, includePathSegment, 0, levels, true);
}

From source file:jp.aegif.nemaki.businesslogic.impl.ContentServiceImpl.java

@Override
public List<Change> getLatestChanges(String repositoryId, CallContext context, Holder<String> changeLogToken,
        Boolean includeProperties, String filter, Boolean includePolicyIds, Boolean includeAcl,
        BigInteger maxItems, ExtensionsData extension) {
    return contentDaoService.getLatestChanges(repositoryId, changeLogToken.getValue(), maxItems.intValue());
}