Changeset 2153


Ignore:
Timestamp:
08/27/12 10:04:08 (12 years ago)
Author:
olhsha
Message:

refactoring of #50

Location:
ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/CMDComponentTypeWrapper.java

    r2152 r2153  
    55package clarin.cmdi.componentregistry;
    66
     7import clarin.cmdi.componentregistry.components.CMDComponentSpec;
    78import clarin.cmdi.componentregistry.components.CMDComponentType;
    89import java.util.List;
     
    1213 * @author olhsha
    1314 */
    14 public class CMDComponentTypeWrapper { // extending CMDComponentType does not work :( does not want to cast
     15public class CMDComponentTypeWrapper { // extending CMDComponentType does not work :( does not want to downcast
    1516   
    16      /**
    17      * Olha: null fileName of *this*, also in children
    18      *
    19      */
     17    CMDComponentType component;
     18    List<CMDComponentType> listofcomponents;
    2019   
    21     // may be do this method static?
    22     public void setFileNamesToNull(CMDComponentType component){
    23     //public void setFileNamesToNull(){   
     20    public CMDComponentTypeWrapper(CMDComponentType newcomponent){
     21        component = newcomponent;
     22        listofcomponents = newcomponent.getCMDComponent();
     23    }
     24   
     25   
     26    public CMDComponentTypeWrapper(CMDComponentSpec newspec){
     27        component = null;
     28        listofcomponents = newspec.getCMDComponent();
     29    }
     30   
     31   
     32    public void setFileNamesToNull(){
     33   
     34        if (component != null) {component.setFilename(null);}
    2435       
    25         // null the filename of component
    26         component.setFilename(null);
    27         //filename=null;
    28                
    29         // and now null filenames in all children's components
    30         List<CMDComponentType> cildrencomponents = component.getCMDComponent();
    31         CMDComponentTypeWrapper childwrapper = new CMDComponentTypeWrapper();
    32         for (CMDComponentType currentcomponent : cildrencomponents) {
    33         //for (CMDComponentType currentcomponent : cmdComponent) {
    34                 childwrapper.setFileNamesToNull(currentcomponent);
    35                 //((CMDComponentTypeWrapper) currentcomponent).setFileNamesToNull();
     36        for (CMDComponentType currentcomponent : listofcomponents) {
     37                CMDComponentTypeWrapper currentwrapper = new CMDComponentTypeWrapper(currentcomponent);
     38                currentwrapper.setFileNamesToNull();
    3639                }
    3740   
  • ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java

    r2152 r2153  
    799799               
    800800                // Olha: removing filename from spec before it gets extended!!! recursion over all the components
    801                 List<CMDComponentType> listofcomponents=spec.getCMDComponent();
    802                 CMDComponentTypeWrapper setnulls= new CMDComponentTypeWrapper();
    803                
    804                 for (CMDComponentType currentcomponent : listofcomponents) {
    805                   setnulls.setFileNamesToNull(currentcomponent);
    806                   }
     801                CMDComponentTypeWrapper setnull = new CMDComponentTypeWrapper(spec);
    807802               
    808                 //for (CMDComponentType currentcomponent : listofcomponents) {
    809                   //((CMDComponentTypeWrapper) currentcomponent). setFileNamesToNull();
    810                    
    811                 //}
     803               
    812804               
    813805                try {
Note: See TracChangeset for help on using the changeset viewer.