Subversion Repositories SmartDukaan

Rev

Rev 91 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 91 Rev 102
Line 1... Line 1...
1
/**
1
/**
2
 * 
2
 * 
3
 */
3
 */
4
package in.shop2020.util;
4
package in.shop2020.util;
5
 
5
 
-
 
6
import in.shop2020.metamodel.core.Bullet;
6
import in.shop2020.metamodel.core.Entity;
7
import in.shop2020.metamodel.core.Entity;
7
import in.shop2020.metamodel.core.Feature;
8
import in.shop2020.metamodel.core.Feature;
-
 
9
import in.shop2020.metamodel.core.PrimitiveDataObject;
8
import in.shop2020.metamodel.core.Slide;
10
import in.shop2020.metamodel.core.Slide;
-
 
11
import in.shop2020.metamodel.definitions.BulletDefinition;
9
import in.shop2020.metamodel.definitions.Catalog;
12
import in.shop2020.metamodel.definitions.Catalog;
10
import in.shop2020.metamodel.definitions.Category;
13
import in.shop2020.metamodel.definitions.Category;
11
import in.shop2020.metamodel.definitions.DatatypeDefinition;
14
import in.shop2020.metamodel.definitions.DatatypeDefinition;
12
import in.shop2020.metamodel.definitions.DefinitionsContainer;
15
import in.shop2020.metamodel.definitions.DefinitionsContainer;
13
import in.shop2020.metamodel.definitions.EntityContainer;
16
import in.shop2020.metamodel.definitions.EntityContainer;
Line 652... Line 655...
652
		Utils.info("expFacetRuleDef=" + expFacetRuleDef);
655
		Utils.info("expFacetRuleDef=" + expFacetRuleDef);
653
		
656
		
654
		EntityContainer ents = 
657
		EntityContainer ents = 
655
			Catalog.getInstance().getEntityContainer();
658
			Catalog.getInstance().getEntityContainer();
656
		
659
		
-
 
660
		DefinitionsContainer defs = 
-
 
661
			Catalog.getInstance().getDefinitionsContainer();
-
 
662
		
657
		IRDataJythonWrapper jw = new IRDataJythonWrapper();
663
		IRDataJythonWrapper jw = new IRDataJythonWrapper();
658
		
664
		
659
		jw.setExpandedEntity(expEntity);
665
		jw.setExpandedEntity(expEntity);
660
		jw.setExpandedFacetRuleDefinition(expFacetRuleDef);
666
		jw.setExpandedFacetRuleDefinition(expFacetRuleDef);
661
		
667
		
Line 681... Line 687...
681
			}
687
			}
682
			
688
			
683
			// Can happen when to slide's feature which is dropped in favor 
689
			// Can happen when to slide's feature which is dropped in favor 
684
			// of a borrowed slide
690
			// of a borrowed slide
685
			else if(feature != null) {
691
			else if(feature != null) {
-
 
692
				
-
 
693
				// Normalize
-
 
694
				if(defs.needsNormalization(feature.getFeatureDefinitionID())) {
-
 
695
					Utils.info("needsNormalization feature=" + feature);
-
 
696
					
-
 
697
					feature = this.normalize(feature);
-
 
698
				}
-
 
699
				
686
				ExpandedFeature expFeature = new ExpandedFeature(feature);
700
				ExpandedFeature expFeature = new ExpandedFeature(feature);
687
				
701
				
688
				jw.setExpandedFeature(expFeature);
702
				jw.setExpandedFeature(expFeature);
689
				
703
				
690
				// Execute Python script
704
				// Execute Python script
Line 750... Line 764...
750
		}
764
		}
751
		
765
		
752
		Utils.info("0 facetXMLSnip=" + facetXMLSnip);
766
		Utils.info("0 facetXMLSnip=" + facetXMLSnip);
753
		return facetXMLSnip;
767
		return facetXMLSnip;
754
	}
768
	}
-
 
769
	
-
 
770
	/**
-
 
771
	 * 
-
 
772
	 * @param feature
-
 
773
	 * @return Feature
-
 
774
	 * @throws Exception 
-
 
775
	 */
-
 
776
	private Feature normalize(Feature feature) throws Exception {
-
 
777
		ExpandedFeature expFeature = new ExpandedFeature(feature);
-
 
778
 
-
 
779
		BulletDefinition bulletDef = 
-
 
780
			expFeature.getFeatureDefinition().getBulletDefinition();
-
 
781
		
-
 
782
		ExpandedBulletDefinition expBulletDef = new ExpandedBulletDefinition(
-
 
783
				bulletDef);
-
 
784
		
-
 
785
		if(expBulletDef.isPrimitive()) {
-
 
786
			PrimitiveNormalizationJythonWrapper jy = 
-
 
787
				new PrimitiveNormalizationJythonWrapper();
-
 
788
			
-
 
789
			jy.setExpandedFeature(expFeature);
-
 
790
			
-
 
791
			jy.excuteRule();
-
 
792
			
-
 
793
			String newValue = jy.getNewValue();
-
 
794
			long newUnitID = jy.getNewUnitID();
-
 
795
			
-
 
796
			List<Bullet> newBullets = new ArrayList<Bullet>();
-
 
797
			Bullet newBullet = new Bullet(new PrimitiveDataObject(newValue));
-
 
798
			newBullet.setUnitID(newUnitID);
-
 
799
			
-
 
800
			newBullets.add(newBullet);
-
 
801
			
-
 
802
			feature.setBullets(newBullets);
-
 
803
		}
-
 
804
		else {
-
 
805
			Utils.severe("Normalization not defined for non-primitives");
-
 
806
		}
-
 
807
		
-
 
808
		return feature;
-
 
809
	}
755
 
810
 
756
	/**
811
	/**
757
	 * 
812
	 * 
758
	 * @param expEntity
813
	 * @param expEntity
759
	 * @param facetFeatureIDs
814
	 * @param facetFeatureIDs