Search in sources :

Example 6 with RepositoryFolder

use of com.serena.dmclient.api.RepositoryFolder in project Gargoyle by callakrsos.

the class DimList method listEntry.

/********************************
	 * 작성일 : 2016. 5. 9. 작성자 : KYJ
	 *
	 * 디멘전 트리 순회
	 *
	 * 2016-11-03 버그 수정
	 *
	 * @param path
	 * @param revision
	 * @param exceptionHandler
	 * @return
	 ********************************/
public void listEntry(String projSpec, String path, DimDirHandler handler) throws Exception {
    DimensionsConnection conn = null;
    try {
        conn = getConnection();
        DimensionsObjectFactory objectFactory = conn.getObjectFactory();
        Project project = objectFactory.getProject(projSpec);
        RepositoryFolder rootFoler = project.findRepositoryFolderByPath(path);
        listEntry(rootFoler, handler);
    } finally {
        manager.close(conn);
    }
}
Also used : Project(com.serena.dmclient.api.Project) RepositoryFolder(com.serena.dmclient.api.RepositoryFolder) DimensionsConnection(com.serena.dmclient.api.DimensionsConnection) DimensionsObjectFactory(com.serena.dmclient.api.DimensionsObjectFactory)

Example 7 with RepositoryFolder

use of com.serena.dmclient.api.RepositoryFolder in project Gargoyle by callakrsos.

the class DimList method listEntry.

/**
	 * 디멘전 트리 순회
	 * @작성자 : KYJ
	 * @작성일 : 2017. 4. 24. 
	 * @param parent
	 * @param handler
	 * @return
	 * @throws Exception
	 */
public List<DimensionsRelatedObject> listEntry(RepositoryFolder parent, ScmDirHandler<RepositoryFolder> handler) throws Exception {
    ArrayList<DimensionsRelatedObject> items = new ArrayList<DimensionsRelatedObject>();
    //자기 자신에 대한 정보
    if (handler.test(parent)) {
        handler.accept(parent);
    }
    //모든 하위 디렉토리를 출력한것.
    List<RepositoryFolder> allChildFolders = parent.getAllChildFolders();
    if (allChildFolders.isEmpty()) {
        return items;
    }
    for (RepositoryFolder r : allChildFolders) {
        if (handler.test(r)) {
            handler.accept(r);
        /*
				 * getAllChildFolder()함수 자체가 재귀호출 로직을 처리하지않게끔.
				 * 모든 하위 디렉토리를 출력함.
				 */
        // listEntry(r, handler);  ** 재귀처리하지않는다. 
        }
    }
    return items;
}
Also used : RepositoryFolder(com.serena.dmclient.api.RepositoryFolder) DimensionsRelatedObject(com.serena.dmclient.api.DimensionsRelatedObject) ArrayList(java.util.ArrayList)

Example 8 with RepositoryFolder

use of com.serena.dmclient.api.RepositoryFolder in project Gargoyle by callakrsos.

the class DimList method list.

/********************************
	 * 작성일 : 2017. 4. 24. 작성자 : KYJ
	 *
	 * path에 속하는 하위 구성정보 조회
	 *
	 * @param path
	 * @param revision
	 * @param exceptionHandler
	 * @return
	 ********************************/
public <T> List<T> list(String projSpec, String path, String fileName, String revision, Function<ItemRevision, T> convert, Consumer<Exception> exceptionHandler) {
    List<T> collections = Collections.emptyList();
    DimensionsConnection conn = null;
    try {
        conn = getConnection();
        Project projObj = getProject(conn, projSpec);
        RepositoryFolder findRepositoryFolderByPath = projObj.findRepositoryFolderByPath(path);
        Filter filter = new Filter();
        if (ValueUtil.isNotEmpty(fileName))
            filter.criteria().add(new Filter.Criterion(SystemAttributes.ITEMFILE_FILENAME, fileName, Filter.Criterion.EQUALS));
        if (ValueUtil.equals("-1", revision)) {
            filter.criteria().add(new Filter.Criterion(SystemAttributes.IS_LATEST_REV, "Y", 0));
        } else {
            filter.criteria().add(new Filter.Criterion(SystemAttributes.REVISION, revision, Filter.Criterion.EQUALS));
        }
        List allChildFolders = findRepositoryFolderByPath.getAllChildFolders();
        List<DimensionsRelatedObject> childItems = findRepositoryFolderByPath.getChildItems(filter);
        //			Stream.concat(allChildFolders, childItems);
        List<ItemRevision> collect = childItems.stream().map(i -> (ItemRevision) i.getObject()).collect(Collectors.toList());
        collections = collect.stream().map(convert).collect(Collectors.toList());
    } catch (Exception e) {
        exceptionHandler.accept(e);
    } finally {
        manager.close(conn);
    }
    return collections;
}
Also used : Arrays(java.util.Arrays) Properties(java.util.Properties) Logger(org.slf4j.Logger) ScmDirHandler(com.kyj.scm.manager.core.commons.ScmDirHandler) DimensionsConnection(com.serena.dmclient.api.DimensionsConnection) LoggerFactory(org.slf4j.LoggerFactory) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) DimensionsRelatedObject(com.serena.dmclient.api.DimensionsRelatedObject) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) DimensionsObjectFactory(com.serena.dmclient.api.DimensionsObjectFactory) Project(com.serena.dmclient.api.Project) List(java.util.List) IListCommand(com.kyj.scm.manager.core.commons.IListCommand) RepositoryFolder(com.serena.dmclient.api.RepositoryFolder) ItemRevision(com.serena.dmclient.api.ItemRevision) Collections(java.util.Collections) SystemAttributes(com.serena.dmclient.api.SystemAttributes) Filter(com.serena.dmclient.api.Filter) DimensionsRelatedObject(com.serena.dmclient.api.DimensionsRelatedObject) DimensionsConnection(com.serena.dmclient.api.DimensionsConnection) Project(com.serena.dmclient.api.Project) RepositoryFolder(com.serena.dmclient.api.RepositoryFolder) Filter(com.serena.dmclient.api.Filter) ArrayList(java.util.ArrayList) List(java.util.List) ItemRevision(com.serena.dmclient.api.ItemRevision)

Example 9 with RepositoryFolder

use of com.serena.dmclient.api.RepositoryFolder in project Gargoyle by callakrsos.

the class DimResource method search.

public <K> K search(RepositoryFolder folder, List<String> linkedList, String revision, Function<List<DimensionsRelatedObject>, K> convert) {
    K items = null;
    if (linkedList.size() == 0) {
        return items;
    }
    String subPathName = linkedList.get(0);
    if (linkedList.size() > 1) {
        RepositoryFolder childFolder = folder.getChildFolder(subPathName);
        linkedList.remove(0);
        return search(childFolder, linkedList, revision, convert);
    } else {
        Filter filter = new Filter();
        /* 파일명과 동일한것만 가져옴 */
        filter.criteria().add(new Filter.Criterion(SystemAttributes.ITEMFILE_FILENAME, subPathName, Filter.Criterion.EQUALS));
        if ("-1".equals(revision))
            //$NON-NLS-1$
            filter.criteria().add(new Filter.Criterion(SystemAttributes.IS_LATEST_REV, "Y", 0));
        else
            filter.criteria().add(new Filter.Criterion(SystemAttributes.REVISION, revision, Filter.Criterion.EQUALS));
        List<DimensionsRelatedObject> childItems = folder.getChildItems(filter);
        return convert.apply(childItems);
    }
}
Also used : RepositoryFolder(com.serena.dmclient.api.RepositoryFolder) DimensionsRelatedObject(com.serena.dmclient.api.DimensionsRelatedObject) Filter(com.serena.dmclient.api.Filter)

Aggregations

RepositoryFolder (com.serena.dmclient.api.RepositoryFolder)9 DimensionsConnection (com.serena.dmclient.api.DimensionsConnection)5 DimensionsRelatedObject (com.serena.dmclient.api.DimensionsRelatedObject)5 Filter (com.serena.dmclient.api.Filter)5 ItemRevision (com.serena.dmclient.api.ItemRevision)5 Project (com.serena.dmclient.api.Project)5 List (java.util.List)3 ScmDirHandler (com.kyj.scm.manager.core.commons.ScmDirHandler)2 DimensionsObjectFactory (com.serena.dmclient.api.DimensionsObjectFactory)2 SystemAttributes (com.serena.dmclient.api.SystemAttributes)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 Properties (java.util.Properties)2 Function (java.util.function.Function)2 Collectors (java.util.stream.Collectors)2 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)1 IListCommand (com.kyj.scm.manager.core.commons.IListCommand)1 DimensionsResult (com.serena.dmclient.api.DimensionsResult)1 IOException (java.io.IOException)1