Search in sources :

Example 1 with ItemRevision

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

the class DimCat method copy.

/**
	 * 
	 * 파일을 복사후 로컬에 붙어넣기.
	 * 파일명에 리비전 번호를 붙여 읽는도중 다른 리비전 읽기 요청이 온 경우 대비할 수 있게한다.
	 * 
	 * 
	 * 2017.4.27
	 * 파일명에 리비전 번호를 붙임.
	 * 파일명에 리비전 번호를 붙여 읽는도중 다른 리비전 읽기 요청이 온 경우 대비할 수 있게한다.
	 * 
	 * 2017.4.13 kyj.
	 * 한가지 우려되는 부분은 
	 * 읽고 있는도중에 쓰거나 
	 * 쓰는도중에 읽는경우 어떻게 반응할것인가 하는문제.
	 * 
	 * 
	 * ps 디멘전 코드는 까볼수없으니 참..
	 * 
	 * 
	 * @작성자 : KYJ
	 * @작성일 : 2017. 3. 14.
	 * @param prjSpec
	 * @param fullPathName
	 * @param revision
	 * @param encoding
	 * @param exceptionHandler
	 * @return
	 * @throws Exception 
	 */
public File copy(String prjSpec, String fullPathName, String revision, String encoding) {
    List<String> linkedList = new LinkedList<String>();
    for (String pathItem : fullPathName.split("/")) {
        if (pathItem != null && !pathItem.isEmpty()) {
            linkedList.add(pathItem);
        }
    }
    //저장 디렉토리 위치
    File root = tmpDir();
    DimensionsConnection conn = null;
    try {
        conn = getConnection();
        Project project = getProject(conn, prjSpec);
        RepositoryFolder rootFolder = project.getRootFolder();
        //searchFindOne(rootFolder, linkedList, revision);
        ItemRevision ir = manager.searchFindOne(rootFolder, linkedList, revision);
        if (ir == null)
            return null;
        //반드시 호출.
        ir.queryAttribute(new int[] { SystemAttributes.ITEMFILE_FILENAME, SystemAttributes.ITEMFILE_DIR, SystemAttributes.LAST_UPDATED_DATE, SystemAttributes.UTC_MODIFIED_DATE, SystemAttributes.REVISION });
        String pathName = ir.getAttribute(SystemAttributes.ITEMFILE_DIR).toString();
        String name = ir.getAttribute(SystemAttributes.ITEMFILE_FILENAME).toString();
        String itemRevision = ir.getAttribute(SystemAttributes.REVISION).toString();
        if (!root.exists()) {
            try {
                FileUtil.mkDirs(root);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        Path path = Paths.get(root.getAbsolutePath(), pathName, name.concat("_").concat(itemRevision));
        //			File tmp = new File(root.getAbsolutePath(), name.concat("_").concat(newRevision));
        //new File(tmp, pathName)  //root.getAbsolutePath() + "/";
        String saveFilePathName = path.toString();
        /* 
			 * java.lang.String destinationFileName, 
			 * boolean expandSubstitutionVariables, 
			 * boolean overwriteWritableFiles, 
			 * boolean applySystemTime
			 * 
			 * 첫번째 String : 저장할 파일명  
			 * 두번째 boolean : ? 치환변수?           ->
			 * 세번째 boolean : 덮어씌울지 여부        -> false - 이미존재하면 덮어쓰지않음
			 * 네번째 boolean : 시스템 타임 적용여부 -> false - 원본파일의 날짜 유지 
			 * */
        DimensionsResult copy = ir.getCopy(saveFilePathName, true, false, false);
        //			DimensionsResult copy = ir.getCopyToFolder(saveFilePathName, true, true, false);
        LOGGER.debug("Dimension DOWLNLOAD  START ############################");
        LOGGER.debug("Dimension DOWLNLOAD  File Name :  " + name);
        LOGGER.debug("Dimension DOWLNLOAD  MESSAGE    :  " + copy.getMessage());
        LOGGER.debug("Dimension DOWLNLOAD  ItemRevisionInfo :  " + ir);
        LOGGER.debug("Dimension DOWLNLOAD  END ############################");
    } finally {
        if (conn != null)
            conn.close();
    }
    return new File(root, fullPathName);
}
Also used : Path(java.nio.file.Path) Project(com.serena.dmclient.api.Project) DimensionsResult(com.serena.dmclient.api.DimensionsResult) RepositoryFolder(com.serena.dmclient.api.RepositoryFolder) DimensionsConnection(com.serena.dmclient.api.DimensionsConnection) ItemRevision(com.serena.dmclient.api.ItemRevision) IOException(java.io.IOException) File(java.io.File) LinkedList(java.util.LinkedList)

Example 2 with ItemRevision

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

the class DimDirHandler method accept.

/**
	 * parent폴더 기준,
	 * filter처리된 아이템 대상으로 하위 아이템들을 순회하는 코드
	 */
@Override
public void accept(RepositoryFolder parent) {
    Filter itemFilter = itemFilter();
    List<DimensionsRelatedObject> childItems = parent.getChildItems(/*필터 적용*/
    itemFilter);
    childItems.stream().map(f -> (ItemRevision) f.getObject()).forEach(r -> handle(r));
}
Also used : List(java.util.List) ScmDirHandler(com.kyj.scm.manager.core.commons.ScmDirHandler) RepositoryFolder(com.serena.dmclient.api.RepositoryFolder) ItemRevision(com.serena.dmclient.api.ItemRevision) DimensionsRelatedObject(com.serena.dmclient.api.DimensionsRelatedObject) Filter(com.serena.dmclient.api.Filter) DimensionsRelatedObject(com.serena.dmclient.api.DimensionsRelatedObject) Filter(com.serena.dmclient.api.Filter) ItemRevision(com.serena.dmclient.api.ItemRevision)

Example 3 with ItemRevision

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

the class DimmensionManager method getRevision.

/**
	 * 날짜에 매치되는 리비젼 번호를 구함.
	 *
	 * 값이 없거나 유효하지않는경우 -1
	 * @작성자 : KYJ
	 * @작성일 : 2016. 7. 14.
	 * @param date
	 * @return
	 * @throws Exception
	 */
public float getRevision(String projSpec, String path, String fileName) throws Exception {
    DimDirHandler handler = new DimDirHandler() {

        Object findOne;

        @Override
        public boolean test(RepositoryFolder entry) {
            return entry.getName().equals(path);
        }

        @Override
        public Filter itemFilter() {
            Filter filter = new Filter();
            filter.criteria().add(new Filter.Criterion(SystemAttributes.IS_LATEST_REV, "Y", 0));
            filter.criteria().add(new Filter.Criterion(SystemAttributes.ITEMFILE_FILENAME, fileName, Filter.Criterion.EQUALS));
            return filter;
        }

        @Override
        public void handle(ItemRevision r) {
            r.queryAttribute(SystemAttributes.REVISION);
            findOne = r.getAttribute(SystemAttributes.REVISION);
        }

        @Override
        public Object get() {
            return findOne;
        }
    };
    this.listEntry(projSpec, path, handler);
    Object object = handler.get();
    if (object != null)
        return Float.parseFloat(object.toString());
    return -1;
}
Also used : RepositoryFolder(com.serena.dmclient.api.RepositoryFolder) Filter(com.serena.dmclient.api.Filter) ItemRevision(com.serena.dmclient.api.ItemRevision)

Example 4 with ItemRevision

use of com.serena.dmclient.api.ItemRevision 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)

Aggregations

ItemRevision (com.serena.dmclient.api.ItemRevision)4 RepositoryFolder (com.serena.dmclient.api.RepositoryFolder)4 Filter (com.serena.dmclient.api.Filter)3 ScmDirHandler (com.kyj.scm.manager.core.commons.ScmDirHandler)2 DimensionsConnection (com.serena.dmclient.api.DimensionsConnection)2 DimensionsRelatedObject (com.serena.dmclient.api.DimensionsRelatedObject)2 Project (com.serena.dmclient.api.Project)2 List (java.util.List)2 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)1 IListCommand (com.kyj.scm.manager.core.commons.IListCommand)1 DimensionsObjectFactory (com.serena.dmclient.api.DimensionsObjectFactory)1 DimensionsResult (com.serena.dmclient.api.DimensionsResult)1 SystemAttributes (com.serena.dmclient.api.SystemAttributes)1 File (java.io.File)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 LinkedList (java.util.LinkedList)1