/* (non-Javadoc)
@see com.abubusoft.kripton.processor.core.ModelElementVisitor#visit(com.abubusoft.kripton.processor.core.ModelProperty)
7596
@Override
	public void visit(SQLProperty property) throws Exception {
		// add property index
		classBuilder.addField(FieldSpec.builder(Integer.TYPE, "index"+(counter++), Modifier.PROTECTED).addJavadoc("Index for column $S\n", property.getName()).build());

	}
1180970
public void visit(BioPAXElement domain, Object range, Model targetModel, PropertyEditor editor)
	{
		BioPAXElement targetDomain = targetModel.getByID(domain.getUri());
		
		if (range instanceof BioPAXElement)
		{
			BioPAXElement bpe = (BioPAXElement) range;
			BioPAXElement existing = targetModel.getByID(bpe.getUri());
			//set the property value if the value is already present in the target 
			if (existing != null) {
				editor.setValueToBean(existing, targetDomain);
			}
		}
		else
		{
			editor.setValueToBean(range, targetDomain);
		}
	}
245406
@Override
    public void visit(PrimitiveParameter primitiveParameter) {
        assert this.kh != null : "kh wasn't set";
        PrimitiveParameter param = new PrimitiveParameter(propId, this.uniqueIdProvider.getInstance());
        param.setPosition(primitiveParameter.getPosition());
        param.setGranularity(primitiveParameter.getGranularity());
        param.setValue(primitiveParameter.getValue());
        param.setSourceSystem(SourceSystem.DERIVED);
        param.setCreateDate(new Date());
        this.kh.insertLogical(param);
        this.derivationsBuilder.propositionAsserted(primitiveParameter, param);
        LOGGER.log(Level.FINER, "Asserted derived proposition {0}", param);
    }
915816
@Override
    public void visitEnd() {
        if (!fieldAlreadyExists) {
            FieldVisitor fv = super.visitField(
                                               Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC,
                                               versionFieldName,
                                               Type.getDescriptor(String.class),
                                               null,
                                               versionFieldValue);
            fv.visitEnd();
        }

        super.visitEnd();
    }
971434
public void traverse(JavacASTVisitor visitor) {
		switch (this.getKind()) {
		case COMPILATION_UNIT:
			visitor.visitCompilationUnit(this, (JCCompilationUnit) get());
			ast.traverseChildren(visitor, this);
			visitor.endVisitCompilationUnit(this, (JCCompilationUnit) get());
			break;
		case TYPE:
			visitor.visitType(this, (JCClassDecl) get());
			ast.traverseChildren(visitor, this);
			visitor.endVisitType(this, (JCClassDecl) get());
			break;
		case FIELD:
			visitor.visitField(this, (JCVariableDecl) get());
			ast.traverseChildren(visitor, this);
			visitor.endVisitField(this, (JCVariableDecl) get());
			break;
		case METHOD:
			visitor.visitMethod(this, (JCMethodDecl) get());
			ast.traverseChildren(visitor, this);
			visitor.endVisitMethod(this, (JCMethodDecl) get());
			break;
		case INITIALIZER:
			visitor.visitInitializer(this, (JCBlock) get());
			ast.traverseChildren(visitor, this);
			visitor.endVisitInitializer(this, (JCBlock) get());
			break;
		case ARGUMENT:
			JCMethodDecl parentMethod = (JCMethodDecl) up().get();
			visitor.visitMethodArgument(this, (JCVariableDecl) get(), parentMethod);
			ast.traverseChildren(visitor, this);
			visitor.endVisitMethodArgument(this, (JCVariableDecl) get(), parentMethod);
			break;
		case LOCAL:
			visitor.visitLocal(this, (JCVariableDecl) get());
			ast.traverseChildren(visitor, this);
			visitor.endVisitLocal(this, (JCVariableDecl) get());
			break;
		case STATEMENT:
			visitor.visitStatement(this, get());
			ast.traverseChildren(visitor, this);
			visitor.endVisitStatement(this, get());
			break;
		case ANNOTATION:
			switch (up().getKind()) {
			case TYPE:
				visitor.visitAnnotationOnType((JCClassDecl) up().get(), this, (JCAnnotation) get());
				break;
			case FIELD:
				visitor.visitAnnotationOnField((JCVariableDecl) up().get(), this, (JCAnnotation) get());
				break;
			case METHOD:
				visitor.visitAnnotationOnMethod((JCMethodDecl) up().get(), this, (JCAnnotation) get());
				break;
			case ARGUMENT:
				JCVariableDecl argument = (JCVariableDecl) up().get();
				JCMethodDecl method = (JCMethodDecl) up().up().get();
				visitor.visitAnnotationOnMethodArgument(argument, method, this, (JCAnnotation) get());
				break;
			case LOCAL:
				visitor.visitAnnotationOnLocal((JCVariableDecl) up().get(), this, (JCAnnotation) get());
				break;
			case TYPE_USE:
				visitor.visitAnnotationOnTypeUse(up().get(), this, (JCAnnotation) get());
				break;
			default:
				throw new AssertionError("Annotion not expected as child of a " + up().getKind());
			}
			break;
		case TYPE_USE:
			visitor.visitTypeUse(this, get());
			ast.traverseChildren(visitor, this);
			visitor.endVisitTypeUse(this, get());
			break;
		default:
			throw new AssertionError("Unexpected kind during node traversal: " + getKind());
		}
	}
296623
protected void visit(Object value, BioPAXElement parent,
			Model newModel, PropertyEditor editor)
	{
			if(editor != null && editor.isUnknown(value)) {
				return;
			}

			String parentType = parent.getModelInterface().getSimpleName();
			BioPAXElement newParent = null;
			Object newValue = value;
			String newProp = propsmap.getProperty(editor.getProperty());

			// special case (PATHWAY-COMPONENTS maps to pathwayComponent or pathwayOrder)
			if(parent instanceof pathway && value instanceof pathwayStep
					&& editor.getProperty().equals("PATHWAY-COMPONENTS")) {
				newProp = "pathwayOrder";
			}

			// for pEPs, getting the corresponding simple PE or Complex is different
			if(parent instanceof physicalEntityParticipant) {
				newParent = getMappedPE((physicalEntityParticipant) parent, newModel);
			} else {
				newParent = newModel.getByID(parent.getUri());
			}

			// bug check!
			if(newParent == null) {
				throw new IllegalAccessError("Of " + value +
					", parent " + parentType + " : " + parent +
					" is not yet in the new model: ");
			}

			PropertyEditor newEditor =
				SimpleEditorMap.L3.getEditorForProperty(newProp, newParent.getModelInterface());

			if(value instanceof Level2Element)
			// not a String, Enum, or primitive type
			{
				// when pEP, create/add stoichiometry!
				if(value instanceof physicalEntityParticipant)
				{
					physicalEntityParticipant pep = (physicalEntityParticipant) value;
					newValue = getMappedPE(pep, newModel);

					float coeff = (float) pep.getSTOICHIOMETRIC_COEFFICIENT();
					if (coeff > 1 ) { //!= BioPAXElement.UNKNOWN_DOUBLE) {
					  if(parent instanceof conversion || parent instanceof complex) {
						PhysicalEntity pe3 = (PhysicalEntity) newValue;
						Stoichiometry stoichiometry = factory
							.create(Stoichiometry.class,
                                    pe3.getUri() + "-stoichiometry" + Math.random());
						stoichiometry.setStoichiometricCoefficient(coeff);
						stoichiometry.setPhysicalEntity(pe3);
						//System.out.println("parent=" + parent + "; phy.ent.=" + pep + "; coeff=" + coeff);
						if (parent instanceof conversion) {
							// (pep) value participates in the conversion interaction
							Conversion conv = (Conversion) newModel
								.getByID(parent.getUri());
							conv.addParticipantStoichiometry(stoichiometry);	
						} else {
							// this (pep) value is component of the complex
							Complex cplx = (Complex) newModel.getByID(parent.getUri());
							cplx.addComponentStoichiometry(stoichiometry);
						} 
						
						newModel.add(stoichiometry);
						
					  } else {
						if (log.isDebugEnabled())
							log.debug(pep + " STOICHIOMETRIC_COEFFICIENT is "
								+ coeff	+ ", but the pEP's parent is not a conversion or complex - " + parent);
					  }
					}
					
					traverse(pep, newModel);
				}
				else if(value instanceof openControlledVocabulary) 
				{
					// create the proper type ControlledVocabulary instance	
					newValue = convertAndAddVocabulary((openControlledVocabulary)value, 
						(Level2Element)parent, newModel, newEditor);
				}
				else
				{
					String id = ((Level2Element) value).getUri();
					newValue = newModel.getByID(id);
				}
			}
			else if (value.getClass().isEnum())
			{
				newValue = getMatchingEnum(value);
			}
			else
			{
				// relationshipXref.RELATIONSHIP-TYPE range changed (String -> RelationshipTypeVocabulaty)
				if(parent instanceof relationshipXref && editor.getProperty().equals("RELATIONSHIP-TYPE")) {
					String id = URLEncoder.encode(value.toString());
					if(!newModel.containsID(id)) {
						RelationshipTypeVocabulary cv = (RelationshipTypeVocabulary) 
							newModel.addNew(newEditor.getRange(), id);
						cv.addTerm(value.toString().toLowerCase());
						newValue = cv;
					} else {
						newValue = newModel.getByID(id);
					}
				}
			}
			
			if(newValue == null) {
				log.debug("Skipped for  " + parent + "." + editor.getProperty()
					+ "=" + value + " ==> " + newParent.getUri() + "." + newProp	+ " = NULL");
				return;
			}
			
			if (newProp != null) {
				if (newEditor != null){
					setNewProperty(newParent, newValue, newEditor);
				} else if(parent instanceof physicalEntity) {
					// Special mapping for 'AVAILABILITY' and 'DATA-SOURCE'
					// find parent pEP(s)
					Set<physicalEntityParticipant> ppeps = ((physicalEntity)parent).isPHYSICAL_ENTITYof();
					// if several pEPs use the same phy.entity, we get this property/value cloned...
					for(physicalEntityParticipant pep: ppeps) {
						//find proper L3 physical entity
						newParent = getMappedPE(pep, newModel);
						if(newParent != null) {
							newEditor = SimpleEditorMap.L3.getEditorForProperty(newProp, newParent.getModelInterface());
							setNewProperty(newParent, newValue, newEditor);
						} else { // bug!
							log.error("Cannot find converted PE to map the property " 
								+ editor.getProperty() + " of physicalEntity " + parent + " (" + parentType + ")");
						}
					}
				} else {
					log.debug("Skipped property " + editor.getProperty() + " in " + parentType + " to " +
						newParent.getModelInterface().getSimpleName() + " conversion (" + parent + ")");
				}
			} else {
				log.warn("No mapping defined for property: " + parentType + "." + editor.getProperty());
			} 
		}
1085113
public void visitPropertyMap(PropertyMap<S, D> propertyMap) {
    String propertyMapClassName = propertyMap.getClass().getName();

    try {
      ClassReader cr = new ClassReader(propertyMap.getClass().getClassLoader().getResourceAsStream(
          propertyMapClassName.replace('.', '/') + ".class"));
      ExplicitMappingVisitor visitor = new ExplicitMappingVisitor(errors, configuration,
          propertyMapClassName, destinationType.getName(), propertyMap.getClass().getClassLoader());
      cr.accept(visitor, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
      visitedMappings = visitor.mappings;
    } catch (IOException e) {
      errors.errorReadingClass(e, propertyMapClassName);
    }

    errors.throwConfigurationExceptionIfErrorsExist();
    createProxies();
  }
831968
@Override
    public void visitMethod(Method obj) {
        methodName = obj.getName();
        state = State.SAW_NOTHING;
    }
1358478
public void explore() {
        if (isLeaf) return;
        if (isGeneric) return;
        removeAllChildren();

        try {
            String addressPath = addressPath();
            ModelNode resourceDesc = executor.doCommand(addressPath + ":read-resource-description");
            resourceDesc = resourceDesc.get("result");
            ModelNode response = executor.doCommand(addressPath + ":read-resource(include-runtime=true,include-defaults=true)");
            ModelNode result = response.get("result");
            if (!result.isDefined()) return;

            List<String> childrenTypes = getChildrenTypes(addressPath);
            for (ModelNode node : result.asList()) {
                Property prop = node.asProperty();
                if (childrenTypes.contains(prop.getName())) { // resource node
                    if (hasGenericOperations(addressPath, prop.getName())) {
                        add(new ManagementModelNode(cliGuiCtx, new UserObject(node, prop.getName())));
                    }
                    if (prop.getValue().isDefined()) {
                        for (ModelNode innerNode : prop.getValue().asList()) {
                            UserObject usrObj = new UserObject(innerNode, prop.getName(), innerNode.asProperty().getName());
                            add(new ManagementModelNode(cliGuiCtx, usrObj));
                        }
                    }
                } else { // attribute node
                    UserObject usrObj = new UserObject(node, resourceDesc, prop.getName(), prop.getValue().asString());
                    add(new ManagementModelNode(cliGuiCtx, usrObj));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
455736
private void visitComponentModel(final ObjectGraphNode node) {
		ComponentModel model = (ComponentModel) node.getValue();
		ComponentModel sharedModel = null;

		List<Field> fieldList = ReflectionUtil.getAllFields(node.getValue(), true, false);
		Field[] fields = fieldList.toArray(new Field[fieldList.size()]);

		for (int i = 0; i < fields.length; i++) {
			if (ComponentModel.class.equals(fields[i].getDeclaringClass())
					&& "sharedModel".equals(fields[i].getName())) {
				sharedModel = (ComponentModel) readField(fields[i], model);
			}
		}

		visitComplexTypeWithDiff(node, sharedModel);
	}
686949
@Override
    public void visit(NodeVisitor v) {
        if (v.visit(this)) {
            expression.visit(v);
            statement.visit(v);
        }
    }
1310987
@Override
    public void visit(NodeVisitor v) {
        if (v.visit(this)) {
            for (XmlFragment frag : fragments) {
                frag.visit(v);
            }
        }
    }
932718
@Override
    public void visit(JavaClass someObj) {
        currentClass = someObj.getClassName();
        currentMethod = null;
        currentCFG = null;
        currentLockDataFlow = null;
        sawDateClass = false;

    }
1101430
@Override
    public void visit(NodeVisitor v) {
        if (v.visit(this)) {
            body.visit(v);
            condition.visit(v);
        }
    }
1254976
@Override
    public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
        this.classVersion = version;
        this.classType = Type.getObjectType(name);
        this.isInterface = (access & Opcodes.ACC_INTERFACE) != 0;
        this.isSynthetic = (access & Opcodes.ACC_SYNTHETIC) != 0;

        super.visit(version, access, name, signature, superName, interfaces);
    }
1006293
@Override
    public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
        fieldAlreadyExists |= name.equals(versionFieldName);

        return super.visitField(access, name, desc, signature, value);
    }
922662
@Override
    public void visit(NodeVisitor v) {
        if (v.visit(this) && value != null) {
            value.visit(v);
        }
    }