Thursday, March 3, 2011

Remove CVS folder

hsual@DTC2700311CD565$ find . | grep CVS
./PMP_Report/DEFAULT/C3.1_STND/CVS
./PMP_Report/DEFAULT/C3.1_STND/CVS/Entries
./PMP_Report/DEFAULT/C3.1_STND/CVS/Repository
./PMP_Report/DEFAULT/C3.1_STND/CVS/Root
./PMP_Report/DEFAULT/CVS
./PMP_Report/DEFAULT/CVS/Entries
./PMP_Report/DEFAULT/CVS/Repository
./PMP_Report/DEFAULT/CVS/Root
./PMP_Report/DEFAULT/PAYROLL/CVS
./PMP_Report/DEFAULT/PAYROLL/CVS/Entries
./PMP_Report/DEFAULT/PAYROLL/CVS/Repository
./PMP_Report/DEFAULT/PAYROLL/CVS/Root
hsual@DTC2700311CD565$ 
hsual@DTC2700311CD565$ 
hsual@DTC2700311CD565$ 
hsual@DTC2700311CD565$ find . | grep CVS$ | xargs rm -rf
hsual@DTC2700311CD565$ find . | grep CVS
hsual@DTC2700311CD565$ 

Thursday, February 24, 2011

Java Read/Write Fixed Length file sample

public static void TempPreProcessor_Fixed(String input, String output){
 BufferedReader reader = null;
 BufferedWriter writer = null;
 try 
 {
  String inputfilename = input;
  String outputfilename = output;
  
  reader = new BufferedReader(
     new InputStreamReader(
       new FileInputStream(inputfilename)));
  writer = new BufferedWriter(
     new OutputStreamWriter(
       new FileOutputStream(outputfilename)));
  
  String thisLine = null;

  //line 1
  if((thisLine =reader.readLine()) != null) 
   writer.write("AA,"+thisLine+"\n");

  //line 2-4
  for(int i = 0; i<3; i++){
   if((thisLine =reader.readLine()) != null)
    writer.write(thisLine+"\n");
  }
  
  //remaining lines
  while((thisLine=reader.readLine()) != null){   
   //add AB to start of line
   writer.write("AB,"+thisLine+"\n");
   //copy with no change
   if((thisLine=reader.readLine()) != null)
    writer.write(thisLine+"\n");
  } 
 }catch(Exception e){
  throw new ServiceException("TempPreProcessor: Unknown errors: " + e.toString());
 }finally{
  try{
   if(writer != null) writer.flush();
   if(reader != null) reader.close();
   if(writer != null) writer.close();
   reader=null; writer=null;
  }catch(Exception e){
   throw new ServiceException("TempPreProcessor: Unknown errors: " + e.toString());
  }
 }
}

Java Read/Write CSV file sample

public static void TempPreProcessor_CSV(String input, String output){
 //IDataSharedCursor idc = pipeline.getSharedCursor();
 BufferedReader reader = null;
 BufferedWriter writer = null;
 try 
 {
  String inputfilename = input;
  String outputfilename = output;

  reader = new BufferedReader(
               new InputStreamReader(
                   new FileInputStream(inputfilename)));
  writer = new BufferedWriter(
               new OutputStreamWriter(
                   new FileOutputStream(outputfilename)));
  int lineNum = 1;
  String checkNum = "";
  
  String thisLine = "";

  // comma, which is not enclosed in quotes
  String delims = ",(?=([^\"]*\"[^\"]*\")*[^\"]*$)";

  while((thisLine=reader.readLine()) != null){// till end of file
     StringBuffer sb = new StringBuffer();
     if(thisLine.trim().equals("")) 
                           continue; // ignore blank lines
   
     if (lineNum++ == 1){
      sb.append(thisLine + "\n");
      writer.write(sb.toString());
      continue;  
     }

     String[] thisTokens = thisLine.split(delims);                           
     if (!checkNum.equalsIgnoreCase(thisTokens[0].toString())){
         checkNum = thisTokens[0].toString();
         sb.append("AA," + thisLine);
     }else{
         sb.append("AB," + thisLine);
     }
     sb.append("\n");
     writer.write(sb.toString());
  }
 }catch(Exception e){
  //throw new ServiceException(
  //  "TempPreProcessor: Unknown errors: " + e.toString());
 }finally{
  try {
   if(writer != null) writer.flush();
   if(reader != null) reader.close();
   if(writer != null) writer.close();
   reader=null;
   writer=null;
   //idc.destroy();
  }catch(Exception e){
   //throw new ServiceException(
   //  "TempPreProcessor: Unknown errors: " + e.toString());
  }
 }
}

Java Date Format

public static String parseDate(String inDate, String fmFormat, String toFormat){
        SimpleDateFormat fmFormatter = new SimpleDateFormat(fmFormat);
        SimpleDateFormat toFormatter = new SimpleDateFormat(toFormat);
        if ( inDate == null ) return "";  // To avoid java.lang.NullPointerException
        if ( inDate.length() == 0 ) return ""; // Taking care of empty string.
        Date fromDate = null;
        try {
         fromDate = (Date) fmFormatter.parse(inDate);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return  toFormatter.format(fromDate);
}

Java Switch Statement

int boolInt=1;
switch (boolInt){
case 0: System.out.println("true = 0"); break;
case 1: System.out.println("false = 1"); break;
default: System.out.println("Invalid"); break;
}

// In Java SE 7 and later, you can use a String object in the switch statement's expression
String boolStr = "true";
switch (boolStr.toLowerCase()){
case "true": System.out.println("0 = true"); break;
case "false": System.out.println("1 = false"); break;
default: System.out.println(" Not 0/1 = false"); break;
}

Wednesday, January 12, 2011

How to move a tag to the tip of a branch?

CVS allows an existing tag to be moved to the tip of a branch in one operation (tag -F) so with this method we don't have to execute an additional “cvs rtag –d” operation to clean out the tag and then “cvs tag”.

Step 1: View the current Graph Selection: Right click on file2.txt file -> click on Graph selection…


Step 2: Update file2.txt and commit it to version 1.2.2.2

Step 3: Repeat Step 1 – Note that we want to move R-0-1-1 to version 1.2.2.2.

Step 4: Moving R-0-1-1: Admin -> Command Line … -> Enter “cvs tag –F R-0-1-1” in Command line settings window -> click on OK button in Command line settings window.

Step 5: Verify Changes:
cvs tag -F R-0-1-1
T file2.txt

*****CVS exited normally with code 0*****
Or repeat Step 1:

How to remove files or directories in CVS?

To remove files, you first schedule the files for removal, and then commit the change:

1. Select the file or files that you want to remove.
2. Click the right mouse button on the selection, and choose the Remove selection menu item. (See the Note below if you can’t find the Remove select menu item.)
3. As the files are only marked for removal, you have to commit them to remove them from the repository. See Sending Your Changes to CVS if you don't know how to commit.

Note: If you can’t find the Remove selection menu item, then: Right click on any file -> Select “Customize this menu…” -> Add the “Remove selection” item on Customize menus window. -> Click OK.

The files will now be removed from the repository. Note that files are not physically removed, but rather marked as "dead". By this way it will still be possible to retrieve the files if you choose to check out an old version of the module.

Removing directories is another story. CVS will optionally remove empty directories when you update one of its parent directories. If you want to get rid of an empty directory, do the following:
1. Select the parent directory of the empty directory you want to remove.
2. Click the right mouse button on the selection, and choose the Update selection menu item.
3. Select the Globals tab.
4. Make sure Prune (remove) empty directories is checked (it is by default).
5. Press the OK button.

The directory will be removed if all its files were previously removed from your local copy and from the repository.